use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize, sqlx::Type)]
#[serde(rename_all = "lowercase")]
#[sqlx(type_name = "memory_type", rename_all = "lowercase")]
pub enum MemoryType {
    Semantic,
    Episodic,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ExtractedMemory {
    pub text: String,
    #[serde(rename = "type")]
    pub memory_type: MemoryType,
    #[serde(default = "default_importance")]
    pub importance: f32,
}

fn default_importance() -> f32 {
    0.5
}

#[derive(Debug, Clone, Default, Deserialize, Serialize)]
pub struct ExtractionResult {
    pub semantic: Vec<String>,
    pub episodic: Vec<ExtractedMemory>,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Message {
    pub role: String,
    pub content: String,
}

#[derive(Debug, Clone, Default, Serialize)]
pub struct ConversationContext {
    pub summary: Option<String>,
    pub recent_messages: Vec<String>,
}

#[derive(Debug, Clone, Serialize)]
pub struct ExtractionInput {
    pub latest_interaction: Vec<Message>,
    pub context: ConversationContext,
}
