feat(ai): add Zhipu provider preset
This commit is contained in:
8 files changed
+72
-4
No files matched your search
@@ -772,6 +772,19 @@ describe("settingsStore AI API key normalization", () => {
|
||||
expect(normalizeAiConfig({ endpoint: "https://api.moonshot.cn/v1", model: "kimi-k2.5" }).provider).toBe("kimi");
|
||||
});
|
||||
|
||||
it("provides Zhipu defaults and recognizes legacy Zhipu configurations", () => {
|
||||
expect(AI_PROVIDER_PRESETS.zhipu).toMatchObject({
|
||||
provider: "zhipu",
|
||||
endpoint: "https://open.bigmodel.cn/api/paas/v4",
|
||||
model: "glm-5.3",
|
||||
apiStyle: "completions",
|
||||
authMethod: "bearer",
|
||||
requiresApiKey: true,
|
||||
});
|
||||
expect(normalizeAiConfig({ endpoint: "https://open.bigmodel.cn/api/paas/v4", model: "glm-4.6" }).provider).toBe("zhipu");
|
||||
expect(normalizeAiConfig({ endpoint: "https://api.z.ai/api/paas/v4", model: "glm-5.2" }).provider).toBe("zhipu");
|
||||
});
|
||||
|
||||
it("uses the mainland MiniMax endpoint only for new zh-CN presets", () => {
|
||||
expect(getAiProviderPresetDefaultEndpoint(AI_PROVIDER_PRESETS.minimax, "zh-CN")).toBe("https://api.minimaxi.com/v1");
|
||||
expect(getAiProviderPresetDefaultEndpoint(AI_PROVIDER_PRESETS.minimax, "zh-TW")).toBe("https://api.minimax.io/v1");
|
||||
@@ -779,6 +792,12 @@ describe("settingsStore AI API key normalization", () => {
|
||||
expect(getAiProviderPresetDefaultEndpoint(AI_PROVIDER_PRESETS.openai, "zh-CN")).toBe(AI_PROVIDER_PRESETS.openai.endpoint);
|
||||
});
|
||||
|
||||
it("uses the international Zhipu endpoint for non-zh-CN presets", () => {
|
||||
expect(getAiProviderPresetDefaultEndpoint(AI_PROVIDER_PRESETS.zhipu, "zh-CN")).toBe("https://open.bigmodel.cn/api/paas/v4");
|
||||
expect(getAiProviderPresetDefaultEndpoint(AI_PROVIDER_PRESETS.zhipu, "zh-TW")).toBe("https://api.z.ai/api/paas/v4");
|
||||
expect(getAiProviderPresetDefaultEndpoint(AI_PROVIDER_PRESETS.zhipu, "en")).toBe("https://api.z.ai/api/paas/v4");
|
||||
});
|
||||
|
||||
it("preserves saved MiniMax endpoints during normalization", () => {
|
||||
expect(normalizeAiConfig({ provider: "minimax", endpoint: "https://api.minimaxi.com/v1" }).endpoint).toBe("https://api.minimaxi.com/v1");
|
||||
expect(normalizeAiConfig({ provider: "minimax", endpoint: "https://minimax.example.com/v1" }).endpoint).toBe("https://minimax.example.com/v1");
|
||||
|
||||
@@ -301,6 +301,16 @@ export const AI_PROVIDER_PRESETS: Record<AiProvider, AiProviderPreset> = {
|
||||
authMethod: "bearer",
|
||||
requiresApiKey: true,
|
||||
},
|
||||
zhipu: {
|
||||
label: "Zhipu",
|
||||
iconSlug: "zhipu",
|
||||
provider: "zhipu",
|
||||
endpoint: "https://open.bigmodel.cn/api/paas/v4",
|
||||
model: "glm-5.3",
|
||||
apiStyle: "completions",
|
||||
authMethod: "bearer",
|
||||
requiresApiKey: true,
|
||||
},
|
||||
minimax: {
|
||||
label: "MiniMax",
|
||||
iconSlug: "minimax",
|
||||
@@ -490,6 +500,9 @@ export function getAiProviderPresetDefaultEndpoint(preset: AiProviderPreset | Ai
|
||||
if (preset.provider === "minimax" && locale === "zh-CN") {
|
||||
return "https://api.minimaxi.com/v1";
|
||||
}
|
||||
if (preset.provider === "zhipu" && locale !== "zh-CN") {
|
||||
return "https://api.z.ai/api/paas/v4";
|
||||
}
|
||||
return preset.endpoint;
|
||||
}
|
||||
|
||||
@@ -588,6 +601,7 @@ function inferAiProviderFromConfig(config: Partial<AiConfig> | null | undefined)
|
||||
if (endpoint.includes("deepseek") || model.includes("deepseek")) return "deepseek";
|
||||
if (endpoint.includes("moonshot") || endpoint.includes("kimi.com") || model.includes("kimi")) return "kimi";
|
||||
if (endpoint.includes("dashscope") || endpoint.includes("aliyuncs") || model.includes("qwen")) return "qwen";
|
||||
if (endpoint.includes("bigmodel.cn") || endpoint.includes("api.z.ai") || model.startsWith("glm-")) return "zhipu";
|
||||
if (endpoint.includes("generativelanguage.googleapis.com") || model.includes("gemini")) return "gemini";
|
||||
if (endpoint.includes("minimax.io") || endpoint.includes("minimaxi.com") || model.includes("minimax")) return "minimax";
|
||||
if (endpoint.includes("localhost:11434") || endpoint.includes("127.0.0.1:11434")) return "ollama";
|
||||
|
||||
@@ -1,4 +1,24 @@
|
||||
export type AiProvider = "claude" | "openai" | "gemini" | "deepseek" | "kimi" | "qwen" | "minimax" | "ollama" | "anthropic-compatible" | "openai-compatible" | "claude-code-cli" | "pi-agent-cli" | "codex-cli" | "opencode-cli" | "cursor-cli" | "grok-cli" | "codebuddy-cli" | "qoder-cli" | "custom";
|
||||
export type AiProvider =
|
||||
| "claude"
|
||||
| "openai"
|
||||
| "gemini"
|
||||
| "deepseek"
|
||||
| "kimi"
|
||||
| "qwen"
|
||||
| "zhipu"
|
||||
| "minimax"
|
||||
| "ollama"
|
||||
| "anthropic-compatible"
|
||||
| "openai-compatible"
|
||||
| "claude-code-cli"
|
||||
| "pi-agent-cli"
|
||||
| "codex-cli"
|
||||
| "opencode-cli"
|
||||
| "cursor-cli"
|
||||
| "grok-cli"
|
||||
| "codebuddy-cli"
|
||||
| "qoder-cli"
|
||||
| "custom";
|
||||
export type AiApiStyle = "completions" | "responses" | "anthropic-messages";
|
||||
export type AiAuthMethod = "api-key" | "bearer";
|
||||
export type AiEffortLevel = "low" | "medium" | "high" | "xhigh" | "max";
|
||||
|
||||
Reference in new issue
Block a user