diff --git a/scripts/completions/aichat.bash b/scripts/completions/aichat.bash index 9b6a4627..260a9d42 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 -R -e -c -f -S -h -V --model --prompt --role --session --save-session --agent --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 -R -e -c -f -S -h -V --model --prompt --role --session --empty-session --save-session --agent --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 90c17f0a..f5b2576d 100644 --- a/scripts/completions/aichat.fish +++ b/scripts/completions/aichat.fish @@ -2,7 +2,8 @@ complete -c aichat -s m -l model -x -a "(aichat --list-models)" -d 'Select a LLM complete -c aichat -l prompt -d 'Use the system prompt' complete -c aichat -s r -l role -x -a "(aichat --list-roles)" -d 'Select a role' -r complete -c aichat -s s -l session -x -a"(aichat --list-sessions)" -d 'Start or join a session' -r -complete -c aichat -l save-session -d 'Forces the session to be saved' +complete -c aichat -l empty-session -d 'Ensure the session is empty' +complete -c aichat -l save-session -d 'Force the session to be saved' complete -c aichat -s a -l agent -x -a"(aichat --list-agents)" -d 'Start a agent' -r complete -c aichat -s R -l rag -x -a"(aichat --list-rags)" -d 'Start a RAG' -r complete -c aichat -l serve -d 'Serve the LLM API and WebAPP' diff --git a/scripts/completions/aichat.nu b/scripts/completions/aichat.nu index dcd7043b..22b3d31c 100644 --- a/scripts/completions/aichat.nu +++ b/scripts/completions/aichat.nu @@ -40,7 +40,8 @@ module completions { --prompt # Use the system prompt --role(-r): string@"nu-complete aichat role" # Select a role --session(-s): string@"nu-complete aichat session" # Start or join a session - --save-session # Forces the session to be saved + --empty-session # Ensure the session is empty + --save-session # Force the session to be saved --agent(-a): string@"nu-complete aichat agent" # Start a agent --rag(-R): string@"nu-complete aichat rag" # Start a RAG --serve # Serve the LLM API and WebAPP diff --git a/scripts/completions/aichat.ps1 b/scripts/completions/aichat.ps1 index 2f30bd14..025427ed 100644 --- a/scripts/completions/aichat.ps1 +++ b/scripts/completions/aichat.ps1 @@ -27,7 +27,8 @@ Register-ArgumentCompleter -Native -CommandName 'aichat' -ScriptBlock { [CompletionResult]::new('--role', '--role', [CompletionResultType]::ParameterName, 'Select a role') [CompletionResult]::new('-s', '-s', [CompletionResultType]::ParameterName, 'Start or join a session') [CompletionResult]::new('--session', '--session', [CompletionResultType]::ParameterName, 'Start or join a session') - [CompletionResult]::new('--save-session', '--save-session', [CompletionResultType]::ParameterName, 'Forces the session to be saved') + [CompletionResult]::new('--empty-session', '--empty-session', [CompletionResultType]::ParameterName, 'Ensure the session is empty') + [CompletionResult]::new('--save-session', '--save-session', [CompletionResultType]::ParameterName, 'Force the session to be saved') [CompletionResult]::new('-a', '-a', [CompletionResultType]::ParameterName, 'Start a agent') [CompletionResult]::new('--agent', '--agent', [CompletionResultType]::ParameterName, 'Start a agent') [CompletionResult]::new('-R', '-R', [CompletionResultType]::ParameterName, 'Start a RAG') diff --git a/scripts/completions/aichat.zsh b/scripts/completions/aichat.zsh index 62434a47..c13cb700 100644 --- a/scripts/completions/aichat.zsh +++ b/scripts/completions/aichat.zsh @@ -22,7 +22,8 @@ _aichat() { '--role[Select a role]:ROLE:->roles' \ '-s[Start or join a session]:SESSION:->sessions' \ '--session[Start or join a session]:SESSION:->sessions' \ -'--save-session[Forces the session to be saved]' \ +'--empty-session[Ensure the session is empty]' \ +'--save-session[Force the session to be saved]' \ '-a[Start a agent]:AGENT:->agents' \ '--agent[Start a agent]:AGENT:->agents' \ '-R[Start a RAG]:RAG:->rags' \ diff --git a/src/cli.rs b/src/cli.rs index e59571d5..643b1d8b 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -15,7 +15,10 @@ pub struct Cli { /// Start or join a session #[clap(short = 's', long)] pub session: Option>, - /// Forces the session to be saved + /// Ensure the session is empty + #[clap(long)] + pub empty_session: bool, + /// Force the session to be saved #[clap(long)] pub save_session: bool, /// Start a agent diff --git a/src/config/mod.rs b/src/config/mod.rs index 97ec014f..f8e36724 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1090,7 +1090,7 @@ impl Config { Ok(()) } - pub fn clear_session_messages(&mut self) -> Result<()> { + pub fn empty_session(&mut self) -> Result<()> { if let Some(session) = self.session.as_mut() { session.clear_messages(); if let Some(agent) = self.agent.as_ref() { diff --git a/src/main.rs b/src/main.rs index 299dc6bd..b9bb54f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -128,6 +128,9 @@ async fn run(config: GlobalConfig, cli: Cli, text: Option) -> Result<()> if cli.no_stream { config.write().stream = false; } + if cli.empty_session { + config.write().empty_session()?; + } if cli.save_session { config.write().set_save_session(Some(true)); } diff --git a/src/repl/mod.rs b/src/repl/mod.rs index a7b25736..5a741c23 100644 --- a/src/repl/mod.rs +++ b/src/repl/mod.rs @@ -475,7 +475,7 @@ impl Repl { }, ".clear" => match args { Some("messages") => { - self.config.write().clear_session_messages()?; + self.config.write().empty_session()?; } _ => unknown_command()?, },