use serde::{Deserialize, Serialize};
use crate::ModelIden;
use crate::chat::{ChatStream, MessageContent, ToolCall, Usage};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ChatResponse {
pub content: MessageContent,
pub reasoning_content: Option<String>,
pub model_iden: ModelIden,
pub provider_model_iden: ModelIden,
pub usage: Usage,
pub captured_raw_body: Option<serde_json::Value>,
}
impl ChatResponse {
pub fn first_text(&self) -> Option<&str> {
self.content.first_text()
}
pub fn into_first_text(self) -> Option<String> {
self.content.into_first_text()
}
pub fn texts(&self) -> Vec<&str> {
self.content.texts()
}
pub fn into_texts(self) -> Vec<String> {
self.content.into_texts()
}
pub fn tool_calls(&self) -> Vec<&ToolCall> {
self.content.tool_calls()
}
pub fn into_tool_calls(self) -> Vec<ToolCall> {
self.content.into_tool_calls()
}
}
impl ChatResponse {
#[deprecated(note = "Use '.first_text()' or '.texts()'")]
pub fn content_text_as_str(&self) -> Option<&str> {
self.first_text()
}
#[deprecated(note = "Use '.into_first_text()' or '.into_texts()")]
pub fn content_text_into_string(self) -> Option<String> {
self.into_first_text()
}
}
pub struct ChatStreamResponse {
pub stream: ChatStream,
pub model_iden: ModelIden,
}