#[cfg(any(feature = "openai", feature = "anthropic", feature = "deepseek"))]
use crate::config::llm::LlmProviderConfig;
#[cfg(feature = "openai")]
use crate::openai::adapter::OpenAIConfig;
#[cfg(feature = "anthropic")]
use crate::anthropic::adapter::AnthropicConfig;
#[cfg(feature = "deepseek")]
use crate::deepseek::adapter::DeepSeekConfig;
#[cfg(feature = "vision")]
use crate::config::vision::VisionConfig as ConfigVisionConfig;
#[cfg(feature = "vision")]
use crate::openai::vision::{
VisionConfig as AdapterVisionConfig, VisionProviderConfig as AdapterVisionProviderConfig,
VisionRetryConfig as AdapterVisionRetryConfig,
};
#[cfg(feature = "openai")]
impl From<&LlmProviderConfig> for OpenAIConfig {
fn from(cfg: &LlmProviderConfig) -> Self {
Self {
api_key: cfg.api_key.clone(),
base_url: cfg
.base_url
.clone()
.unwrap_or_else(|| "https://api.openai.com/v1".to_string()),
organization: None,
timeout_seconds: cfg.timeout_seconds.unwrap_or(300),
max_retries: cfg.max_retries.unwrap_or(3),
}
}
}
#[cfg(feature = "anthropic")]
impl From<&LlmProviderConfig> for AnthropicConfig {
fn from(cfg: &LlmProviderConfig) -> Self {
Self {
api_key: cfg.api_key.clone(),
base_url: cfg
.base_url
.clone()
.unwrap_or_else(|| "https://api.anthropic.com/v1".to_string()),
model: cfg
.default_model
.clone()
.unwrap_or_else(|| "claude-3-5-sonnet-20241022".to_string()),
max_tokens: 4096,
timeout_seconds: cfg.timeout_seconds.unwrap_or(300),
}
}
}
#[cfg(feature = "deepseek")]
impl From<&LlmProviderConfig> for DeepSeekConfig {
fn from(cfg: &LlmProviderConfig) -> Self {
Self {
api_key: cfg.api_key.clone(),
base_url: cfg
.base_url
.clone()
.unwrap_or_else(|| "https://api.deepseek.com/v1".to_string()),
model: cfg
.default_model
.clone()
.unwrap_or_else(|| "deepseek-chat".to_string()),
timeout_seconds: cfg.timeout_seconds.unwrap_or(60),
}
}
}
#[cfg(feature = "vision")]
impl From<&ConfigVisionConfig> for AdapterVisionConfig {
fn from(cfg: &ConfigVisionConfig) -> Self {
Self {
retry: AdapterVisionRetryConfig {
max_retries: cfg.retry.max_retries,
initial_backoff_ms: cfg.retry.initial_backoff_ms,
backoff_multiplier: cfg.retry.backoff_multiplier,
},
openai: AdapterVisionProviderConfig {
max_tokens: cfg.openai.max_tokens,
},
anthropic: AdapterVisionProviderConfig {
max_tokens: cfg.anthropic.max_tokens,
},
}
}
}