From a9268b600fb378400795fbaf98bf923372b4c19a Mon Sep 17 00:00:00 2001 From: sigoden Date: Tue, 9 Jul 2024 21:22:51 +0800 Subject: feat: support agent variables (#692) --- src/repl/mod.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/repl/mod.rs') 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()), @@ -118,6 +118,11 @@ lazy_static! { "Use the conversation starter", AssertState::True(StateFlags::AGENT) ), + ReplCommand::new( + ".variable", + "Set agent variable", + AssertState::True(StateFlags::AGENT) + ), ReplCommand::new( ".exit agent", "Leave the agent", @@ -293,6 +298,14 @@ Tips: use to autocomplete conversation starter text. println!("{output}"); } }, + ".variable" => match args { + Some(args) => { + self.config.write().set_agent_variable(args)?; + } + _ => { + println!("Usage: .variable ") + } + }, ".save" => { match args.map(|v| match v.split_once(' ') { Some((subcmd, args)) => (subcmd, Some(args.trim())), -- cgit v1.2.3