refactor(config): 移除环境变量依赖,统一使用 Provider 配置系统
- 移除 .env.example 文件 - 简化 resolveApiKey 函数,只从配置文件读取 API Key - 重构 loadConfig/loadVisionConfig/loadSummaryConfig 使用 ProviderRegistry - 更新测试以 mock Provider 系统
This commit is contained in:
@@ -73,22 +73,9 @@ export async function saveProvidersConfig(
|
||||
|
||||
/**
|
||||
* 获取提供商的 API Key
|
||||
* 优先从环境变量获取,其次从配置获取
|
||||
* 从配置文件获取
|
||||
*/
|
||||
export function resolveApiKey(config?: ProviderConfig, envVar?: string): string | undefined {
|
||||
// 优先使用配置中指定的环境变量
|
||||
if (config?.apiKeyEnvVar) {
|
||||
const key = process.env[config.apiKeyEnvVar];
|
||||
if (key) return key;
|
||||
}
|
||||
|
||||
// 其次使用默认环境变量
|
||||
if (envVar) {
|
||||
const key = process.env[envVar];
|
||||
if (key) return key;
|
||||
}
|
||||
|
||||
// 最后使用直接配置的 apiKey
|
||||
export function resolveApiKey(config?: ProviderConfig): string | undefined {
|
||||
return config?.apiKey;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user