use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Conversation {
pub id: String,
pub object: String,
pub created_at: i64,
#[serde(default)]
pub metadata: Option<HashMap<String, String>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ConversationListResponse {
pub object: String,
pub data: Vec<Conversation>,
#[serde(default)]
pub first_id: Option<String>,
#[serde(default)]
pub last_id: Option<String>,
#[serde(default)]
pub has_more: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ConversationItem {
pub id: String,
#[serde(default)]
pub object: Option<String>,
#[serde(rename = "type")]
pub item_type: String,
#[serde(default)]
pub role: Option<String>,
#[serde(default)]
pub content: Option<serde_json::Value>,
#[serde(default)]
pub status: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ConversationItemListResponse {
pub object: String,
pub data: Vec<ConversationItem>,
#[serde(default)]
pub first_id: Option<String>,
#[serde(default)]
pub last_id: Option<String>,
#[serde(default)]
pub has_more: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DeleteConversationResponse {
pub id: String,
pub object: String,
pub deleted: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InputItem {
#[serde(rename = "type")]
pub item_type: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub role: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub content: Option<serde_json::Value>,
}
impl InputItem {
pub fn message(role: &str, content: &str) -> Self {
Self { item_type: "message".to_string(), role: Some(role.to_string()), content: Some(serde_json::Value::String(content.to_string())) }
}
pub fn user_message(content: &str) -> Self {
Self::message("user", content)
}
pub fn assistant_message(content: &str) -> Self {
Self::message("assistant", content)
}
}