use serde::{Deserialize, Serialize};
use crate::seed::AmbiguityScore;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InterviewResult {
#[serde(default)]
pub original_message: String,
pub questions: Vec<String>,
pub answers: Vec<String>,
pub ambiguity: AmbiguityScore,
pub ready_for_seed: bool,
#[serde(default = "default_is_task")]
pub is_task: bool,
#[serde(default)]
pub chat_response: String,
#[serde(default)]
pub conversation_history: Vec<Exchange>,
#[serde(default = "default_complexity")]
pub complexity: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Exchange {
pub user: String,
pub agent: String,
}
fn default_is_task() -> bool {
true
}
fn default_complexity() -> String {
"complex".to_string()
}
impl InterviewResult {
pub fn new() -> Self {
Self {
original_message: String::new(),
questions: Vec::new(),
answers: Vec::new(),
ambiguity: AmbiguityScore::default(),
ready_for_seed: false,
is_task: true,
chat_response: String::new(),
conversation_history: Vec::new(),
complexity: default_complexity(),
}
}
pub fn add_exchange(&mut self, question: impl Into<String>, answer: impl Into<String>) {
self.questions.push(question.into());
self.answers.push(answer.into());
}
pub fn update_ambiguity(&mut self, score: AmbiguityScore) {
self.ready_for_seed = score.is_ready();
self.ambiguity = score;
}
pub fn add_to_history(&mut self, user: impl Into<String>, agent: impl Into<String>) {
self.conversation_history.push(Exchange {
user: user.into(),
agent: agent.into(),
});
}
}
impl Default for InterviewResult {
fn default() -> Self {
Self::new()
}
}