mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 21:30:17 +08:00
f2935a3db9
Enable openai_chat routing with explicit model catalogs across the major Chinese/Asian providers (DeepSeek, Zhipu GLM, Kimi, MiniMax, Baidu Qianfan, Bailian, StepFun, Volcengine Agent Plan, BytePlus, DouBaoSeed, ModelScope, Longcat, BaiLing, Xiaomi MiMo, SiliconFlow, Novita AI, Nvidia, etc.). Each preset declares its context window so the UI can size catalog rows when the preset is picked. Also lands two consistency fixes uncovered along the way: - Include setCodexCatalogModels in resetCodexConfig's useCallback deps to match the new third parameter it consumes. - Realign TheRouter Codex test to the "custom" model_provider bucket established by the recent third-party unification; the previous assertion predated that refactor and had been failing on HEAD.
69 lines
3.0 KiB
TypeScript
69 lines
3.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { providerPresets } from "@/config/claudeProviderPresets";
|
|
import { codexProviderPresets } from "@/config/codexProviderPresets";
|
|
import { geminiProviderPresets } from "@/config/geminiProviderPresets";
|
|
|
|
describe("TheRouter provider presets", () => {
|
|
it("uses the Anthropic-compatible root endpoint for Claude", () => {
|
|
const preset = providerPresets.find((item) => item.name === "TheRouter");
|
|
|
|
expect(preset).toBeDefined();
|
|
expect(preset?.websiteUrl).toBe("https://therouter.ai");
|
|
expect(preset?.apiKeyUrl).toBe("https://dashboard.therouter.ai");
|
|
expect(preset?.category).toBe("aggregator");
|
|
expect(preset?.endpointCandidates).toEqual(["https://api.therouter.ai"]);
|
|
|
|
const env = (preset?.settingsConfig as { env: Record<string, string> }).env;
|
|
expect(env.ANTHROPIC_BASE_URL).toBe("https://api.therouter.ai");
|
|
expect(env.ANTHROPIC_AUTH_TOKEN).toBe("");
|
|
expect(env.ANTHROPIC_API_KEY).toBe("");
|
|
expect(env.ANTHROPIC_MODEL).toBe("anthropic/claude-sonnet-4.6");
|
|
expect(env.ANTHROPIC_DEFAULT_HAIKU_MODEL).toBe(
|
|
"anthropic/claude-haiku-4.5",
|
|
);
|
|
expect(env.ANTHROPIC_DEFAULT_SONNET_MODEL).toBe(
|
|
"anthropic/claude-sonnet-4.6",
|
|
);
|
|
expect(env.ANTHROPIC_DEFAULT_OPUS_MODEL).toBe(
|
|
"anthropic/claude-opus-4.7",
|
|
);
|
|
});
|
|
|
|
it("uses the OpenAI-compatible v1 endpoint for Codex", () => {
|
|
const preset = codexProviderPresets.find((item) => item.name === "TheRouter");
|
|
|
|
expect(preset).toBeDefined();
|
|
expect(preset?.websiteUrl).toBe("https://therouter.ai");
|
|
expect(preset?.apiKeyUrl).toBe("https://dashboard.therouter.ai");
|
|
expect(preset?.category).toBe("aggregator");
|
|
expect(preset?.endpointCandidates).toEqual([
|
|
"https://api.therouter.ai/v1",
|
|
]);
|
|
expect(preset?.auth).toEqual({ OPENAI_API_KEY: "" });
|
|
expect(preset?.config).toContain('model_provider = "custom"');
|
|
expect(preset?.config).toContain("[model_providers.custom]");
|
|
expect(preset?.config).toContain('name = "therouter"');
|
|
expect(preset?.config).toContain('model = "openai/gpt-5.3-codex"');
|
|
expect(preset?.config).toContain(
|
|
'base_url = "https://api.therouter.ai/v1"',
|
|
);
|
|
expect(preset?.config).toContain('wire_api = "responses"');
|
|
});
|
|
|
|
it("uses the Gemini-native root endpoint for Gemini", () => {
|
|
const preset = geminiProviderPresets.find((item) => item.name === "TheRouter");
|
|
|
|
expect(preset).toBeDefined();
|
|
expect(preset?.websiteUrl).toBe("https://therouter.ai");
|
|
expect(preset?.apiKeyUrl).toBe("https://dashboard.therouter.ai");
|
|
expect(preset?.category).toBe("aggregator");
|
|
expect(preset?.endpointCandidates).toEqual(["https://api.therouter.ai"]);
|
|
expect(preset?.baseURL).toBe("https://api.therouter.ai");
|
|
expect(preset?.model).toBe("gemini-3.1-pro");
|
|
|
|
const env = (preset?.settingsConfig as { env: Record<string, string> }).env;
|
|
expect(env.GOOGLE_GEMINI_BASE_URL).toBe("https://api.therouter.ai");
|
|
expect(env.GEMINI_MODEL).toBe("gemini-3.1-pro");
|
|
});
|
|
});
|