new-model-catalog.test.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { readFile } from "node:fs/promises";
  2. import { describe, expect, it } from "vitest";
  3. import { parseZCodeBuiltinModelConfigRules } from "@zcode/provider";
  4. describe("2026-09 新模型官方目录", () => {
  5. it("模型身份、能力和值域独立声明,不能从旧型号宽匹配猜测", async () => {
  6. const release = JSON.parse(
  7. await readFile(
  8. new URL("../../../config/provider/zcode-builtin.json", import.meta.url),
  9. "utf8",
  10. ),
  11. );
  12. const rules = parseZCodeBuiltinModelConfigRules(release.config.modelConfigRules);
  13. const templates = release.config.providerConfigRules.templateRules;
  14. for (const [templateId, modelId, context, output, levels] of [
  15. ["openai", "gpt-6-astra", 1050000, 128000, ["low", "medium", "high", "xhigh", "max"]],
  16. ["anthropic", "claude-fable-5-1", 1000000, 128000, ["low", "medium", "high", "xhigh", "max"]],
  17. ["deepseek", "deepseek-flash", 1000000, 384000, ["disabled", "low", "high", "max"]],
  18. ] as const) {
  19. const template = templates.find((t: { templateId: string }) => t.templateId === templateId);
  20. expect(template.config.builtinModelIds).toContain(modelId);
  21. const model = rules.resolve({
  22. templateId,
  23. providerId: "fixture",
  24. modelId,
  25. apiType: template.config.api.type,
  26. baseUrl: template.config.api.baseUrl,
  27. });
  28. expect(model.enabled).toBe(true);
  29. expect(model.properties?.contextWindow).toBe(context);
  30. expect(model.properties?.inputFormat?.supportsImage).toBe(true);
  31. expect(model.optionSpecs?.maxOutputTokens?.max).toBe(output);
  32. expect(model.optionSpecs?.reasoningLevel?.values).toEqual(levels);
  33. }
  34. for (const [modelId, baseUrl, image] of [
  35. ["deepseek-v4-flash", "https://api.deepseek.com/anthropic", true],
  36. ["deepseek-v4-flash", "https://proxy.invalid/anthropic", false],
  37. ["deepseek-v4-pro", "https://api.deepseek.com/anthropic", false],
  38. ] as const)
  39. expect(
  40. rules.resolve({ providerId: "fixture", modelId, baseUrl, apiType: "anthropic-messages" })
  41. .properties?.inputFormat?.supportsImage,
  42. ).toBe(image);
  43. });
  44. });