use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AnthropicStreamToken {
Text(String),
Thinking(String),
}
#[derive(Serialize, Clone, Debug)]
#[serde(untagged)]
pub enum AnthropicMessageContent {
Text(String),
Blocks(Vec<AnthropicContentBlock>),
}
#[derive(Serialize, Clone, Debug)]
#[serde(tag = "type")]
pub enum AnthropicContentBlock {
#[serde(rename = "text")]
Text { text: String },
#[serde(rename = "tool_use")]
ToolUse {
id: String,
name: String,
input: serde_json::Value,
},
#[serde(rename = "tool_result")]
ToolResult {
tool_use_id: String,
content: String,
},
}
#[derive(Serialize, Clone)]
pub(crate) struct AnthropicMessage {
pub(crate) role: String,
pub(crate) content: AnthropicMessageContent,
}
#[derive(Deserialize)]
#[allow(dead_code)]
pub(crate) struct AnthropicResponse {
pub(crate) id: String,
pub(crate) model: String,
pub(crate) content: Vec<AnthropicContent>,
pub(crate) usage: Option<AnthropicUsage>,
}
#[derive(Deserialize)]
#[allow(dead_code)]
pub(crate) struct AnthropicContent {
#[serde(rename = "type")]
pub(crate) content_type: String,
#[serde(default)]
pub(crate) text: String,
#[serde(default)]
pub(crate) thinking: String,
#[serde(default)]
pub(crate) id: Option<String>,
#[serde(default)]
pub(crate) name: Option<String>,
#[serde(default)]
pub(crate) input: Option<serde_json::Value>,
}
#[derive(Deserialize)]
pub(crate) struct AnthropicUsage {
pub(crate) input_tokens: usize,
pub(crate) output_tokens: usize,
}
#[derive(Deserialize)]
pub(crate) struct AnthropicStreamEvent {
#[serde(rename = "type")]
pub(crate) type_field: String,
pub(crate) delta: Option<AnthropicDelta>,
}
#[derive(Deserialize)]
pub(crate) struct AnthropicDelta {
#[serde(rename = "type")]
pub(crate) type_field: String,
#[serde(default)]
pub(crate) text: String,
#[serde(default)]
pub(crate) thinking: String,
}