use futures_core::Stream;
use crate::llm::{ChatGptClient, LlmError, Message};
const SYSTEM_PROMPT: &str = "\
You are a Path of Exile 2 build analysis assistant. The user has uploaded \
their Path of Building export and you have access to their parsed build stats.\n\
\n\
Answer the user's questions about their build. Be specific and reference \
actual numbers from the build data when relevant. If the data doesn't contain \
enough information to answer, say so.\n\
\n\
Here is the parsed build data:\n";
pub struct QueryAgent {
llm: ChatGptClient,
}
impl QueryAgent {
pub fn new(llm: ChatGptClient) -> Self {
Self { llm }
}
pub fn respond(
&self,
build_json: &[u8],
message: &str,
) -> impl Stream<Item = Result<String, LlmError>> + Send {
let system_content = format!(
"{SYSTEM_PROMPT}```json\n{}\n```",
String::from_utf8_lossy(build_json),
);
let messages = vec![
Message::system(system_content),
Message::user(message),
];
self.llm.chat_stream(messages)
}
}