diff options
| author | sigoden <sigoden@gmail.com> | 2024-09-14 20:10:49 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-14 20:10:49 +0800 |
| commit | beaf5946a98f1552763ff974942cc71ee531fe62 (patch) | |
| tree | 2588545daec3169cc93c389de4bbcb421a1cd60d /src/repl | |
| parent | 6211d01a648e941fc69954d0855bcdcef98f27b9 (diff) | |
| download | aichat-beaf5946a98f1552763ff974942cc71ee531fe62.tar.gz | |
feat: add `.source rag` repl command (#871)
Diffstat (limited to 'src/repl')
| -rw-r--r-- | src/repl/mod.rs | 21 |
1 files changed, 20 insertions, 1 deletions
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()), @@ -106,6 +106,11 @@ lazy_static::lazy_static! { 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", AssertState::True(StateFlags::RAG), @@ -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); |
