use serde::Deserialize;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Provider {
Anthropic,
#[serde(alias = "openai")]
OpenAi,
Gemini,
}
impl Provider {
#[must_use]
pub fn default_model(&self) -> &'static str {
match self {
Self::Anthropic => "claude-sonnet-4-20250514",
Self::OpenAi => "gpt-4o",
Self::Gemini => "gemini-2.0-flash",
}
}
#[must_use]
pub fn default_base_url(&self) -> &'static str {
match self {
Self::Anthropic => "https://api.anthropic.com",
Self::OpenAi => "https://api.openai.com",
Self::Gemini => "https://generativelanguage.googleapis.com",
}
}
#[must_use]
pub fn api_key_env_var(&self) -> &'static str {
match self {
Self::Anthropic => "ANTHROPIC_API_KEY",
Self::OpenAi => "OPENAI_API_KEY",
Self::Gemini => "GEMINI_API_KEY",
}
}
}
pub async fn complete(
config: &super::AiConfig,
system: &str,
user: &str,
) -> anyhow::Result<String> {
let client = reqwest::Client::new();
match config.provider {
Provider::Anthropic => crate::anthropic::complete(&client, config, system, user).await,
Provider::OpenAi => crate::openai::complete(&client, config, system, user).await,
Provider::Gemini => crate::gemini::complete(&client, config, system, user).await,
}
}