diff options
| author | sigoden <sigoden@gmail.com> | 2024-06-17 13:19:00 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-17 13:19:00 +0800 |
| commit | ba884c9fc65d820f8603859acafd055b98897b56 (patch) | |
| tree | 3b319a01322ed7a74822634f775c0e0cadfe3753 /src/repl/mod.rs | |
| parent | bbdd866eb325fde60241f33eeb8770b1180abd96 (diff) | |
| download | aichat-ba884c9fc65d820f8603859acafd055b98897b56.tar.gz | |
feat: add `.continue` repl command (#608)
Diffstat (limited to 'src/repl/mod.rs')
| -rw-r--r-- | src/repl/mod.rs | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/repl/mod.rs b/src/repl/mod.rs index 5b37d36..cfeb341 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; 24] = [ + static ref REPL_COMMANDS: [ReplCommand; 25] = [ 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()), @@ -123,6 +123,7 @@ lazy_static! { "Include files with the message", AssertState::pass() ), + ReplCommand::new(".continue", "Continue response", AssertState::pass()), ReplCommand::new(".set", "Adjust settings", AssertState::pass()), ReplCommand::new(".copy", "Copy the last response", AssertState::pass()), ReplCommand::new(".exit", "Exit the REPL", AssertState::pass()), @@ -308,6 +309,23 @@ Tips: use <tab> to autocomplete conversation starter text. } } } + ".file" => match args { + Some(args) => { + let (files, text) = split_files_text(args); + let files = shell_words::split(files).with_context(|| "Invalid args")?; + let input = Input::new(&self.config, text, files, None)?; + ask(&self.config, self.abort_signal.clone(), input, true).await?; + } + None => println!("Usage: .file <files>... [-- <text>...]"), + }, + ".continue" => { + let (mut input, output) = match self.config.read().last_message.clone() { + Some(v) => v, + None => bail!("No incomplete response."), + }; + input.set_continue_output(&output); + ask(&self.config, self.abort_signal.clone(), input, true).await?; + } ".set" => match args { Some(args) => { self.config.write().update(args)?; @@ -321,15 +339,6 @@ Tips: use <tab> to autocomplete conversation starter text. self.copy(config.last_reply()) .with_context(|| "Failed to copy the last output")?; } - ".file" => match args { - Some(args) => { - let (files, text) = split_files_text(args); - let files = shell_words::split(files).with_context(|| "Invalid args")?; - let input = Input::new(&self.config, text, files, None)?; - ask(&self.config, self.abort_signal.clone(), input, true).await?; - } - None => println!("Usage: .file <files>... [-- <text>...]"), - }, ".exit" => match args { Some("role") => { self.config.write().exit_role()?; |
