API, CORS, Streaming

This commit is contained in:
Alex Emmet 2026-05-09 04:49:00 +02:00
commit e79e2734f4

View file

@ -19,3 +19,41 @@ pub struct AiConversation {
pub temperature: f32, pub temperature: f32,
pub stream: bool, pub stream: bool,
} }
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StreamEvent {
#[serde(rename = "type")]
pub event_type: String,
pub content: Option<String>,
pub error: Option<String>,
pub message_id: Option<String>,
}
impl StreamEvent {
pub fn content(content: String) -> Self {
Self {
event_type: "content".to_string(),
content: Some(content),
error: None,
message_id: None,
}
}
pub fn error(error: String) -> Self {
Self {
event_type: "error".to_string(),
content: None,
error: Some(error),
message_id: None,
}
}
pub fn done(message_id: String) -> Self {
Self {
event_type: "done".to_string(),
content: None,
error: None,
message_id: Some(message_id),
}
}
}