From bb648d68845e0755edb03570237039433a752463 Mon Sep 17 00:00:00 2001 From: sigoden Date: Sat, 4 Jan 2025 18:13:57 +0800 Subject: feat: add cli option `--rebuild-rag` (#1074) --- src/cli.rs | 3 +++ src/main.rs | 6 ++++++ 2 files changed, 9 insertions(+) (limited to 'src') diff --git a/src/cli.rs b/src/cli.rs index 2de6113..18bc442 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -30,6 +30,9 @@ pub struct Cli { /// Start a RAG #[clap(long)] pub rag: Option, + /// Rebuild the RAG to sync document changes + #[clap(long)] + pub rebuild_rag: bool, /// Serve the LLM API and WebAPP #[clap(long, value_name = "ADDRESS")] pub serve: Option>, diff --git a/src/main.rs b/src/main.rs index 11fea86..056133c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -152,6 +152,12 @@ async fn run(config: GlobalConfig, cli: Cli, text: Option) -> Result<()> return Ok(()); } let is_repl = config.read().working_mode.is_repl(); + if cli.rebuild_rag { + Config::rebuild_rag(&config, abort_signal.clone()).await?; + if is_repl { + return Ok(()); + } + } if cli.execute && !is_repl { if cfg!(target_os = "macos") && !stdin().is_terminal() { bail!("Unable to read the pipe for shell execution on MacOS") -- cgit v1.2.3