summaryrefslogtreecommitdiffstats
path: root/src/repl/mod.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-06-17 17:03:28 +0800
committerGitHub <noreply@github.com>2024-06-17 17:03:28 +0800
commit62b297e8bb09e257a61154afddc4017e48bd12f3 (patch)
treeb402281f625b304ad99ba392597f65d9fca0b21e /src/repl/mod.rs
parentff284779d9757c128acaf690ddf64a87a986e413 (diff)
downloadaichat-62b297e8bb09e257a61154afddc4017e48bd12f3.tar.gz
feat: add `.regenerate` repl command (#610)
Diffstat (limited to 'src/repl/mod.rs')
-rw-r--r--src/repl/mod.rs17
1 files changed, 15 insertions, 2 deletions
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 <tab> 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)?;