summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-04-28 19:18:56 +0800
committerGitHub <noreply@github.com>2024-04-28 19:18:56 +0800
commitd9b8eabf23ae96fb395a8059c1e08840609499f4 (patch)
tree73c69f56c5ecd718daacd9450bb25ec8db0649b1 /src
parent4b205c4bac414f625001faa39fe36f9e118dfaa3 (diff)
downloadaichat-d9b8eabf23ae96fb395a8059c1e08840609499f4.tar.gz
feat: add `--prompt` option (#454)
Diffstat (limited to 'src')
-rw-r--r--src/cli.rs3
-rw-r--r--src/main.rs4
-rw-r--r--src/repl/mod.rs2
3 files changed, 7 insertions, 2 deletions
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<String>,
+ /// Use the system prompt
+ #[clap(long)]
+ pub prompt: Option<String>,
/// Select a role
#[clap(short, long)]
pub role: Option<String>,
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(