From beaf5946a98f1552763ff974942cc71ee531fe62 Mon Sep 17 00:00:00 2001 From: sigoden Date: Sat, 14 Sep 2024 20:10:49 +0800 Subject: feat: add `.source rag` repl command (#871) --- src/repl/mod.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/repl') diff --git a/src/repl/mod.rs b/src/repl/mod.rs index 09fa74d..57e0376 100644 --- a/src/repl/mod.rs +++ b/src/repl/mod.rs @@ -31,7 +31,7 @@ lazy_static::lazy_static! { const MENU_NAME: &str = "completion_menu"; lazy_static::lazy_static! { - static ref REPL_COMMANDS: [ReplCommand; 32] = [ + static ref REPL_COMMANDS: [ReplCommand; 33] = [ ReplCommand::new(".help", "Show this help message", AssertState::pass()), ReplCommand::new(".info", "View system info", AssertState::pass()), ReplCommand::new(".model", "Change the current LLM", AssertState::pass()), @@ -105,6 +105,11 @@ lazy_static::lazy_static! { "Rebuild the RAG to sync document changes", AssertState::True(StateFlags::RAG), ), + ReplCommand::new( + ".sources rag", + "View the RAG sources in the last query", + AssertState::True(StateFlags::RAG), + ), ReplCommand::new( ".info rag", "View RAG info", @@ -368,6 +373,20 @@ impl Repl { } } } + ".sources" => { + match args.map(|v| match v.split_once(' ') { + Some((subcmd, args)) => (subcmd, Some(args.trim())), + None => (v, None), + }) { + Some(("rag", _)) => { + let output = Config::rag_sources(&self.config)?; + println!("{}", output); + } + _ => { + println!(r#"Usage: .sources rag"#) + } + } + } ".file" => match args { Some(args) => { let (files, text) = split_files_text(args); -- cgit v1.2.3