From d9b8eabf23ae96fb395a8059c1e08840609499f4 Mon Sep 17 00:00:00 2001 From: sigoden Date: Sun, 28 Apr 2024 19:18:56 +0800 Subject: feat: add `--prompt` option (#454) --- src/cli.rs | 3 +++ src/main.rs | 4 +++- src/repl/mod.rs | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/cli.rs b/src/cli.rs index f6e12ab..8225b7f 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -6,6 +6,9 @@ pub struct Cli { /// Select a LLM model #[clap(short, long)] pub model: Option, + /// Use the system prompt + #[clap(long)] + pub prompt: Option, /// Select a role #[clap(short, long)] pub role: Option, diff --git a/src/main.rs b/src/main.rs index f3d3846..f691b6f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -80,7 +80,9 @@ async fn main() -> Result<()> { if cli.dry_run { config.write().dry_run = true; } - if let Some(name) = &cli.role { + if let Some(prompt) = &cli.prompt { + config.write().set_prompt(prompt)?; + } else if let Some(name) = &cli.role { config.write().set_role(name)?; } else if cli.execute { config.write().set_role(SHELL_ROLE)?; diff --git a/src/repl/mod.rs b/src/repl/mod.rs index dd1c735..6306f0b 100644 --- a/src/repl/mod.rs +++ b/src/repl/mod.rs @@ -32,7 +32,7 @@ lazy_static! { ReplCommand::new(".model", "Change the current LLM", State::all()), ReplCommand::new( ".prompt", - "Make a temporary role using a prompt", + "Create a temporary role using a custom prompt", State::able_change_role() ), ReplCommand::new( -- cgit v1.2.3