API, CORS, Streaming
This commit is contained in:
parent
f63722f67c
commit
e79e2734f4
1 changed files with 38 additions and 0 deletions
|
|
@ -19,3 +19,41 @@ pub struct AiConversation {
|
|||
pub temperature: f32,
|
||||
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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue