summaryrefslogtreecommitdiffstats
path: root/src/repl/mod.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-03-09 10:39:28 +0800
committerGitHub <noreply@github.com>2023-03-09 10:39:28 +0800
commita62e461e38482ade15c6826e656393d5f867488a (patch)
treebb8c0d76e6863e761f273059744bee722c0ab260 /src/repl/mod.rs
parenta7f2da156c0692121e35dbe20bdacc76baadd5c4 (diff)
downloadaichat-a62e461e38482ade15c6826e656393d5f867488a.tar.gz
feat: support conversation (#48)
Diffstat (limited to 'src/repl/mod.rs')
-rw-r--r--src/repl/mod.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/repl/mod.rs b/src/repl/mod.rs
index e9a0b51..9407bcf 100644
--- a/src/repl/mod.rs
+++ b/src/repl/mod.rs
@@ -15,12 +15,14 @@ use anyhow::{Context, Result};
use reedline::Signal;
use std::sync::Arc;
-pub const REPL_COMMANDS: [(&str, &str, bool); 10] = [
+pub const REPL_COMMANDS: [(&str, &str, bool); 12] = [
(".info", "Print the information", false),
(".set", "Modify the configuration temporarily", false),
(".prompt", "Add a GPT prompt", true),
(".role", "Select a role", false),
(".clear role", "Clear the currently selected role", false),
+ (".conversation", "Start a conversation.", false),
+ (".clear conversation", "End the conversation.", false),
(".history", "Print the history", false),
(".clear history", "Clear the history", false),
(".editor", "Enter editor mode for multiline input", true),
@@ -102,6 +104,7 @@ impl Repl {
print_now!("\n");
}
Some("role") => handler.handle(ReplCmd::ClearRole)?,
+ Some("conversation") => handler.handle(ReplCmd::EndConversatoin)?,
_ => dump_unknown_command(),
},
".history" => {
@@ -113,7 +116,7 @@ impl Repl {
None => print_now!("Usage: .role <name>\n\n"),
},
".info" => {
- handler.handle(ReplCmd::Info)?;
+ handler.handle(ReplCmd::ViewInfo)?;
}
".editor" => {
let mut text = args.unwrap_or_default().to_string();
@@ -140,6 +143,9 @@ impl Repl {
handler.handle(ReplCmd::Prompt(text))?;
}
}
+ ".conversation" => {
+ handler.handle(ReplCmd::StartConversation)?;
+ }
_ => dump_unknown_command(),
}
} else {
@@ -157,11 +163,11 @@ fn dump_unknown_command() {
fn dump_repl_help() {
let head = REPL_COMMANDS
.iter()
- .map(|(name, desc, _)| format!("{name:<15} {desc}"))
+ .map(|(name, desc, _)| format!("{name:<24} {desc}"))
.collect::<Vec<String>>()
.join("\n");
print_now!(
- "{}\n\nPress Ctrl+C to abort session, Ctrl+D to exit the REPL\n\n",
+ "{}\n\nPress Ctrl+C to abort conversation, Ctrl+D to exit the REPL\n\n",
head,
);
}