6.3 配置验证

验证函数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
interface ValidationResult {
valid: boolean;
error?: string;
warnings?: string[];
}

export function validateConfig(config: Config): ValidationResult {
if (!config.llm.apiKey) {
return { valid: false, error: 'API Key is required' };
}

const warnings: string[] = [];
if (!config.llm.baseUrl.includes('://')) {
warnings.push('baseUrl should include protocol');
}

return { valid: true, warnings };
}

Step 4 总结

  • ✅ JSON 配置文件
  • ✅ 环境变量支持
  • ✅ 配置验证

下一章: 第七章:会话持久化

导航

上一篇: 6.2 环境变量支持

下一篇: 7.1 会话存储方案