forked from ZhuLinsen/daily_stock_analysis
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathllmProviderTemplates.ts
More file actions
257 lines (250 loc) · 9.39 KB
/
Copy pathllmProviderTemplates.ts
File metadata and controls
257 lines (250 loc) · 9.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
export type ChannelProtocol =
| 'openai'
| 'deepseek'
| 'gemini'
| 'anthropic'
| 'vertex_ai'
| 'ollama'
| 'github_copilot';
export type LLMProviderCapability =
| 'openai-compatible'
| 'aggregator'
| 'official-api'
| 'model-discovery'
| 'vision'
| 'local-runtime';
export interface LLMProviderTemplate {
channelId: string;
label: string;
protocol: ChannelProtocol;
baseUrl: string;
placeholderModels: string;
capabilities: LLMProviderCapability[];
configHint?: string;
officialSources: Array<{
label: string;
url: string;
}>;
}
export const LLM_PROVIDER_CAPABILITY_LABELS: Record<LLMProviderCapability, { label: string; hint: string }> = {
'openai-compatible': {
label: 'OpenAI 兼容',
hint: '按 OpenAI-compatible endpoint 配置 Base URL,不额外拼接 /chat/completions。',
},
aggregator: {
label: '聚合平台',
hint: '模型可见性、路由和价格可能随账号权限与平台策略变化。',
},
'official-api': {
label: '官方 API',
hint: '使用服务商官方协议或官方兼容入口。',
},
'model-discovery': {
label: '可获取模型',
hint: '支持尝试通过 /models 获取模型列表;实际结果仍取决于账号权限和 API Key。',
},
vision: {
label: 'Vision 提示',
hint: '模板提示该 provider 常用于 Vision 场景;具体模型能力仍以账号和模型列表为准。',
},
'local-runtime': {
label: '本地运行',
hint: '需要当前运行环境能访问对应本地服务。',
},
};
export const LLM_PROVIDER_TEMPLATES: LLMProviderTemplate[] = [
{
channelId: 'aihubmix',
label: 'AIHubmix(聚合平台)',
protocol: 'openai',
baseUrl: 'https://aihubmix.com/v1',
placeholderModels: 'gpt-5.5,claude-sonnet-4-6,gemini-3.1-pro-preview',
capabilities: ['openai-compatible', 'aggregator'],
officialSources: [{ label: 'AIHubmix', url: 'https://aihubmix.com/' }],
},
{
channelId: 'anspire',
label: 'Anspire Open(一站式模型+搜索)',
protocol: 'openai',
baseUrl: 'https://open-gateway.anspire.cn/v6',
placeholderModels: 'Doubao-Seed-2.0-lite,Doubao-Seed-2.0-pro,qwen3.5-flash,MiniMax-M2.7',
capabilities: ['openai-compatible'],
configHint:
'同一 ANSPIRE_API_KEYS 可复用到搜索与 LLM 渠道。以下模型与网关为配置示例,实际可用性请以账号权限和控制台为准;建议先点“测试连接”确认。',
officialSources: [
{ label: 'Anspire Open', url: 'https://open.anspire.cn/?share_code=QFBC0FYC' },
{
label: 'LiteLLM OpenAI-compatible',
url: 'https://docs.litellm.ai/docs/providers/openai_compatible',
},
],
},
{
channelId: 'deepseek',
label: 'DeepSeek 官方',
protocol: 'deepseek',
baseUrl: 'https://api.deepseek.com',
placeholderModels: 'deepseek-v4-flash,deepseek-v4-pro',
capabilities: ['official-api', 'openai-compatible'],
officialSources: [{ label: 'DeepSeek API Docs', url: 'https://api-docs.deepseek.com/' }],
},
{
channelId: 'dashscope',
label: '通义千问(Dashscope)',
protocol: 'openai',
baseUrl: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
placeholderModels: 'qwen3.6-plus,qwen3.6-flash',
capabilities: ['openai-compatible', 'model-discovery'],
officialSources: [
{ label: 'DashScope Text Generation', url: 'https://help.aliyun.com/zh/model-studio/text-generation-model/' },
],
},
{
channelId: 'zhipu',
label: '智谱 GLM',
protocol: 'openai',
baseUrl: 'https://open.bigmodel.cn/api/paas/v4',
placeholderModels: 'glm-5.1,glm-4.7-flash',
capabilities: ['openai-compatible'],
officialSources: [{ label: 'Zhipu Model Overview', url: 'https://docs.bigmodel.cn/cn/guide/start/model-overview' }],
},
{
channelId: 'moonshot',
label: 'Moonshot(月之暗面)',
protocol: 'openai',
baseUrl: 'https://api.moonshot.cn/v1',
placeholderModels: 'kimi-k2.6,kimi-k2.5',
capabilities: ['openai-compatible'],
officialSources: [{ label: 'Kimi Platform Docs', url: 'https://platform.kimi.com/docs/models' }],
},
{
channelId: 'minimax',
label: 'MiniMax 官方',
protocol: 'openai',
baseUrl: 'https://api.minimax.io/v1',
placeholderModels: 'MiniMax-M2.7,MiniMax-M2.7-highspeed',
capabilities: ['openai-compatible'],
officialSources: [
{ label: 'MiniMax OpenAI API', url: 'https://platform.minimax.io/docs/api-reference/text-chat' },
{ label: 'MiniMax Models', url: 'https://platform.minimax.io/docs/api-reference/models/openai/list-models' },
],
},
{
channelId: 'volcengine',
label: '火山方舟(豆包)',
protocol: 'openai',
baseUrl: 'https://ark.cn-beijing.volces.com/api/v3',
placeholderModels: 'doubao-seed-1-6-251015,doubao-seed-1-6-thinking-251015',
capabilities: ['openai-compatible'],
configHint: '确认在线推理 endpoint / region 与 Coding Plan 专用入口不要混用。',
officialSources: [
{ label: 'Volcengine Ark Inference', url: 'https://www.volcengine.com/docs/82379/2121998' },
{ label: 'Volcengine Ark Models', url: 'https://www.volcengine.com/docs/82379/1949118' },
],
},
{
channelId: 'siliconflow',
label: '硅基流动(SiliconFlow)',
protocol: 'openai',
baseUrl: 'https://api.siliconflow.cn/v1',
placeholderModels: 'deepseek-ai/DeepSeek-V3.2,Qwen/Qwen3-235B-A22B-Thinking-2507',
capabilities: ['openai-compatible', 'model-discovery'],
configHint: '模型列表和模型可见性依赖账号权限与 API Key。',
officialSources: [{ label: 'SiliconFlow Models', url: 'https://docs.siliconflow.cn/quickstart/models' }],
},
{
channelId: 'openrouter',
label: 'OpenRouter',
protocol: 'openai',
baseUrl: 'https://openrouter.ai/api/v1',
placeholderModels: '~anthropic/claude-sonnet-latest,~openai/gpt-latest',
capabilities: ['openai-compatible', 'aggregator', 'model-discovery'],
configHint: '模型列表和模型可见性依赖账号权限与 API Key。',
officialSources: [
{ label: 'OpenRouter Models API', url: 'https://openrouter.ai/docs/api/api-reference/models/get-models' },
],
},
{
channelId: 'gemini',
label: 'Gemini 官方',
protocol: 'gemini',
baseUrl: '',
placeholderModels: 'gemini-3.1-pro-preview,gemini-3-flash-preview',
capabilities: ['official-api', 'vision'],
officialSources: [{ label: 'Gemini Models', url: 'https://ai.google.dev/gemini-api/docs/models' }],
},
{
channelId: 'anthropic',
label: 'Anthropic 官方',
protocol: 'anthropic',
baseUrl: '',
placeholderModels: 'claude-sonnet-4-6,claude-opus-4-7',
capabilities: ['official-api'],
officialSources: [
{ label: 'Anthropic Models', url: 'https://docs.anthropic.com/en/docs/about-claude/models/all-models' },
],
},
{
channelId: 'openai',
label: 'OpenAI 官方',
protocol: 'openai',
baseUrl: 'https://api.openai.com/v1',
placeholderModels: 'gpt-5.5,gpt-5.4-mini',
capabilities: ['official-api', 'openai-compatible', 'model-discovery'],
officialSources: [{ label: 'OpenAI Models', url: 'https://platform.openai.com/docs/models' }],
},
{
channelId: 'ollama',
label: 'Ollama(本地)',
protocol: 'ollama',
baseUrl: 'http://127.0.0.1:11434',
placeholderModels: 'llama3.2,qwen2.5',
capabilities: ['local-runtime'],
configHint: '需要本机、Docker 或 self-hosted runner 能访问 Ollama 服务。',
officialSources: [{ label: 'Ollama API', url: 'https://github.com/ollama/ollama/blob/main/docs/api.md' }],
},
{
channelId: 'copilot',
label: 'GitHub Copilot(OAuth 设备流,无需 API Key)',
protocol: 'github_copilot',
baseUrl: '',
placeholderModels: 'gpt-4o,claude-sonnet-4,gemini-2.5-pro',
capabilities: ['official-api'],
configHint:
'需要付费 GitHub Copilot 订阅。首次调用时 LiteLLM 会在终端打印 device code 与 GitHub 验证链接,授权后凭据自动保存到 ~/.config/litellm/github_copilot/,之后无需再次登录。',
officialSources: [
{ label: 'GitHub Copilot Docs', url: 'https://docs.github.com/en/copilot' },
{ label: 'LiteLLM GitHub Copilot Provider', url: 'https://docs.litellm.ai/docs/providers/github_copilot' },
],
},
{
channelId: 'custom',
label: '自定义渠道',
protocol: 'openai',
baseUrl: '',
placeholderModels: 'model-name-1,model-name-2',
capabilities: [],
officialSources: [],
},
];
export const LLM_PROVIDER_TEMPLATE_BY_ID: Record<string, LLMProviderTemplate> = Object.fromEntries(
LLM_PROVIDER_TEMPLATES.map((template) => [template.channelId, template]),
);
export function getProviderTemplate(channelId: string): LLMProviderTemplate | undefined {
if (!Object.prototype.hasOwnProperty.call(LLM_PROVIDER_TEMPLATE_BY_ID, channelId)) {
return undefined;
}
return LLM_PROVIDER_TEMPLATE_BY_ID[channelId];
}
export function isKnownProviderTemplate(channelId: string): boolean {
return channelId !== 'custom' && Boolean(getProviderTemplate(channelId));
}
export const MODEL_PLACEHOLDERS_BY_PROTOCOL: Record<ChannelProtocol, string> = {
openai: 'gpt-5.5,qwen3.6-plus',
deepseek: 'deepseek-v4-flash,deepseek-v4-pro',
gemini: 'gemini-3.1-pro-preview,gemini-3-flash-preview',
anthropic: 'claude-sonnet-4-6,claude-opus-4-7',
vertex_ai: 'gemini-3.1-pro-preview',
ollama: 'llama3.2,qwen2.5',
github_copilot: 'gpt-4o,claude-sonnet-4',
};