diff --git a/scripts/completions/aichat.bash b/scripts/completions/aichat.bash index cfa7ec81..c335a6e3 100644 --- a/scripts/completions/aichat.bash +++ b/scripts/completions/aichat.bash @@ -17,7 +17,7 @@ _aichat() { case "${cmd}" in aichat) - opts="-m -r -s -a -e -c -f -S -h -V --model --prompt --role --session --empty-session --save-session --agent --agent-variable --rag --serve --execute --code --file --no-stream --dry-run --info --list-models --list-roles --list-sessions --list-agents --list-rags --help --version" + opts="-m -r -s -a -e -c -f -S -h -V --model --prompt --role --session --empty-session --save-session --agent --agent-variable --rag --rebuild-rag --serve --execute --code --file --no-stream --dry-run --info --list-models --list-roles --list-sessions --list-agents --list-rags --help --version" if [[ ${cur} == -* || ${cword} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 diff --git a/scripts/completions/aichat.fish b/scripts/completions/aichat.fish index 19bf96e3..148af82c 100644 --- a/scripts/completions/aichat.fish +++ b/scripts/completions/aichat.fish @@ -7,6 +7,7 @@ complete -c aichat -l save-session -d 'Ensure the new conversation is saved to t complete -c aichat -s a -l agent -x -a "(aichat --list-agents)" -d 'Start a agent' -r complete -c aichat -l agent-variable -d 'Set agent variables' complete -c aichat -l rag -x -a"(aichat --list-rags)" -d 'Start a RAG' -r +complete -c aichat -l rebuild-rag -d 'Rebuild the RAG to sync document changes' complete -c aichat -l serve -d 'Serve the LLM API and WebAPP' complete -c aichat -s e -l execute -d 'Execute commands in natural language' complete -c aichat -s c -l code -d 'Output code only' diff --git a/scripts/completions/aichat.nu b/scripts/completions/aichat.nu index 447da497..748ffc15 100644 --- a/scripts/completions/aichat.nu +++ b/scripts/completions/aichat.nu @@ -45,6 +45,7 @@ module completions { --agent(-a): string@"nu-complete aichat agent" # Start a agent --agent-variable # Set agent variables --rag: string@"nu-complete aichat rag" # Start a RAG + --rebuild-rag # Rebuild the RAG to sync document changes --serve # Serve the LLM API and WebAPP --execute(-e) # Execute commands in natural language --code(-c) # Output code only diff --git a/scripts/completions/aichat.ps1 b/scripts/completions/aichat.ps1 index 7b3cc82b..30c8c791 100644 --- a/scripts/completions/aichat.ps1 +++ b/scripts/completions/aichat.ps1 @@ -33,6 +33,7 @@ Register-ArgumentCompleter -Native -CommandName 'aichat' -ScriptBlock { [CompletionResult]::new('--agent', '--agent', [CompletionResultType]::ParameterName, 'Start a agent') [CompletionResult]::new('--agent-variable', '--agent-variable', [CompletionResultType]::ParameterName, 'Set agent variables') [CompletionResult]::new('--rag', '--rag', [CompletionResultType]::ParameterName, 'Start a RAG') + [CompletionResult]::new('--rebuild-rag', '--rebuild-rag', [CompletionResultType]::ParameterName, 'Rebuild the RAG to sync document changes') [CompletionResult]::new('--serve', '--serve', [CompletionResultType]::ParameterName, 'Serve the LLM API and WebAPP') [CompletionResult]::new('-e', '-e', [CompletionResultType]::ParameterName, 'Execute commands in natural language') [CompletionResult]::new('--execute', '--execute', [CompletionResultType]::ParameterName, 'Execute commands in natural language') diff --git a/scripts/completions/aichat.zsh b/scripts/completions/aichat.zsh index ed7627e1..11da4e7f 100644 --- a/scripts/completions/aichat.zsh +++ b/scripts/completions/aichat.zsh @@ -28,6 +28,7 @@ _aichat() { '--agent[Start a agent]:AGENT:->agents' \ '--agent-variable[Set agent variables]' \ '--rag[Start a RAG]:RAG:->rags' \ +'--rebuild-rag[Rebuild the RAG to sync document changes]' \ '--serve[Serve the LLM API and WebAPP]' \ '-e[Execute commands in natural language]' \ '--execute[Execute commands in natural language]' \ diff --git a/src/cli.rs b/src/cli.rs index 2de6113c..18bc442c 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 11fea86a..056133cc 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")