use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_json::{Map, Value};
use skald_spec::wire::jev::{JevRequest, JevResponse};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct GatewayAnthropicMessagesRequest {
pub model: String,
pub max_tokens: u64,
pub messages: Vec<GatewayAnthropicMessageParam>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub stream: Option<bool>,
#[serde(flatten)]
pub extra: Map<String, Value>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct GatewayAnthropicMessageParam {
pub role: String,
pub content: Value,
#[serde(flatten)]
pub extra: Map<String, Value>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct GatewayAnthropicMessage {
pub id: String,
#[serde(rename = "type")]
pub kind: String,
pub role: String,
pub model: String,
pub content: Vec<Value>,
pub stop_reason: Option<String>,
pub stop_sequence: Option<String>,
pub usage: GatewayAnthropicUsage,
#[serde(flatten)]
pub extra: Map<String, Value>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct GatewayAnthropicUsage {
pub input_tokens: u64,
pub output_tokens: u64,
#[serde(flatten)]
pub extra: Map<String, Value>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct GatewayGeminiGenerateContentRequest {
pub contents: Vec<GatewayGeminiContent>,
#[serde(flatten)]
pub extra: Map<String, Value>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct GatewayGeminiContent {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub role: Option<String>,
#[serde(default)]
pub parts: Vec<Value>,
#[serde(flatten)]
pub extra: Map<String, Value>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct GatewayGeminiGenerateContentResponse {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub candidates: Vec<GatewayGeminiCandidate>,
#[serde(
rename = "usageMetadata",
default,
skip_serializing_if = "Option::is_none"
)]
pub usage_metadata: Option<Map<String, Value>>,
#[serde(flatten)]
pub extra: Map<String, Value>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct GatewayGeminiCandidate {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub content: Option<GatewayGeminiContent>,
#[serde(
rename = "finishReason",
default,
skip_serializing_if = "Option::is_none"
)]
pub finish_reason: Option<String>,
#[serde(flatten)]
pub extra: Map<String, Value>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(transparent)]
pub struct GatewayJevRequest(
pub JevRequest,
);
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(transparent)]
pub struct GatewayJevResponse(
pub JevResponse,
);
#[cfg(feature = "server")]
super::openai::openapi_schema!(
GatewayAnthropicMessagesRequest,
GatewayAnthropicMessage,
GatewayGeminiGenerateContentRequest,
GatewayGeminiGenerateContentResponse,
GatewayJevRequest,
GatewayJevResponse,
);
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[cfg_attr(feature = "server", derive(utoipa::ToSchema))]
pub struct AnthropicErrorEnvelope {
#[serde(rename = "type")]
pub kind: String,
pub error: AnthropicError,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[cfg_attr(feature = "server", derive(utoipa::ToSchema))]
pub struct AnthropicError {
#[serde(rename = "type")]
pub kind: String,
pub message: String,
pub code: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[cfg_attr(feature = "server", derive(utoipa::ToSchema))]
pub struct GoogleErrorEnvelope {
pub error: GoogleError,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[cfg_attr(feature = "server", derive(utoipa::ToSchema))]
pub struct GoogleError {
pub code: u16,
pub message: String,
pub status: String,
pub details: Vec<GoogleErrorInfo>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[cfg_attr(feature = "server", derive(utoipa::ToSchema))]
pub struct GoogleErrorInfo {
#[serde(rename = "@type")]
pub kind: String,
pub reason: String,
pub domain: String,
}