feat: system prompt and persona
This commit is contained in:
@@ -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", ¤t_history)
|
||||
// Emit history excluding system prompt (index 0)
|
||||
app.emit("chat:update", ¤t_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", ¤t_history)
|
||||
// Emit history excluding system prompt (index 0)
|
||||
app.emit("chat:update", ¤t_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", ¤t_history)
|
||||
// Emit history excluding system prompt (index 0)
|
||||
app.emit("chat:update", ¤t_history[1..])
|
||||
.map_err(|e| e.to_string())?;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user