use serde::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
#[non_exhaustive]
pub enum OutputFormat {
Json,
JsonSchema {
#[serde(default, skip_serializing_if = "Option::is_none")]
name: Option<String>,
schema: Value,
#[serde(default, skip_serializing_if = "Option::is_none")]
strict: Option<bool>,
},
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
#[non_exhaustive]
pub enum ReasoningEffort {
Low,
Medium,
High,
}
impl ReasoningEffort {
pub fn as_str(self) -> &'static str {
match self {
ReasoningEffort::Low => "low",
ReasoningEffort::Medium => "medium",
ReasoningEffort::High => "high",
}
}
pub fn budget(self) -> u32 {
match self {
ReasoningEffort::Low => 1024,
ReasoningEffort::Medium => 8192,
ReasoningEffort::High => 24576,
}
}
}
impl std::str::FromStr for ReasoningEffort {
type Err = ();
fn from_str(s: &str) -> Result<Self, ()> {
match s {
"low" => Ok(ReasoningEffort::Low),
"medium" => Ok(ReasoningEffort::Medium),
"high" => Ok(ReasoningEffort::High),
_ => Err(()),
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
#[non_exhaustive]
pub enum ServiceTier {
Priority,
Standard,
}
impl ServiceTier {
pub fn openai(self) -> &'static str {
match self {
ServiceTier::Priority => "priority",
ServiceTier::Standard => "default",
}
}
pub fn anthropic(self) -> &'static str {
match self {
ServiceTier::Priority => "auto",
ServiceTier::Standard => "standard_only",
}
}
}
impl std::str::FromStr for ServiceTier {
type Err = ();
fn from_str(s: &str) -> Result<Self, ()> {
match s {
"priority" => Ok(ServiceTier::Priority),
"standard" => Ok(ServiceTier::Standard),
_ => Err(()),
}
}
}