feat: 新增硅基流动国内站与国际站渠道

- 新增 siliconflow 与 siliconflow-global 两个 OpenAI 兼容渠道预设,分别使用国内站与国际站地址、独立账号与默认模型
- 国内站默认免费文字模型 THUDM/GLM-Z1-9B-0414,说明实名认证、固定限速与图片识别限制;国际站默认支持图片的 Qwen/Qwen2.5-VL-7B-Instruct,说明新用户 $1 赠金与按量付费
- 设置页按渠道展示免费额度说明、Base URL 提示与对应站点的文档链接,补充渠道预设和文档测试
This commit is contained in:
margrop
2026-11-19 12:44:39 +08:00
parent 3967065ea0
commit f0b96ae414
6 changed files with 69 additions and 9 deletions

View File

@@ -8,10 +8,10 @@ import { VENDOR_PROVIDER_IDS } from '@/lib/ai/vendor-presets';
const isHttps = (url: string | undefined) => !url || url.startsWith('https://');
describe('官方接入文档', () => {
it('国产大模型渠道都有国内站文档,链接为 https', () => {
it('国产大模型渠道都有国内站或国际站文档,链接为 https', () => {
for (const id of VENDOR_PROVIDER_IDS) {
const docs = getProviderDocs(id);
expect(docs?.cn, id).toMatch(/^https:\/\//);
expect(docs?.cn ?? docs?.intl, id).toMatch(/^https:\/\//);
expect(isHttps(docs?.intl), id).toBe(true);
}
});
@@ -23,6 +23,12 @@ describe('官方接入文档', () => {
});
expect(getProviderDocs('kimi')?.intl).toContain('moonshot.ai');
expect(getProviderDocs('deepseek')?.intl).toBeUndefined();
expect(getProviderDocs('siliconflow')).toMatchObject({
cn: 'https://docs.siliconflow.cn/cn/userguide/quickstart',
intl: 'https://docs.siliconflow.com/en/userguide/quickstart',
});
expect(getProviderDocs('siliconflow-global')?.cn).toBeUndefined();
expect(getProviderDocs('siliconflow-global')?.intl).toContain('siliconflow.com');
});
it('海外提供商只有一个入口;MiniMax Code OAuth 没有', () => {

View File

@@ -51,6 +51,8 @@ const EXPECTED: Record<VendorProviderId, { baseUrl: string; model: string }> = {
'volcengine-agent': { baseUrl: 'https://ark.cn-beijing.volces.com/api/plan/v3', model: 'doubao-seed-evolving' },
'volcengine-coding': { baseUrl: 'https://ark.cn-beijing.volces.com/api/coding/v3', model: 'doubao-seed-evolving' },
'volcengine-free': { baseUrl: 'https://ark.cn-beijing.volces.com/api/v3', model: 'doubao-seed-evolving' },
siliconflow: { baseUrl: 'https://api.siliconflow.cn/v1', model: 'THUDM/GLM-Z1-9B-0414' },
'siliconflow-global': { baseUrl: 'https://api.siliconflow.com/v1', model: 'Qwen/Qwen2.5-VL-7B-Instruct' },
ollama: { baseUrl: 'http://localhost:11434/v1', model: 'qwen3-vl:8b' },
};
@@ -72,6 +74,8 @@ describe('国产大模型渠道预设', () => {
}
expect(getVendorName('volcengine-free', 'en')).toBe('Volcengine (free trial)');
expect(getVendorName('glm', 'zh')).toBe('智谱 GLM');
expect(getVendorName('siliconflow', 'zh')).toBe('硅基流动 SiliconFlow');
expect(getVendorName('siliconflow-global', 'en')).toBe('SiliconFlow (international)');
});
it('只识别已知渠道', () => {

View File

@@ -27,14 +27,23 @@ export function VendorSettings({ provider, value, onChange }: VendorSettingsProp
volcengine: t.settings?.ai?.volcengineBaseUrlHint,
"volcengine-agent": t.settings?.ai?.volcengineAgentBaseUrlHint,
"volcengine-coding": t.settings?.ai?.volcengineCodingBaseUrlHint,
siliconflow: t.settings?.ai?.siliconflowBaseUrlHint,
"siliconflow-global": t.settings?.ai?.siliconflowGlobalBaseUrlHint,
};
// 免费额度说明:火山引擎新用户免费试用、硅基流动免费模型与体验赠金
const freeNotices: Partial<Record<VendorProviderId, { title: string; body: string }>> = {
"volcengine-free": t.settings?.ai?.volcengineFree,
siliconflow: t.settings?.ai?.siliconflowFree,
"siliconflow-global": t.settings?.ai?.siliconflowGlobalFree,
};
const notice = freeNotices[provider];
return (
<div className="space-y-3 animate-in fade-in slide-in-from-top-2">
{provider === "volcengine-free" && (
{notice && (
<div className="rounded-md border border-green-200 bg-green-50 p-3 text-xs text-green-800 dark:border-green-900 dark:bg-green-950/40 dark:text-green-300">
<p className="font-medium">{t.settings.ai.volcengineFree.title}</p>
<p className="mt-1">{t.settings.ai.volcengineFree.body}</p>
<p className="font-medium">{notice.title}</p>
<p className="mt-1">{notice.body}</p>
</div>
)}
<div className="space-y-2">

View File

@@ -1,19 +1,19 @@
/**
* 内置 OpenAI 兼容渠道预设:国产大模型官方渠道 + 本地 Ollama,均复用 OpenAIProvider。
* 内置 OpenAI 兼容渠道预设:国产大模型官方渠道、硅基流动 + 本地 Ollama,均复用 OpenAIProvider。
* 本文件不依赖 Node 模块,前端设置界面也会引用。
*/
export interface VendorPreset {
name: string; // 中文界面的显示名称
nameEn: string; // 英文界面的显示名称
baseUrl: string; // 官方 OpenAI 兼容地址(中国大陆)
baseUrl: string; // 官方 OpenAI 兼容地址(国内站或国际站)
model: string; // 默认模型(当前最新、支持图片输入)
envPrefix: string; // 环境变量前缀:<PREFIX>_API_KEY / _BASE_URL / _MODEL
consoleUrl: string; // 获取 API Key 的控制台
/** 本地服务不校验 Key 时使用的占位 API Key(如 Ollama 要求非空但忽略内容) */
defaultApiKey?: string;
/** 官方接入文档:国内站与国际站(只有一个入口时只填 cn),以及获取 API Key 的说明和模型列表 */
docs: { cn: string; intl?: string; apiKey: string; models: string };
/** 官方接入文档:国内站与国际站(只有一个入口时只填 cn 或 intl),以及获取 API Key 的说明和模型列表 */
docs: { cn?: string; intl?: string; apiKey: string; models: string };
}
export const VENDOR_PRESETS = {
@@ -113,6 +113,27 @@ export const VENDOR_PRESETS = {
consoleUrl: 'https://console.volcengine.com/ark',
docs: { cn: 'https://www.volcengine.com/docs/82379/1399514', apiKey: 'https://www.volcengine.com/docs/82379/1541594', models: 'https://www.volcengine.com/docs/82379/1330310' },
},
// 硅基流动中国站:OpenAI 兼容接口;默认使用免费的 GLM-Z1-9B-0414。
// 免费对话模型只有文本输入,图片识别需另选付费视觉模型或把识别渠道设为其他渠道
siliconflow: {
name: '硅基流动 SiliconFlow',
nameEn: 'SiliconFlow',
baseUrl: 'https://api.siliconflow.cn/v1',
model: 'THUDM/GLM-Z1-9B-0414',
envPrefix: 'SILICONFLOW',
consoleUrl: 'https://cloud.siliconflow.cn',
docs: { cn: 'https://docs.siliconflow.cn/cn/userguide/quickstart', intl: 'https://docs.siliconflow.com/en/userguide/quickstart', apiKey: 'https://docs.siliconflow.cn/cn/userguide/quickstart', models: 'https://www.siliconflow.cn/pricing' },
},
// 硅基流动国际站:独立账号与地址,新用户有 $1 体验赠金;默认用便宜的视觉模型 Qwen2.5-VL-7B
'siliconflow-global': {
name: '硅基流动(国际站)',
nameEn: 'SiliconFlow (international)',
baseUrl: 'https://api.siliconflow.com/v1',
model: 'Qwen/Qwen2.5-VL-7B-Instruct',
envPrefix: 'SILICONFLOW_GLOBAL',
consoleUrl: 'https://cloud.siliconflow.com',
docs: { intl: 'https://docs.siliconflow.com/en/userguide/quickstart', apiKey: 'https://docs.siliconflow.com/en/userguide/quickstart', models: 'https://www.siliconflow.com/pricing' },
},
// 本地 Ollama:OpenAI 兼容接口;API Key 必须非空但本地服务不校验,模型需支持图片输入
ollama: {
name: 'Ollama(本地)',

View File

@@ -937,6 +937,16 @@ export const en = {
body: "New Volcengine accounts get a free inference quota for each model (500,000 tokens per model, per Volcengine's docs). Turn on worry-free trial mode under Activation Management in the Ark console: calls only use the free quota and pause when it is nearly used up, so you are never charged. To keep going afterwards, verify your identity and switch to the regular Volcengine channel.",
},
qwenBaseUrlHint: "The default is the Alibaba Cloud Model Studio Token Plan endpoint (recommended; keys start with sk-sp-). For a pay-as-you-go key, enter https://dashscope.aliyuncs.com/compatible-mode/v1.",
siliconflowBaseUrlHint: "The default is the free THUDM/GLM-Z1-9B-0414 (text input only). Free chat models do not accept images; for question recognition use a paid vision model under the same key (check the model list) or route image recognition to another channel under Channel routing. For the international site, enter https://api.siliconflow.com/v1.",
siliconflowFree: {
title: "Free models",
body: "The SiliconFlow China site makes some chat models free (currently THUDM/GLM-Z1-9B-0414, THUDM/GLM-4-9B-0414 and Qwen/Qwen3-8B among others), available after identity verification with a fixed rate limit. Free chat models take text only: image recognition needs a paid vision model or another channel. Check the official pricing page for the current free list.",
},
siliconflowGlobalBaseUrlHint: "The international endpoint is fixed at https://api.siliconflow.com/v1 (not the China site's api.siliconflow.cn). The default Qwen/Qwen2.5-VL-7B-Instruct accepts images at about $0.05 per million input tokens, payable from the new-user credit. API keys, accounts and credits do not carry over between the two sites.",
siliconflowGlobalFree: {
title: "New-user credit",
body: "New users on the SiliconFlow international site get a $1 trial credit, deducted at live prices; the international site has no permanently free chat models. The default Qwen/Qwen2.5-VL-7B-Instruct is inexpensive and accepts images, so $1 covers roughly 20 million input tokens (output billed separately). Top up when the credit runs out; for permanently free text models, use the SiliconFlow China channel instead.",
},
minimaxCode: {
title: "MiniMax Code account",
intro: "Sign in to your MiniMax Code account in the browser. The app uses this login to call MiniMax Code models, so no API key is needed.",

View File

@@ -937,6 +937,16 @@ export const zh = {
body: "注册火山引擎即可获得每个模型的免费推理额度(官方文档为每个模型 50 万 tokens)。在火山方舟控制台的「开通管理」中开启「安心体验模式」后,调用只消耗免费额度,额度接近用完时自动暂停,不会产生费用。额度用完后如需继续使用,完成实名认证并改用「火山引擎 豆包」渠道。",
},
qwenBaseUrlHint: "默认为阿里云百炼 Token Plan 专属地址(推荐,Key 以 sk-sp- 开头);使用按量付费的 Key 时填写 https://dashscope.aliyuncs.com/compatible-mode/v1。",
siliconflowBaseUrlHint: "默认使用免费的 THUDM/GLM-Z1-9B-0414(仅文本输入)。免费对话模型不支持图片;识别题目时请改用同一 Key 下的付费视觉模型(以模型列表为准),或在「渠道分工」中把图片识别渠道设为其他渠道。使用国际站时填写 https://api.siliconflow.com/v1。",
siliconflowFree: {
title: "免费模型",
body: "硅基流动中国站对部分对话模型免费(当前包括 THUDM/GLM-Z1-9B-0414、THUDM/GLM-4-9B-0414、Qwen/Qwen3-8B 等),完成实名认证后可调用,免费额度有固定限速。免费对话模型只有文本输入:图片识别需改用付费视觉模型或其他渠道。价格与免费名单以官方价格页为准。",
},
siliconflowGlobalBaseUrlHint: "国际站地址固定为 https://api.siliconflow.com/v1(不要填中国站的 api.siliconflow.cn)。默认模型 Qwen/Qwen2.5-VL-7B-Instruct 支持图片输入,单价约 $0.05/百万输入 tokens,可用新用户赠金支付。国际站与中国站的 API Key、账号和赠金互不通用。",
siliconflowGlobalFree: {
title: "新用户赠金",
body: "硅基流动国际站新用户注册可得 $1 体验赠金,按实时价格扣减;国际站没有长期免费的对话模型。默认的 Qwen/Qwen2.5-VL-7B-Instruct 单价很低且支持图片识别,$1 约可覆盖 2000 万输入 tokens(不含输出)。赠金用完后充值即可继续使用;如需长期免费的文字模型,请改用「硅基流动 SiliconFlow」中国站渠道。",
},
minimaxCode: {
title: "MiniMax Code 账号",
intro: "用 MiniMax Code 账号在网页登录授权,应用会用这个登录调用 MiniMax Code 的模型,不需要 API Key。",