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
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class ZhipuAPIClient extends OpenAIAPIClient {

public async listModels(): Promise<OpenAI.Models.Model[]> {
const models = [
'glm-5',
'glm-4.7',
'glm-4.6',
'glm-4.6v',
Expand Down
15 changes: 14 additions & 1 deletion src/renderer/src/config/models/__tests__/reasoning.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2280,14 +2280,27 @@ describe('isInterleavedThinkingModel', () => {

it('should return false for other glm models', () => {
expect(isInterleavedThinkingModel(createModel({ id: 'glm-3.5' }))).toBe(false)
expect(isInterleavedThinkingModel(createModel({ id: 'glm-5.0' }))).toBe(false)
expect(isInterleavedThinkingModel(createModel({ id: 'glm-zero-preview' }))).toBe(false)
})

it('should handle case insensitivity', () => {
expect(isInterleavedThinkingModel(createModel({ id: 'GLM-4.5' }))).toBe(true)
expect(isInterleavedThinkingModel(createModel({ id: 'Glm-4.6-Pro' }))).toBe(true)
})

it('should return true for glm-5', () => {
expect(isInterleavedThinkingModel(createModel({ id: 'glm-5' }))).toBe(true)
})

it('should return true for glm-5 with suffixes', () => {
expect(isInterleavedThinkingModel(createModel({ id: 'glm-5-pro' }))).toBe(true)
expect(isInterleavedThinkingModel(createModel({ id: 'glm-5-lite' }))).toBe(true)
})

it('should return true for glm-5.x versions (future versions maintain same behavior)', () => {
expect(isInterleavedThinkingModel(createModel({ id: 'glm-5.0' }))).toBe(true)
expect(isInterleavedThinkingModel(createModel({ id: 'glm-5.1' }))).toBe(true)
})
})

describe('Non-matching models', () => {
Expand Down
11 changes: 7 additions & 4 deletions src/renderer/src/config/models/__tests__/websearch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,11 @@ describe('websearch helpers', () => {
expect(isWebSearchModel(createModel({ id: 'gemini-2.0-flash-latest' }))).toBe(true)
})

it('evaluates hunyuan/zhipu/dashscope/openrouter/grok providers', () => {
it('evaluates hunyuan/dashscope/openrouter/grok providers', () => {
providerMock.mockReturnValueOnce(createProvider({ id: 'hunyuan' }))
expect(isWebSearchModel(createModel({ id: 'hunyuan-pro' }))).toBe(true)
expect(isWebSearchModel(createModel({ id: 'hunyuan-lite', provider: 'hunyuan' }))).toBe(false)

providerMock.mockReturnValueOnce(createProvider({ id: 'zhipu' }))
expect(isWebSearchModel(createModel({ id: 'glm-4-air' }))).toBe(true)

providerMock.mockReturnValueOnce(createProvider({ id: 'dashscope' }))
expect(isWebSearchModel(createModel({ id: 'qwen-max-latest' }))).toBe(true)

Expand All @@ -235,6 +232,12 @@ describe('websearch helpers', () => {

providerMock.mockReturnValueOnce(createProvider({ id: 'grok' }))
expect(isWebSearchModel(createModel({ id: 'grok-2' }))).toBe(true)

// zhipu provider does not have built-in search capability
providerMock.mockReturnValueOnce(createProvider({ id: 'zhipu' }))
expect(isWebSearchModel(createModel({ id: 'glm-4-air' }))).toBe(false)
providerMock.mockReturnValueOnce(createProvider({ id: 'zhipu' }))
expect(isWebSearchModel(createModel({ id: 'glm-5' }))).toBe(false)
})
})

Expand Down
12 changes: 12 additions & 0 deletions src/renderer/src/config/models/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,18 @@ export const SYSTEM_MODELS: Record<SystemProviderId | 'defaultModel', Model[]> =
{ id: 'yi-vision-v2', name: 'Yi Vision v2', provider: 'yi', group: 'yi-vision', owned_by: '01.ai' }
],
zhipu: [
{
id: 'glm-5',
provider: 'zhipu',
name: 'GLM-5',
group: 'GLM-5'
},
{
id: 'glm-4.7',
provider: 'zhipu',
name: 'GLM-4.7',
group: 'GLM-4.7'
},
{
id: 'glm-4.5-flash',
provider: 'zhipu',
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/src/config/models/reasoning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ export const isSupportedReasoningEffortPerplexityModel = (model: Model): boolean

export const isSupportedThinkingTokenZhipuModel = (model: Model): boolean => {
const modelId = getLowerBaseModelName(model.id, '/')
return ['glm-4.5', 'glm-4.6', 'glm-4.7'].some((id) => modelId.includes(id))
return ['glm-5', 'glm-4.5', 'glm-4.6', 'glm-4.7'].some((id) => modelId.includes(id))
}

export const isSupportedThinkingTokenMiMoModel = (model: Model): boolean => {
Expand Down Expand Up @@ -803,7 +803,7 @@ export const isFixedReasoningModel = (model: Model) =>
// https://docs.z.ai/guides/capabilities/thinking-mode
// https://platform.moonshot.cn/docs/guide/use-kimi-k2-thinking-model#%E5%A4%9A%E6%AD%A5%E5%B7%A5%E5%85%B7%E8%B0%83%E7%94%A8
const INTERLEAVED_THINKING_MODEL_REGEX =
/minimax-m2(.(\d+))?(?:-[\w-]+)?|mimo-v2-flash|glm-4.(\d+)(?:-[\w-]+)?|kimi-k2-thinking?|kimi-k2.5$/i
/minimax-m2(.(\d+))?(?:-[\w-]+)?|mimo-v2-flash|glm-5(?:.\d+)?(?:-[\w-]+)?|glm-4.(\d+)(?:-[\w-]+)?|kimi-k2-thinking?|kimi-k2.5$/i

/**
* Determines whether the given model supports interleaved thinking.
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/config/models/tooluse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const FUNCTION_CALLING_MODELS = [
'glm-4(?:-[\\w-]+)?',
'glm-4.5(?:-[\\w-]+)?',
'glm-4.7(?:-[\\w-]+)?',
'glm-5(?:-[\\w-]+)?',
'learnlm(?:-[\\w-]+)?',
'gemini(?:-[\\w-]+)?', // 提前排除了gemini的嵌入模型
'grok-3(?:-[\\w-]+)?',
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/config/models/websearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function isWebSearchModel(model: Model): boolean {
}

if (provider.id === 'zhipu') {
return modelId?.startsWith('glm-4-')
return false
}

if (provider.id === 'dashscope') {
Expand Down