feat: 支持 Anthropic Messages API 格式调用
通过 LLM_PROVIDER 环境变量区分 openai 和 anthropic 两种调用方式, LLMClient 根据 provider 分发到不同的 API 调用路径。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
e76a85db97
commit
2d301370e2
5 files changed
+236
-70
No files matched your search
+10
-2
@@ -58,10 +58,18 @@ class App {
|
||||
|
||||
// 配置 LLM 趋势总结服务(如果配置了 API Key)
|
||||
if (process.env.LLM_API_KEY) {
|
||||
const provider = (process.env.LLM_PROVIDER as 'openai' | 'anthropic') || 'openai';
|
||||
const defaultBase = provider === 'anthropic'
|
||||
? 'https://api.anthropic.com'
|
||||
: 'https://api.openai.com/v1';
|
||||
const defaultModel = provider === 'anthropic'
|
||||
? 'claude-sonnet-4-20250514'
|
||||
: 'gpt-4o-mini';
|
||||
const llmConfig = {
|
||||
apiBase: process.env.LLM_API_BASE || 'https://api.openai.com/v1',
|
||||
provider,
|
||||
apiBase: process.env.LLM_API_BASE || defaultBase,
|
||||
apiKey: process.env.LLM_API_KEY,
|
||||
model: process.env.LLM_MODEL || 'gpt-4o-mini',
|
||||
model: process.env.LLM_MODEL || defaultModel,
|
||||
timeout: 120000
|
||||
};
|
||||
const llmClient = new LLMClient(llmConfig);
|
||||
|
||||
Reference in new issue
Block a user