use async_trait::async_trait;

use crate::types::Claim;

use super::error::{LlmError, Result};

pub struct LlmConfig {
    pub api_key: String,
    pub timeout_secs: u64,
}

impl Default for LlmConfig {
    fn default() -> Self {
        Self { api_key: String::new(), timeout_secs: 60 }
    }
}

#[async_trait]
pub trait LlmClient: Send + Sync {
    async fn extract_claims(&self, text: &str) -> Result<Vec<Claim>>;
    async fn test_connection(&self) -> Result<()>;
}

pub fn create_client(provider: &str, config: LlmConfig) -> Result<Box<dyn LlmClient>> {
    match provider {
        "anthropic" => Ok(Box::new(super::anthropic::AnthropicClient::new(config))),
        "groq" => Ok(Box::new(super::groq::GroqClient::new(config))),
        _ => Err(LlmError::UnsupportedProvider(provider.to_string())),
    }
}
