Skip to content

Commit bb648d6

Browse files
authored
feat: add cli option --rebuild-rag (#1074)
1 parent 1a07be7 commit bb648d6

File tree

7 files changed

+14
-1
lines changed

7 files changed

+14
-1
lines changed

scripts/completions/aichat.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ _aichat() {
1717

1818
case "${cmd}" in
1919
aichat)
20-
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"
20+
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"
2121
if [[ ${cur} == -* || ${cword} -eq 1 ]] ; then
2222
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
2323
return 0

scripts/completions/aichat.fish

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ complete -c aichat -l save-session -d 'Ensure the new conversation is saved to t
77
complete -c aichat -s a -l agent -x -a "(aichat --list-agents)" -d 'Start a agent' -r
88
complete -c aichat -l agent-variable -d 'Set agent variables'
99
complete -c aichat -l rag -x -a"(aichat --list-rags)" -d 'Start a RAG' -r
10+
complete -c aichat -l rebuild-rag -d 'Rebuild the RAG to sync document changes'
1011
complete -c aichat -l serve -d 'Serve the LLM API and WebAPP'
1112
complete -c aichat -s e -l execute -d 'Execute commands in natural language'
1213
complete -c aichat -s c -l code -d 'Output code only'

scripts/completions/aichat.nu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module completions {
4545
--agent(-a): string@"nu-complete aichat agent" # Start a agent
4646
--agent-variable # Set agent variables
4747
--rag: string@"nu-complete aichat rag" # Start a RAG
48+
--rebuild-rag # Rebuild the RAG to sync document changes
4849
--serve # Serve the LLM API and WebAPP
4950
--execute(-e) # Execute commands in natural language
5051
--code(-c) # Output code only

scripts/completions/aichat.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Register-ArgumentCompleter -Native -CommandName 'aichat' -ScriptBlock {
3333
[CompletionResult]::new('--agent', '--agent', [CompletionResultType]::ParameterName, 'Start a agent')
3434
[CompletionResult]::new('--agent-variable', '--agent-variable', [CompletionResultType]::ParameterName, 'Set agent variables')
3535
[CompletionResult]::new('--rag', '--rag', [CompletionResultType]::ParameterName, 'Start a RAG')
36+
[CompletionResult]::new('--rebuild-rag', '--rebuild-rag', [CompletionResultType]::ParameterName, 'Rebuild the RAG to sync document changes')
3637
[CompletionResult]::new('--serve', '--serve', [CompletionResultType]::ParameterName, 'Serve the LLM API and WebAPP')
3738
[CompletionResult]::new('-e', '-e', [CompletionResultType]::ParameterName, 'Execute commands in natural language')
3839
[CompletionResult]::new('--execute', '--execute', [CompletionResultType]::ParameterName, 'Execute commands in natural language')

scripts/completions/aichat.zsh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ _aichat() {
2828
'--agent[Start a agent]:AGENT:->agents' \
2929
'--agent-variable[Set agent variables]' \
3030
'--rag[Start a RAG]:RAG:->rags' \
31+
'--rebuild-rag[Rebuild the RAG to sync document changes]' \
3132
'--serve[Serve the LLM API and WebAPP]' \
3233
'-e[Execute commands in natural language]' \
3334
'--execute[Execute commands in natural language]' \

src/cli.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ pub struct Cli {
3030
/// Start a RAG
3131
#[clap(long)]
3232
pub rag: Option<String>,
33+
/// Rebuild the RAG to sync document changes
34+
#[clap(long)]
35+
pub rebuild_rag: bool,
3336
/// Serve the LLM API and WebAPP
3437
#[clap(long, value_name = "ADDRESS")]
3538
pub serve: Option<Option<String>>,

src/main.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ async fn run(config: GlobalConfig, cli: Cli, text: Option<String>) -> Result<()>
152152
return Ok(());
153153
}
154154
let is_repl = config.read().working_mode.is_repl();
155+
if cli.rebuild_rag {
156+
Config::rebuild_rag(&config, abort_signal.clone()).await?;
157+
if is_repl {
158+
return Ok(());
159+
}
160+
}
155161
if cli.execute && !is_repl {
156162
if cfg!(target_os = "macos") && !stdin().is_terminal() {
157163
bail!("Unable to read the pipe for shell execution on MacOS")

0 commit comments

Comments
 (0)