summaryrefslogtreecommitdiffstats
path: root/src/repl
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-07-09 21:22:51 +0800
committerGitHub <noreply@github.com>2024-07-09 21:22:51 +0800
commita9268b600fb378400795fbaf98bf923372b4c19a (patch)
treeea0f3d79da0ae02041ad1313e9764a4750e8a3f1 /src/repl
parent138c90b58bf90be84de3fedbbdf8e05bf0820a11 (diff)
downloadaichat-a9268b600fb378400795fbaf98bf923372b4c19a.tar.gz
feat: support agent variables (#692)
Diffstat (limited to 'src/repl')
-rw-r--r--src/repl/mod.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/repl/mod.rs b/src/repl/mod.rs
index 2111c48..0100cb0 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; 27] = [
+ static ref REPL_COMMANDS: [ReplCommand; 28] = [
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()),
@@ -119,6 +119,11 @@ lazy_static! {
AssertState::True(StateFlags::AGENT)
),
ReplCommand::new(
+ ".variable",
+ "Set agent variable",
+ AssertState::True(StateFlags::AGENT)
+ ),
+ ReplCommand::new(
".exit agent",
"Leave the agent",
AssertState::True(StateFlags::AGENT)
@@ -293,6 +298,14 @@ Tips: use <tab> to autocomplete conversation starter text.
println!("{output}");
}
},
+ ".variable" => match args {
+ Some(args) => {
+ self.config.write().set_agent_variable(args)?;
+ }
+ _ => {
+ println!("Usage: .variable <key> <value>")
+ }
+ },
".save" => {
match args.map(|v| match v.split_once(' ') {
Some((subcmd, args)) => (subcmd, Some(args.trim())),