summaryrefslogtreecommitdiffstats
path: root/src/repl/mod.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-07-01 20:19:41 +0800
committerGitHub <noreply@github.com>2024-07-01 20:19:41 +0800
commit7c6dac061b2a33aae334c08b725e02459c5e9ade (patch)
tree3c2067aaf80a24f988600b42aa12b647675bc383 /src/repl/mod.rs
parentd193950d204ed82bdb3d6a3a111511d189f084bb (diff)
downloadaichat-7c6dac061b2a33aae334c08b725e02459c5e9ade.tar.gz
feat: support `.rebuild rag` repl command(#672)
Diffstat (limited to 'src/repl/mod.rs')
-rw-r--r--src/repl/mod.rs26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/repl/mod.rs b/src/repl/mod.rs
index 6c15002..2111c48 100644
--- a/src/repl/mod.rs
+++ b/src/repl/mod.rs
@@ -33,7 +33,7 @@ lazy_static! {
const MENU_NAME: &str = "completion_menu";
lazy_static! {
- static ref REPL_COMMANDS: [ReplCommand; 26] = [
+ static ref REPL_COMMANDS: [ReplCommand; 27] = [
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()),
@@ -89,17 +89,22 @@ lazy_static! {
),
ReplCommand::new(
".rag",
- "Init or use a rag",
+ "Init or use the RAG",
AssertState::False(StateFlags::AGENT)
),
ReplCommand::new(
".info rag",
- "View rag info",
+ "View RAG info",
+ AssertState::True(StateFlags::RAG),
+ ),
+ ReplCommand::new(
+ ".rebuild rag",
+ "Rebuild the RAG to sync document changes",
AssertState::True(StateFlags::RAG),
),
ReplCommand::new(
".exit rag",
- "Leave the rag",
+ "Leave the RAG",
AssertState::TrueFalse(StateFlags::RAG, StateFlags::AGENT),
),
ReplCommand::new(".agent", "Use a agent", AssertState::bare()),
@@ -314,6 +319,19 @@ Tips: use <tab> to autocomplete conversation starter text.
}
}
}
+ ".rebuild" => {
+ match args.map(|v| match v.split_once(' ') {
+ Some((subcmd, args)) => (subcmd, Some(args.trim())),
+ None => (v, None),
+ }) {
+ Some(("rag", _)) => {
+ Config::rebuild_rag(&self.config, self.abort_signal.clone()).await?;
+ }
+ _ => {
+ println!(r#"Usage: .rebuild rag"#)
+ }
+ }
+ }
".file" => match args {
Some(args) => {
let (files, text) = split_files_text(args);