use serde::{Serialize, Deserialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Hash)]
pub enum ProviderType {
Anthropic,
OpenAI,
Mistral,
Google,
Ollama
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct LlmRequest {
pub messages: Vec<Message>,
pub model: Option<String>,
pub max_tokens: Option<u32>,
pub temperature: Option<f32>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Message {
pub role: String,
pub content: String,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct LlmResponse {
pub content: String,
pub model: String,
pub usage: Option<TokenUsage>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct TokenUsage {
pub prompt_tokens: u32,
pub completion_tokens: u32,
pub total_tokens: u32,
}
impl Default for TokenUsage {
fn default() -> Self {
Self {
prompt_tokens: 0,
completion_tokens: 0,
total_tokens: 0
}
}
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ModelInfo {
pub name: String,
pub provider: ProviderType,
}
impl std::fmt::Display for ProviderType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ProviderType::Anthropic => write!(f, "Anthropic"),
ProviderType::OpenAI => write!(f, "OpenAI"),
ProviderType::Mistral => write!(f, "Mistral"),
ProviderType::Google => write!(f, "Google"),
ProviderType::Ollama => write!(f, "Ollama"),
}
}
}
impl From<&str> for ProviderType {
fn from(value: &str) -> Self {
match value {
"Anthropic" => ProviderType::Anthropic,
"OpenAI" => ProviderType::OpenAI,
"Mistral" => ProviderType::Mistral,
"Google" => ProviderType::Google,
"Ollama" => ProviderType::Ollama,
_ => panic!("Unknown provider: {}", value),
}
}
}