From 62b297e8bb09e257a61154afddc4017e48bd12f3 Mon Sep 17 00:00:00 2001 From: sigoden Date: Mon, 17 Jun 2024 17:03:28 +0800 Subject: feat: add `.regenerate` repl command (#610) --- src/repl/mod.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/repl/mod.rs') diff --git a/src/repl/mod.rs b/src/repl/mod.rs index cfeb341..ca718b5 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; 25] = [ + static ref REPL_COMMANDS: [ReplCommand; 26] = [ 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()), @@ -124,6 +124,11 @@ lazy_static! { AssertState::pass() ), ReplCommand::new(".continue", "Continue response", AssertState::pass()), + ReplCommand::new( + ".regenerate", + "Regenerate the last 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()), @@ -321,11 +326,19 @@ Tips: use to autocomplete conversation starter text. ".continue" => { let (mut input, output) = match self.config.read().last_message.clone() { Some(v) => v, - None => bail!("No incomplete response."), + None => bail!("Unable to continue response"), }; input.set_continue_output(&output); ask(&self.config, self.abort_signal.clone(), input, true).await?; } + ".regenerate" => { + let (mut input, _) = match self.config.read().last_message.clone() { + Some(v) => v, + None => bail!("Unable to regenerate the last response"), + }; + input.set_regenerate(); + ask(&self.config, self.abort_signal.clone(), input, true).await?; + } ".set" => match args { Some(args) => { self.config.write().update(args)?; -- cgit v1.2.3