Parcourir la source

refactor(core): 删除 qwen endpoint(与 bailian 重复)+ 修正 xiaomimimo 注释

qwen 和 bailian 是同一套阿里百炼后端的两张皮:
- qwen:dashscope/compatible-mode/v1,openai-completions
- bailian:dashscope/apps/anthropic,anthropic-messages

inkos agent 场景下 Anthropic 协议的工具调用更稳(这也是当初 bailian 选走
/anthropic 的原因),两者的模型清单必须同步维护,UI 下拉里也会出现两个名字
几乎一样的条目让人困惑。

决策:保留 bailian,删 qwen。用户若坚持 OpenAI 协议调 qwen,走 custom
endpoint 填 dashscope/compatible-mode/v1 即可。

- 删 packages/core/src/llm/providers/endpoints/qwen.ts
- providers/index.ts 移除 QWEN 引用
- lookup.ts PROVIDER_PRIORITY 里 "qwen" 换成 "bailian"
- providers-schema.test 断言更新(总数 36 → 35,A 组测试要求含 bailian 且
  不含 qwen)

顺手修 xiaomimimo 顶部注释:之前错写"官方暂无独立 API",实际
api-ai.xiaomi.com/v1 就是小米自家的 OpenAI 兼容端点。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
fanghanjun il y a 6 mois
Parent
commit
d5c5a67ec6

+ 9 - 6
packages/core/src/__tests__/providers-schema.test.ts

@@ -39,14 +39,17 @@ describe("providers structural integrity", () => {
     }
   });
 
-  it("A 组至少有 6 个核心 provider", () => {
+  it("A 组至少有 5 个核心 provider", () => {
     const ids = getAllEndpoints().map((p) => p.id);
     expect(ids).toContain("anthropic");
     expect(ids).toContain("openai");
     expect(ids).toContain("google");
     expect(ids).toContain("deepseek");
-    expect(ids).toContain("qwen");
     expect(ids).toContain("minimax");
+    // 阿里通义千问:仅保留 bailian(Anthropic 协议,工具调用更稳),
+    // 已删除重复的 qwen endpoint(OpenAI 协议同家)
+    expect(ids).toContain("bailian");
+    expect(ids).not.toContain("qwen");
   });
 
   it("B1:中国原厂批次 1 全部收录(10 个)", () => {
@@ -100,9 +103,9 @@ describe("providers structural integrity", () => {
     expect(getEndpoint("higress")?.baseUrl).toBe("");
   });
 
-  it("B4:总 provider 数 = 36(不含 CodingPlan)", () => {
+  it("B4:总 provider 数 = 35(不含 CodingPlan,R5 删除重复的 qwen 后)", () => {
     const nonCoding = getAllEndpoints().filter((p) => !p.id.endsWith("CodingPlan"));
-    expect(nonCoding.length).toBe(36);
+    expect(nonCoding.length).toBe(35);
   });
 
   it("B6:CodingPlan 7 个 provider 全部收录", () => {
@@ -116,8 +119,8 @@ describe("providers structural integrity", () => {
     }
   });
 
-  it("B6:总 provider 数 = 43 (36 base + 7 CodingPlan)", () => {
-    expect(getAllEndpoints().length).toBe(43);
+  it("B6:总 provider 数 = 42 (35 base + 7 CodingPlan)", () => {
+    expect(getAllEndpoints().length).toBe(42);
   });
 
   it("B6:CodingPlan provider 都走 anthropic-messages", () => {

+ 0 - 128
packages/core/src/llm/providers/endpoints/qwen.ts

@@ -1,128 +0,0 @@
-/**
- * 通义千问(百炼 OpenAI 兼容接入)
- *
- * - 控制台:https://bailian.console.aliyun.com/
- * - 模型文档:https://help.aliyun.com/zh/model-studio/getting-started/models
- * - OpenAI 兼容 API:https://help.aliyun.com/zh/model-studio/developer-reference/use-openai-sdk
- *
- * 和 bailian endpoint 同源(同一套百炼后端),区别在 api 协议:
- * - qwen:openai-completions(/compatible-mode/v1)
- * - bailian:anthropic-messages(/apps/anthropic)
- */
-import type { InkosEndpoint } from "../types.js";
-
-export const QWEN: InkosEndpoint = {
-  id: "qwen",
-  label: "通义千问",
-  api: "openai-completions",
-  baseUrl: "https://dashscope.aliyuncs.com/compatible-mode/v1",
-  checkModel: "qwen-flash",
-  temperatureRange: [0, 2],
-  defaultTemperature: 0.7,
-  writingTemperature: 1,
-  models: [
-    // --- Qwen3.6 系列(2026-04 发布) ---
-    { 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" },
-    { id: "kimi-k2.5", maxOutput: 32768, contextWindowTokens: 262144 },
-    { 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" },
-    { 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 },
-    { 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: 8192, 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-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: 32768 },
-    { 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 },
-  ],
-};

+ 5 - 2
packages/core/src/llm/providers/endpoints/xiaomimimo.ts

@@ -1,8 +1,11 @@
 /**
  * 小米 MiMo
  *
- * - MiMo 是小米自研模型系列,目前在 PPIO / 百炼等平台开放,小米官方暂无独立 API。
- * - 模型卡 (HF):https://huggingface.co/XiaomiMiMo
+ * - 官网:https://api-ai.xiaomi.com/
+ * - API 端点:https://api-ai.xiaomi.com/v1 (OpenAI 兼容)
+ * - 模型卡 (HuggingFace):https://huggingface.co/XiaomiMiMo
+ *
+ * MiMo 是小米自研模型系列,除小米官方 /v1 外,也在 PPIO / 百炼等第三方平台开放。
  */
 import type { InkosEndpoint } from "../types.js";
 

+ 1 - 2
packages/core/src/llm/providers/index.ts

@@ -3,7 +3,6 @@ import { ANTHROPIC } from "./endpoints/anthropic.js";
 import { OPENAI } from "./endpoints/openai.js";
 import { GOOGLE } from "./endpoints/google.js";
 import { DEEPSEEK } from "./endpoints/deepseek.js";
-import { QWEN } from "./endpoints/qwen.js";
 import { MINIMAX } from "./endpoints/minimax.js";
 // B1
 import { MOONSHOT } from "./endpoints/moonshot.js";
@@ -55,7 +54,7 @@ export type { InkosEndpoint, InkosModel, ApiProtocol } from "./types.js";
  * 但 Layer 2 还会按 PROVIDER_PRIORITY 显式排序,所以此处顺序不影响结果。
  */
 const ALL_PROVIDERS: readonly InkosEndpoint[] = [
-  ANTHROPIC, OPENAI, GOOGLE, DEEPSEEK, QWEN, MINIMAX,
+  ANTHROPIC, OPENAI, GOOGLE, DEEPSEEK, MINIMAX,
   MOONSHOT, ZHIPU, SILICONCLOUD, PPIO, BAILIAN, VOLCENGINE, HUNYUAN, BAICHUAN, STEPFUN, WENXIN,
   SPARK, SENSENOVA, TENCENTCLOUD, XIAOMI_MIMO, LONGCAT, INTERNLM,
   MODELSCOPE, GITEEAI, QINIU, HIGRESS, INFINIAI, ZEROONE, AI360,

+ 2 - 2
packages/core/src/llm/providers/lookup.ts

@@ -6,9 +6,9 @@ import { getAllEndpoints, getEndpoint } from "./index.js";
  * 保证结果确定性。白名单外的 provider 视同 999(排最后)。
  */
 const PROVIDER_PRIORITY: readonly string[] = [
-  "anthropic", "openai", "google", "deepseek", "qwen", "moonshot",
+  "anthropic", "openai", "google", "deepseek", "bailian", "moonshot",
   "zhipu", "minimax", "xai",
-  "siliconcloud", "ppio", "bailian",
+  "siliconcloud", "ppio",
   "openrouter", "aihubmix", "novita",
 ];