feat: system prompt and persona

This commit is contained in:
Dave
2025-12-25 13:10:03 +00:00
parent 9aa52a4b6c
commit f1d4efb266
8 changed files with 109 additions and 20 deletions

View File

@@ -1,5 +1,6 @@
use crate::commands::{fs, search, shell};
use crate::llm::ollama::OllamaProvider;
use crate::llm::prompts::SYSTEM_PROMPT;
use crate::llm::types::{
Message, ModelProvider, Role, ToolCall, ToolDefinition, ToolFunctionDefinition,
};
@@ -51,6 +52,18 @@ pub async fn chat(
// 3. Agent Loop
let mut current_history = messages.clone();
// Inject System Prompt
current_history.insert(
0,
Message {
role: Role::System,
content: SYSTEM_PROMPT.to_string(),
tool_calls: None,
tool_call_id: None,
},
);
let mut new_messages: Vec<Message> = Vec::new();
let mut turn_count = 0;
@@ -78,7 +91,8 @@ pub async fn chat(
current_history.push(assistant_msg.clone());
new_messages.push(assistant_msg);
app.emit("chat:update", &current_history)
// Emit history excluding system prompt (index 0)
app.emit("chat:update", &current_history[1..])
.map_err(|e| e.to_string())?;
// Execute Tools
@@ -96,7 +110,8 @@ pub async fn chat(
current_history.push(tool_msg.clone());
new_messages.push(tool_msg);
app.emit("chat:update", &current_history)
// Emit history excluding system prompt (index 0)
app.emit("chat:update", &current_history[1..])
.map_err(|e| e.to_string())?;
}
} else {
@@ -111,7 +126,8 @@ pub async fn chat(
// We don't push to current_history needed for next loop, because we are done.
new_messages.push(assistant_msg.clone());
current_history.push(assistant_msg);
app.emit("chat:update", &current_history)
// Emit history excluding system prompt (index 0)
app.emit("chat:update", &current_history[1..])
.map_err(|e| e.to_string())?;
break;
}