feat(agent): inject project context and sender info into AI chat messages
This commit is contained in:
parent
b740e2884d
commit
66006d842e
@ -559,6 +559,38 @@ impl ChatService {
|
|||||||
messages.push(mem.to_system_message());
|
messages.push(mem.to_system_message());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inject project context so the AI knows which project it is operating in.
|
||||||
|
let project_info = format!(
|
||||||
|
"Current Project:\n{}\nDescription: {}\nPublic: {}",
|
||||||
|
request.project.display_name,
|
||||||
|
request.project.description.as_deref().unwrap_or("(none)"),
|
||||||
|
if request.project.is_public { "yes" } else { "no" }
|
||||||
|
);
|
||||||
|
messages.push(ChatCompletionRequestMessage::System(
|
||||||
|
ChatCompletionRequestSystemMessage {
|
||||||
|
content: async_openai::types::chat::ChatCompletionRequestSystemMessageContent::Text(project_info),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
));
|
||||||
|
|
||||||
|
// Inject sender info so the AI knows who is asking.
|
||||||
|
let mut sender_parts = vec![format!("**Sender:** {}", request.sender.username)];
|
||||||
|
if let Some(ref display_name) = request.sender.display_name {
|
||||||
|
sender_parts.push(display_name.clone());
|
||||||
|
}
|
||||||
|
if let Some(ref org) = request.sender.organization {
|
||||||
|
sender_parts.push(format!("({})", org));
|
||||||
|
}
|
||||||
|
let sender_display = sender_parts.join(" ");
|
||||||
|
messages.push(ChatCompletionRequestMessage::System(
|
||||||
|
ChatCompletionRequestSystemMessage {
|
||||||
|
content: async_openai::types::chat::ChatCompletionRequestSystemMessageContent::Text(
|
||||||
|
format!("The person sending the next message:\n{}", sender_display),
|
||||||
|
),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
));
|
||||||
|
|
||||||
messages.push(ChatCompletionRequestMessage::User(
|
messages.push(ChatCompletionRequestMessage::User(
|
||||||
ChatCompletionRequestUserMessage {
|
ChatCompletionRequestUserMessage {
|
||||||
content: async_openai::types::chat::ChatCompletionRequestUserMessageContent::Text(
|
content: async_openai::types::chat::ChatCompletionRequestUserMessageContent::Text(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user