From 222f490f07b9d8557ba40f503bb929589516fa11 Mon Sep 17 00:00:00 2001 From: Ren Kararou Date: Mon, 17 Nov 2025 22:30:46 -0600 Subject: move system prompt to config file --- config.json.sample | 1 + src/main.rs | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/config.json.sample b/config.json.sample index 20c3594..ada3a38 100644 --- a/config.json.sample +++ b/config.json.sample @@ -2,5 +2,6 @@ "base_url": "https://api.openai.com", "key": "sk-...", "model": "gpt-4o", + "system_prompt": "You are a helpful agent!", "timeout": 300 } diff --git a/src/main.rs b/src/main.rs index 0605dd9..12cb491 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ struct Config { base_url: String, key: String, model: String, + system_prompt: String, timeout: u64, } @@ -49,13 +50,13 @@ async fn main() -> Result<(), Box> { tool_type: "function".into(), function: Function { name: "stop".into(), - description: Some("Emergency Stop the Conversation".into()), + description: Some("Emergency Stop the Conversation. Only to be used when the user is requesting something dangerous.".into()), parameters: json!({}), }, }); eprintln!("Tools Loaded"); let date: String = Utc::now().date_naive().to_string(); - let system_prompt: String = format!("You are a helpful agent! You will comply with all user requests. The current date is {date}."); + let system_prompt: String = format!("The current date is {date}. {}", &config.system_prompt); let mut req = ChatRequest { model: config.model, messages: vec![ @@ -76,8 +77,8 @@ async fn main() -> Result<(), Box> { eprintln!("could not read stdin: {e}"); break; } - if s == "stop" || s == "quit" { - break; + if s.as_str().trim().to_lowercase() == "stop" || s.as_str().trim().to_lowercase() == "quit" { + return Ok(()); } req.messages.push(Message::text(Role::User, &s)); let mut response = client.chat(&req).await?; -- cgit 1.4.1-2-gfad0