This repository was archived by the owner on May 15, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathglm-model-detection.spec.ts
More file actions
115 lines (104 loc) · 2.9 KB
/
Copy pathglm-model-detection.spec.ts
File metadata and controls
115 lines (104 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import { isGlmModel, getGlmModelOptions } from "../glm-model-detection"
describe("GLM Model Detection", () => {
describe("isGlmModel", () => {
describe("should detect GLM models", () => {
const validGlmModels = [
// Standard Z.ai format
"glm-4.5",
"glm-4.6",
"glm-4.7",
"glm-4.5-air",
"glm-4.5v",
// MLX format (from user's report)
"mlx-community/GLM-4.5-4bit",
"mlx-community/GLM-4.5-8bit",
// GGUF format (from user's report)
"GLM-4.5-UD-Q8_K_XL-00001-of-00008.gguf",
"GLM-4.5-UD-Q4_K_M.gguf",
// HuggingFace format
"THUDM/glm-4-9b-chat",
"THUDM/glm-4v-9b",
// ChatGLM variants
"chatglm-6b",
"chatglm2-6b",
"chatglm3-6b",
"ChatGLM-6B",
// Without hyphen
"glm4",
"GLM4",
// Mixed case
"GLM-4.5",
"Glm-4.5",
]
test.each(validGlmModels)('should detect "%s" as a GLM model', (modelId) => {
expect(isGlmModel(modelId)).toBe(true)
})
})
describe("should NOT detect non-GLM models", () => {
const nonGlmModels = [
// OpenAI models
"gpt-4",
"gpt-4-turbo",
"gpt-3.5-turbo",
"o1-preview",
// Anthropic models
"claude-3-opus",
"claude-3.5-sonnet",
// Llama models
"llama-3.1-70b",
"meta-llama/Llama-3.1-8B-Instruct",
// Mistral models
"mistral-7b",
"mixtral-8x7b",
// DeepSeek models
"deepseek-coder",
"deepseek-reasoner",
// Qwen models
"qwen-2.5-72b",
"qwen-coder",
// Empty/undefined
"",
]
test.each(nonGlmModels)('should NOT detect "%s" as a GLM model', (modelId) => {
expect(isGlmModel(modelId)).toBe(false)
})
})
it("should return false for undefined modelId", () => {
expect(isGlmModel(undefined)).toBe(false)
})
})
describe("getGlmModelOptions", () => {
it("should return options for GLM models", () => {
const options = getGlmModelOptions("glm-4.5")
expect(options).toEqual({
mergeToolResultText: true,
disableParallelToolCalls: true,
})
})
it("should return options for MLX GLM models", () => {
const options = getGlmModelOptions("mlx-community/GLM-4.5-4bit")
expect(options).toEqual({
mergeToolResultText: true,
disableParallelToolCalls: true,
})
})
it("should return options for GGUF GLM models", () => {
const options = getGlmModelOptions("GLM-4.5-UD-Q8_K_XL-00001-of-00008.gguf")
expect(options).toEqual({
mergeToolResultText: true,
disableParallelToolCalls: true,
})
})
it("should return undefined for non-GLM models", () => {
expect(getGlmModelOptions("gpt-4")).toBeUndefined()
expect(getGlmModelOptions("llama-3.1")).toBeUndefined()
expect(getGlmModelOptions("claude-3")).toBeUndefined()
})
it("should return undefined for undefined modelId", () => {
expect(getGlmModelOptions(undefined)).toBeUndefined()
})
it("should return undefined for empty string", () => {
expect(getGlmModelOptions("")).toBeUndefined()
})
})
})