Просмотр исходного кода

fix(core): bailian bank 重写——仅保留 Anthropic 通道 live 验证支持的 24 个模型

问题:bailian 有两条独立通道,模型清单不对等:
- OpenAI 兼容 (/compatible-mode/v1): 全量 236+ 模型
- Anthropic 兼容 (/apps/anthropic): 精选 20+ 模型

inkos 用 /apps/anthropic(agent 工具调用更稳)。上轮 B 阶段我给 bailian bank
加 kimi-k2.6 / deepseek-v3.2 / qwen3-235b 等条目时是按 OpenAI 通道的 /models
结果加的——结果用户在 Studio 选 kimi-k2.6 走 bailian 就 400:
  `InvalidParameter: model 'kimi-k2.6' not found or not supported`

对 bailian.ts 里所有 chat 类 id 逐一 live 探测 /apps/anthropic/v1/messages,
保留 24 个实际可用:
- Qwen3.6: max-preview / plus / flash / 27b
- Qwen3.5: plus / flash / 397b-a17b / 122b-a10b / 35b-a3b / 27b
- Qwen 通用: qwen3-max / qwen3-max-preview / qwen-max / qwen-plus /
            qwen-flash / qwen-turbo
- 代理: kimi-k2.5 / kimi-k2-thinking / MiniMax-M2.5 / MiniMax-M2.1 /
       glm-5.1 / glm-5 / glm-4.7 / glm-4.6

删除 40+ 个 Anthropic 通道 400 的条目:kimi-k2.6 / 所有 deepseek-* /
qwen3-235b-a22b / qwen3-32b / qwen3-30b / qwen3-14b 等 qwen3 全系列 /
qwq-* / qvq-* / 所有 qwen2.5-* / 所有 qwen-*-2507 变体 / qwen-long /
Moonshot-Kimi-K2-Instruct / glm-4.5 / glm-4.5-air / deepseek-r1-distill-*。

同时移除 modelsBaseUrl 配置:之前指向 /compatible-mode/v1,让 live probe
拉到 OpenAI 通道的全量 id 回来污染 UI——选了就 400。现在 bailian 完全
bank-driven,不跑 live probe。文件顶部注释说明这个权衡。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
fanghanjun 6 месяцев назад
Родитель
Сommit
d12924ab71
1 измененных файлов с 32 добавлено и 98 удалено
  1. 32 98
      packages/core/src/llm/providers/endpoints/bailian.ts

+ 32 - 98
packages/core/src/llm/providers/endpoints/bailian.ts

@@ -1,14 +1,24 @@
 /**
- * 阿里云百炼(DashScope)
+ * 阿里云百炼(DashScope)— Anthropic 通道
  *
  * - 控制台:https://bailian.console.aliyun.com/
  * - API key:https://bailian.console.aliyun.com/?tab=model#/api-key
  * - 模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
  * - Anthropic 兼容接入:https://help.aliyun.com/zh/model-studio/developer-reference/use-anthropic-sdk
- * - OpenAI 兼容 /models:https://dashscope.aliyuncs.com/compatible-mode/v1/models
  *
- * inkos 选 anthropic-messages 接入是因为 agent 场景下工具调用在这条链路上更稳;
- * 模型列表 probe 走 compatible-mode/v1(apps/anthropic 没有 /models 端点)。
+ * inkos 用 /apps/anthropic 接入(agent 场景工具调用更稳)。
+ *
+ * **重要**:百炼有两条通道,模型清单**不完全对等**:
+ *   - OpenAI 兼容(/compatible-mode/v1):全量 236+ 模型(qwen3.6、kimi-k2.6、deepseek-v3.2 等)
+ *   - Anthropic 兼容(/apps/anthropic):精选 20+ 模型,主要是 qwen 主力 + 少数代理(kimi-k2.5、
+ *     kimi-k2-thinking、MiniMax-M2.5/2.1、glm-5/5.1/4.7/4.6)
+ *
+ * 下面的清单是 2026-04-23 对 /apps/anthropic 通道逐一 live 验证过的子集,
+ * 不能从 OpenAI 通道的 /models 清单直接抄——kimi-k2.6、deepseek-v3.2、
+ * qwen3-235b / qwen3-32b 等 OpenAI 通道支持的 id,Anthropic 通道会 400。
+ *
+ * 同理:不设 modelsBaseUrl 让 live /models probe 走 OpenAI 通道,那会拉到
+ * 大量 Anthropic 通道不支持的 id,用户选了就 400。这里宁可只用 bank 兜底。
  */
 import type { InkosEndpoint } from "../types.js";
 
@@ -17,114 +27,38 @@ export const BAILIAN: InkosEndpoint = {
   label: "百炼 (通义千问)",
   api: "anthropic-messages",
   baseUrl: "https://dashscope.aliyuncs.com/apps/anthropic",
-  modelsBaseUrl: "https://dashscope.aliyuncs.com/compatible-mode/v1",
   checkModel: "qwen-turbo",
   temperatureRange: [0, 2],
   defaultTemperature: 0.7,
   writingTemperature: 1,
   models: [
-    // --- Qwen3.6 系列(2026-04 发布) ---
+    // --- Qwen3.6 系列(2026-04 发布,Anthropic 通道已放开) ---
     { id: "qwen3.6-max-preview", maxOutput: 65536, contextWindowTokens: 262144, enabled: true, releasedAt: "2026-04-21" },
     { id: "qwen3.6-plus", maxOutput: 65536, contextWindowTokens: 1000000, enabled: true, releasedAt: "2026-04-09" },
     { id: "qwen3.6-flash", maxOutput: 65536, contextWindowTokens: 1000000, enabled: true, releasedAt: "2026-04-17" },
     { id: "qwen3.6-27b", maxOutput: 65536, contextWindowTokens: 262144, releasedAt: "2026-04-23" },
-    { id: "qwen3.6-35b-a3b", maxOutput: 65536, contextWindowTokens: 262144, releasedAt: "2026-04-17" },
-    // --- 第三方代理(百炼平台上的) ---
-    { id: "kimi-k2.6", maxOutput: 32768, contextWindowTokens: 262144, enabled: true, releasedAt: "2026-04-21", temperature: 1 },
-    { id: "kimi-k2.5", maxOutput: 32768, contextWindowTokens: 262144, temperature: 1 },
-    { id: "glm-5.1", maxOutput: 16384, contextWindowTokens: 202752, enabled: true, releasedAt: "2026-04-23" },
-    { id: "MiniMax-M2.5", maxOutput: 32768, contextWindowTokens: 196608 },
-    { id: "MiniMax-M2.1", maxOutput: 32768, contextWindowTokens: 204800 },
-    { id: "qwen3-vl-plus", maxOutput: 32768, contextWindowTokens: 262144, releasedAt: "2025-09-23" },
-    { id: "qwen3-vl-flash", maxOutput: 32768, contextWindowTokens: 262144 },
-    { id: "deepseek-v3.2", maxOutput: 65536, contextWindowTokens: 131072 },
-    { id: "deepseek-v3.2-exp", maxOutput: 65536, contextWindowTokens: 131072 },
-    { id: "deepseek-v3.1", maxOutput: 65536, contextWindowTokens: 131072 },
-    { id: "kimi-k2-thinking", maxOutput: 16384, contextWindowTokens: 262144, releasedAt: "2025-11-10", temperature: 1 },
-    { id: "Moonshot-Kimi-K2-Instruct", maxOutput: 8192, contextWindowTokens: 131072, releasedAt: "2025-07-17" },
-    { id: "glm-5", maxOutput: 16384, contextWindowTokens: 202752 },
-    { id: "glm-4.7", maxOutput: 16384, contextWindowTokens: 202752 },
-    { id: "glm-4.6", maxOutput: 16384, contextWindowTokens: 202752 },
-    { id: "glm-4.5", maxOutput: 16384, contextWindowTokens: 131072 },
-    { id: "glm-4.5-air", maxOutput: 16384, contextWindowTokens: 131072 },
-    { id: "qwen3-coder-next", maxOutput: 65536, contextWindowTokens: 262144 },
-    { id: "qwen3-coder-plus", maxOutput: 65536, contextWindowTokens: 1000000 },
-    { id: "qwen3-coder-flash", maxOutput: 65536, contextWindowTokens: 1000000 },
-    { id: "qwen3-coder-480b-a35b-instruct", maxOutput: 65536, contextWindowTokens: 262144 },
-    { id: "qwen3-coder-30b-a3b-instruct", maxOutput: 65536, contextWindowTokens: 262144 },
+    // --- Qwen3.5 系列 ---
+    { id: "qwen3.5-plus", maxOutput: 65536, contextWindowTokens: 1000000, enabled: true, releasedAt: "2026-02-15" },
+    { id: "qwen3.5-flash", maxOutput: 65536, contextWindowTokens: 1000000, enabled: true, releasedAt: "2026-02-24" },
     { id: "qwen3.5-397b-a17b", maxOutput: 65536, contextWindowTokens: 262144, releasedAt: "2026-02-16" },
     { id: "qwen3.5-122b-a10b", maxOutput: 65536, contextWindowTokens: 262144, releasedAt: "2026-02-24" },
-    { id: "qwen3.5-27b", maxOutput: 65536, contextWindowTokens: 262144, releasedAt: "2026-02-24" },
     { id: "qwen3.5-35b-a3b", maxOutput: 65536, contextWindowTokens: 262144, releasedAt: "2026-02-24" },
-    { id: "qwen3-235b-a22b-thinking-2507", maxOutput: 32768, contextWindowTokens: 131072, releasedAt: "2025-07-25" },
-    { id: "qwen3-235b-a22b-instruct-2507", maxOutput: 32768, contextWindowTokens: 131072, releasedAt: "2025-07-22" },
-    { id: "qwen3-30b-a3b-thinking-2507", maxOutput: 32768, contextWindowTokens: 131072, releasedAt: "2025-07-30" },
-    { id: "qwen3-30b-a3b-instruct-2507", maxOutput: 32768, contextWindowTokens: 131072, releasedAt: "2025-07-29" },
-    { id: "qwen3-next-80b-a3b-thinking", maxOutput: 32768, contextWindowTokens: 131072, releasedAt: "2025-09-12" },
-    { id: "qwen3-next-80b-a3b-instruct", maxOutput: 32768, contextWindowTokens: 131072, releasedAt: "2025-09-12" },
-    { id: "qwen3-235b-a22b", maxOutput: 8192, contextWindowTokens: 131072, releasedAt: "2025-04-28" },
-    { id: "qwen3-32b", maxOutput: 8192, contextWindowTokens: 131072, releasedAt: "2025-04-28" },
-    { id: "qwen3-30b-a3b", maxOutput: 8192, contextWindowTokens: 131072, releasedAt: "2025-04-28" },
-    { id: "qwen3-14b", maxOutput: 8192, contextWindowTokens: 131072, releasedAt: "2025-04-28" },
-    { id: "qwen3-8b", maxOutput: 8192, contextWindowTokens: 131072, releasedAt: "2025-04-28" },
-    { id: "qwen3-4b", maxOutput: 8192, contextWindowTokens: 131072, releasedAt: "2025-04-28" },
-    { id: "qwen3-1.7b", maxOutput: 8192, contextWindowTokens: 32768, releasedAt: "2025-04-28" },
-    { id: "qwen3-0.6b", maxOutput: 8192, contextWindowTokens: 32768, releasedAt: "2025-04-28" },
-    { id: "qwq-plus", maxOutput: 8192, contextWindowTokens: 131072, releasedAt: "2025-03-05" },
-    { id: "qwen3.5-flash", maxOutput: 65536, contextWindowTokens: 1000000, enabled: true, releasedAt: "2026-02-24" },
-    { id: "qwen-flash", maxOutput: 32768, contextWindowTokens: 1000000, releasedAt: "2025-07-28" },
-    { id: "qwen-turbo", maxOutput: 16384, contextWindowTokens: 1000000, releasedAt: "2025-07-15" },
-    { id: "qwen3.5-plus", maxOutput: 65536, contextWindowTokens: 1000000, enabled: true, releasedAt: "2026-02-15" },
-    { id: "qwen-plus", maxOutput: 32768, contextWindowTokens: 1000000 },
+    { id: "qwen3.5-27b", maxOutput: 65536, contextWindowTokens: 262144, releasedAt: "2026-02-24" },
+    // --- Qwen 通用 ---
     { id: "qwen3-max", maxOutput: 65536, contextWindowTokens: 262144, enabled: true, releasedAt: "2026-01-23" },
     { id: "qwen3-max-preview", maxOutput: 65536, contextWindowTokens: 262144, releasedAt: "2025-10-30" },
     { id: "qwen-max", maxOutput: 8192, contextWindowTokens: 131072 },
-    { id: "qwen-long", maxOutput: 32768, contextWindowTokens: 10000000 },
-    { id: "qwen3.5-omni-plus", maxOutput: 65536, contextWindowTokens: 262144, releasedAt: "2026-03-30" },
-    { id: "qwen3.5-omni-flash", maxOutput: 65536, contextWindowTokens: 262144, releasedAt: "2026-03-30" },
-    { id: "qwen3-omni-flash", maxOutput: 16384, contextWindowTokens: 65536, releasedAt: "2025-12-04" },
-    { id: "qwen-omni-turbo", maxOutput: 2048, contextWindowTokens: 32768 },
-    { id: "qwen2.5-omni-7b", maxOutput: 2048, contextWindowTokens: 32768 },
-    { id: "qwen-vl-plus", maxOutput: 8192, contextWindowTokens: 131072 },
-    { id: "qwen-vl-max", maxOutput: 8192, contextWindowTokens: 131072 },
-    { id: "qwen-vl-ocr", maxOutput: 4096, contextWindowTokens: 34096 },
-    { id: "qwen3-vl-30b-a3b-thinking", maxOutput: 32768, contextWindowTokens: 131072 },
-    { id: "qwen3-vl-30b-a3b-instruct", maxOutput: 32768, contextWindowTokens: 131072 },
-    { id: "qwen3-vl-8b-thinking", maxOutput: 32768, contextWindowTokens: 131072 },
-    { id: "qwen3-vl-8b-instruct", maxOutput: 32768, contextWindowTokens: 131072 },
-    { id: "qwen3-vl-235b-a22b-thinking", maxOutput: 32768, contextWindowTokens: 131072 },
-    { id: "qwen3-vl-235b-a22b-instruct", maxOutput: 32768, contextWindowTokens: 131072 },
-    { id: "qwen3-vl-32b-thinking", maxOutput: 32768, contextWindowTokens: 131072 },
-    { id: "qwen3-vl-32b-instruct", maxOutput: 32768, contextWindowTokens: 131072 },
-    { id: "qwen-math-turbo", maxOutput: 3072, contextWindowTokens: 4096 },
-    { id: "qwen-math-plus", maxOutput: 3072, contextWindowTokens: 4096 },
-    { id: "qwen-coder-turbo", maxOutput: 8192, contextWindowTokens: 131072 },
-    { id: "qwen-coder-plus", maxOutput: 8192, contextWindowTokens: 131072 },
-    { id: "qwq-32b", maxOutput: 8192, contextWindowTokens: 131072, releasedAt: "2025-03-06" },
-    { id: "qwq-32b-preview", maxOutput: 16384, contextWindowTokens: 32768, releasedAt: "2024-11-28" },
-    { id: "qvq-max", maxOutput: 8192, contextWindowTokens: 131072, releasedAt: "2025-05-15" },
-    { id: "qvq-plus", maxOutput: 8192, contextWindowTokens: 131072, releasedAt: "2025-05-15" },
-    { id: "qvq-72b-preview", maxOutput: 16384, contextWindowTokens: 32768, releasedAt: "2024-12-25" },
-    { id: "qwen2.5-7b-instruct", maxOutput: 8192, contextWindowTokens: 131072 },
-    { id: "qwen2.5-14b-instruct", maxOutput: 8192, contextWindowTokens: 131072 },
-    { id: "qwen2.5-32b-instruct", maxOutput: 8192, contextWindowTokens: 131072 },
-    { id: "qwen2.5-72b-instruct", maxOutput: 8192, contextWindowTokens: 131072 },
-    { id: "qwen2.5-14b-instruct-1m", maxOutput: 8192, contextWindowTokens: 1000000, releasedAt: "2025-01-27" },
-    { id: "qwen2.5-math-7b-instruct", maxOutput: 3072, contextWindowTokens: 4096 },
-    { id: "qwen2.5-math-72b-instruct", maxOutput: 3072, contextWindowTokens: 4096, releasedAt: "2025-07-23" },
-    { id: "qwen2.5-coder-7b-instruct", maxOutput: 8192, contextWindowTokens: 131072 },
-    { id: "qwen2.5-coder-14b-instruct", maxOutput: 8192, contextWindowTokens: 131072 },
-    { id: "qwen2.5-coder-32b-instruct", maxOutput: 8192, contextWindowTokens: 131072 },
-    { id: "qwen2.5-vl-72b-instruct", maxOutput: 8192, contextWindowTokens: 131072, releasedAt: "2025-01-27" },
-    { id: "qwen2.5-vl-32b-instruct", maxOutput: 8192, contextWindowTokens: 131072, releasedAt: "2025-03-24" },
-    { id: "qwen2.5-vl-7b-instruct", maxOutput: 8192, contextWindowTokens: 131072, releasedAt: "2025-01-27" },
-    { id: "deepseek-r1-0528", maxOutput: 16384, contextWindowTokens: 131072, releasedAt: "2025-05-28" },
-    { id: "deepseek-v3", maxOutput: 8192, contextWindowTokens: 65536, releasedAt: "2025-01-27" },
-    { id: "deepseek-r1-distill-qwen-1.5b", maxOutput: 16384, contextWindowTokens: 32768 },
-    { id: "deepseek-r1-distill-qwen-7b", maxOutput: 16384, contextWindowTokens: 32768 },
-    { id: "deepseek-r1-distill-qwen-14b", maxOutput: 16384, contextWindowTokens: 32768 },
-    { id: "deepseek-r1-distill-qwen-32b", maxOutput: 16384, contextWindowTokens: 32768 },
-    { id: "deepseek-r1-distill-llama-8b", maxOutput: 16384, contextWindowTokens: 32768 },
-    { id: "deepseek-r1-distill-llama-70b", maxOutput: 16384, contextWindowTokens: 32768 },
+    { id: "qwen-plus", maxOutput: 32768, contextWindowTokens: 1000000 },
+    { id: "qwen-flash", maxOutput: 32768, contextWindowTokens: 1000000, releasedAt: "2025-07-28" },
+    { id: "qwen-turbo", maxOutput: 16384, contextWindowTokens: 1000000, releasedAt: "2025-07-15" },
+    // --- 第三方代理(Anthropic 通道放开的那部分) ---
+    { id: "kimi-k2.5", maxOutput: 32768, contextWindowTokens: 262144, temperature: 1 },
+    { id: "kimi-k2-thinking", maxOutput: 16384, contextWindowTokens: 262144, releasedAt: "2025-11-10", temperature: 1 },
+    { id: "MiniMax-M2.5", maxOutput: 32768, contextWindowTokens: 196608 },
+    { id: "MiniMax-M2.1", maxOutput: 32768, contextWindowTokens: 204800 },
+    { id: "glm-5.1", maxOutput: 16384, contextWindowTokens: 202752, enabled: true, releasedAt: "2026-04-23" },
+    { id: "glm-5", maxOutput: 16384, contextWindowTokens: 202752 },
+    { id: "glm-4.7", maxOutput: 16384, contextWindowTokens: 202752 },
+    { id: "glm-4.6", maxOutput: 16384, contextWindowTokens: 202752 },
   ],
 };