diff --git a/packages/types/src/providers/zai.ts b/packages/types/src/providers/zai.ts index 1dfface9f6..f7e35a63d9 100644 --- a/packages/types/src/providers/zai.ts +++ b/packages/types/src/providers/zai.ts @@ -5,6 +5,8 @@ import { ZaiApiLine } from "../provider-settings.js" // https://docs.z.ai/guides/llm/glm-4-32b-0414-128k // https://docs.z.ai/guides/llm/glm-4.5 // https://docs.z.ai/guides/llm/glm-4.6 +// https://docs.z.ai/guides/llm/glm-4.7 +// https://docs.z.ai/guides/capabilities/thinking-mode // https://docs.z.ai/guides/overview/pricing // https://bigmodel.cn/pricing @@ -107,6 +109,21 @@ export const internationalZAiModels = { description: "GLM-4.6 is Zhipu's newest model with an extended context window of up to 200k tokens, providing enhanced capabilities for processing longer documents and conversations.", }, + "glm-4.7": { + maxTokens: 98_304, + contextWindow: 200_000, + supportsImages: false, + supportsPromptCache: true, + supportsNativeTools: true, + defaultToolProtocol: "native", + preserveReasoning: true, + inputPrice: 0.6, + outputPrice: 2.2, + cacheWritesPrice: 0, + cacheReadsPrice: 0.11, + description: + "GLM-4.7 is Zhipu's latest model with preserved thinking capabilities, allowing reasoning content to be retained across turns for improved coherence and cache efficiency.", + }, "glm-4-32b-0414-128k": { maxTokens: 98_304, contextWindow: 131_072, @@ -221,6 +238,21 @@ export const mainlandZAiModels = { description: "GLM-4.6 is Zhipu's newest model with an extended context window of up to 200k tokens, providing enhanced capabilities for processing longer documents and conversations.", }, + "glm-4.7": { + maxTokens: 98_304, + contextWindow: 204_800, + supportsImages: false, + supportsPromptCache: true, + supportsNativeTools: true, + defaultToolProtocol: "native", + preserveReasoning: true, + inputPrice: 0.29, + outputPrice: 1.14, + cacheWritesPrice: 0, + cacheReadsPrice: 0.057, + description: + "GLM-4.7 is Zhipu's latest model with preserved thinking capabilities, allowing reasoning content to be retained across turns for improved coherence and cache efficiency.", + }, } as const satisfies Record export const ZAI_DEFAULT_TEMPERATURE = 0.6 diff --git a/src/api/providers/__tests__/zai.spec.ts b/src/api/providers/__tests__/zai.spec.ts index 707abee09f..2c6bf49883 100644 --- a/src/api/providers/__tests__/zai.spec.ts +++ b/src/api/providers/__tests__/zai.spec.ts @@ -6,6 +6,7 @@ import { Anthropic } from "@anthropic-ai/sdk" import { type InternationalZAiModelId, type MainlandZAiModelId, + type ModelInfo, internationalZAiDefaultModelId, mainlandZAiDefaultModelId, internationalZAiModels, @@ -96,6 +97,23 @@ describe("ZAiHandler", () => { expect(model.info.maxTokens).toBe(16_384) expect(model.info.contextWindow).toBe(131_072) }) + + it("should return GLM-4.7 international model with preserved thinking support", () => { + const testModelId: InternationalZAiModelId = "glm-4.7" + const handlerWithModel = new ZAiHandler({ + apiModelId: testModelId, + zaiApiKey: "test-zai-api-key", + zaiApiLine: "international_coding", + }) + const model = handlerWithModel.getModel() + expect(model.id).toBe(testModelId) + expect(model.info).toEqual(internationalZAiModels[testModelId]) + // GLM-4.7 should have preserveReasoning enabled for interleaved thinking mode + // This allows reasoning_content to be passed back during tool call continuation + expect((model.info as ModelInfo).preserveReasoning).toBe(true) + expect(model.info.contextWindow).toBe(200_000) + expect(model.info.supportsNativeTools).toBe(true) + }) }) describe("China Z AI", () => { @@ -161,6 +179,23 @@ describe("ZAiHandler", () => { expect(model.info.maxTokens).toBe(16_384) expect(model.info.contextWindow).toBe(131_072) }) + + it("should return GLM-4.7 China model with preserved thinking support", () => { + const testModelId: MainlandZAiModelId = "glm-4.7" + const handlerWithModel = new ZAiHandler({ + apiModelId: testModelId, + zaiApiKey: "test-zai-api-key", + zaiApiLine: "china_coding", + }) + const model = handlerWithModel.getModel() + expect(model.id).toBe(testModelId) + expect(model.info).toEqual(mainlandZAiModels[testModelId]) + // GLM-4.7 should have preserveReasoning enabled for interleaved thinking mode + // This allows reasoning_content to be passed back during tool call continuation + expect((model.info as ModelInfo).preserveReasoning).toBe(true) + expect(model.info.contextWindow).toBe(204_800) + expect(model.info.supportsNativeTools).toBe(true) + }) }) describe("International API", () => {