feat(ai): 扩展 AiConfig 支持多 Provider 配置

- config/default.toml 新增 providers 子段(claude/openai/ollama)
- erp-server/config.rs AiConfig 新增 quota_check_enabled + providers HashMap
- erp-ai/config.rs 新增 ProviderType 枚举 + ProviderConfig 结构体
This commit is contained in:
iven
2026-05-05 15:01:24 +08:00
parent 93f6e87220
commit 4d02b2b531
4 changed files with 138 additions and 0 deletions

View File

@@ -99,6 +99,26 @@ pub struct AiConfig {
pub temperature: f32,
pub cache_ttl_seconds: u64,
pub rate_limit_patient_daily: u32,
#[serde(default)]
pub quota_check_enabled: bool,
#[serde(default)]
pub providers: std::collections::HashMap<String, ProviderConfig>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct ProviderConfig {
pub provider_type: String,
pub api_key_env: Option<String>,
pub base_url: Option<String>,
pub default_model: String,
pub max_tokens: u32,
pub temperature: f32,
#[serde(default = "default_true")]
pub is_enabled: bool,
}
fn default_true() -> bool {
true
}
#[derive(Debug, Clone, Deserialize)]