Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions packages/types/src/providers/zai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const internationalZAiModels = {
supportsImages: false,
supportsPromptCache: true,
supportsNativeTools: true,
supportsReasoningBinary: true,
inputPrice: 0.6,
outputPrice: 2.2,
cacheWritesPrice: 0,
Expand Down Expand Up @@ -94,7 +93,6 @@ export const internationalZAiModels = {
supportsImages: false,
supportsPromptCache: true,
supportsNativeTools: true,
supportsReasoningBinary: true,
inputPrice: 0.6,
outputPrice: 2.2,
cacheWritesPrice: 0,
Expand Down Expand Up @@ -125,7 +123,6 @@ export const mainlandZAiModels = {
supportsImages: false,
supportsPromptCache: true,
supportsNativeTools: true,
supportsReasoningBinary: true,
inputPrice: 0.29,
outputPrice: 1.14,
cacheWritesPrice: 0,
Expand Down Expand Up @@ -202,7 +199,6 @@ export const mainlandZAiModels = {
supportsImages: false,
supportsPromptCache: true,
supportsNativeTools: true,
supportsReasoningBinary: true,
inputPrice: 0.29,
outputPrice: 1.14,
cacheWritesPrice: 0,
Expand Down
138 changes: 0 additions & 138 deletions src/api/providers/__tests__/zai.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,143 +295,5 @@ describe("ZAiHandler", () => {
undefined,
)
})

describe("Reasoning functionality", () => {
it("should include thinking parameter when enableReasoningEffort is true and model supports reasoning in createMessage", async () => {
const handlerWithReasoning = new ZAiHandler({
apiModelId: "glm-4.6", // GLM-4.6 has supportsReasoningBinary: true
zaiApiKey: "test-zai-api-key",
zaiApiLine: "international_coding",
enableReasoningEffort: true,
})

mockCreate.mockImplementationOnce(() => {
return {
[Symbol.asyncIterator]: () => ({
async next() {
return { done: true }
},
}),
}
})

const systemPrompt = "Test system prompt"
const messages: Anthropic.Messages.MessageParam[] = [{ role: "user", content: "Test message" }]

const messageGenerator = handlerWithReasoning.createMessage(systemPrompt, messages)
await messageGenerator.next()

expect(mockCreate).toHaveBeenCalledWith(
expect.objectContaining({
thinking: { type: "enabled" },
}),
undefined,
)
})

it("should not include thinking parameter when enableReasoningEffort is false in createMessage", async () => {
const handlerWithoutReasoning = new ZAiHandler({
apiModelId: "glm-4.6", // GLM-4.6 has supportsReasoningBinary: true
zaiApiKey: "test-zai-api-key",
zaiApiLine: "international_coding",
enableReasoningEffort: false,
})

mockCreate.mockImplementationOnce(() => {
return {
[Symbol.asyncIterator]: () => ({
async next() {
return { done: true }
},
}),
}
})

const systemPrompt = "Test system prompt"
const messages: Anthropic.Messages.MessageParam[] = [{ role: "user", content: "Test message" }]

const messageGenerator = handlerWithoutReasoning.createMessage(systemPrompt, messages)
await messageGenerator.next()

expect(mockCreate).toHaveBeenCalledWith(
expect.not.objectContaining({
thinking: expect.anything(),
}),
undefined,
)
})

it("should not include thinking parameter when model does not support reasoning in createMessage", async () => {
const handlerWithNonReasoningModel = new ZAiHandler({
apiModelId: "glm-4-32b-0414-128k", // This model doesn't have supportsReasoningBinary: true
zaiApiKey: "test-zai-api-key",
zaiApiLine: "international_coding",
enableReasoningEffort: true,
})

mockCreate.mockImplementationOnce(() => {
return {
[Symbol.asyncIterator]: () => ({
async next() {
return { done: true }
},
}),
}
})

const systemPrompt = "Test system prompt"
const messages: Anthropic.Messages.MessageParam[] = [{ role: "user", content: "Test message" }]

const messageGenerator = handlerWithNonReasoningModel.createMessage(systemPrompt, messages)
await messageGenerator.next()

expect(mockCreate).toHaveBeenCalledWith(
expect.not.objectContaining({
thinking: expect.anything(),
}),
undefined,
)
})

it("should include thinking parameter when enableReasoningEffort is true and model supports reasoning in completePrompt", async () => {
const handlerWithReasoning = new ZAiHandler({
apiModelId: "glm-4.5", // GLM-4.5 has supportsReasoningBinary: true
zaiApiKey: "test-zai-api-key",
zaiApiLine: "international_coding",
enableReasoningEffort: true,
})

const expectedResponse = "This is a test response"
mockCreate.mockResolvedValueOnce({ choices: [{ message: { content: expectedResponse } }] })

await handlerWithReasoning.completePrompt("test prompt")

expect(mockCreate).toHaveBeenCalledWith(
expect.objectContaining({
thinking: { type: "enabled" },
}),
)
})

it("should not include thinking parameter when enableReasoningEffort is false in completePrompt", async () => {
const handlerWithoutReasoning = new ZAiHandler({
apiModelId: "glm-4.5", // GLM-4.5 has supportsReasoningBinary: true
zaiApiKey: "test-zai-api-key",
zaiApiLine: "international_coding",
enableReasoningEffort: false,
})

const expectedResponse = "This is a test response"
mockCreate.mockResolvedValueOnce({ choices: [{ message: { content: expectedResponse } }] })

await handlerWithoutReasoning.completePrompt("test prompt")

expect(mockCreate).toHaveBeenCalledWith(
expect.not.objectContaining({
thinking: expect.anything(),
}),
)
})
})
})
})
Loading