-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(core): support glm-5.3-flash under glm-v family #3071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,14 +5,31 @@ import type { | |
| ModelAdapterDefinition, | ||
| } from '../model-adapter/types'; | ||
|
|
||
| const ALWAYS_THINKING_GLM_MODEL_PATTERN = /^glm-5\.3-flash\b/; | ||
|
|
||
| const buildGlmChatCompletionParams = ( | ||
| input: ChatCompletionCallContext, | ||
| ): ChatCompletionParamsResult => { | ||
| const { midsceneDefaults, userConfig } = input; | ||
| const { midsceneDefaults, userConfig, modelName } = input; | ||
| const { reasoningEnabled } = userConfig; | ||
| const commonOverrideConfig: Record<string, unknown> = {}; | ||
|
|
||
| if (userConfig.temperature !== undefined) { | ||
| // GLM models that cannot turn thinking off. GLM-5.3-Flash rejects | ||
| // `thinking.type: 'disabled'` with error 1210 ("该模型始终思考,不支持关闭 | ||
| // 思考"), so for these models the adapter keeps thinking enabled and steers | ||
| // its depth with `reasoning_effort` instead. Field-tested against the | ||
| // Zhipu Coding Plan endpoint in KSL-49 (2026-08-26). | ||
| const alwaysThinking = ALWAYS_THINKING_GLM_MODEL_PATTERN.test( | ||
| modelName ?? '', | ||
| ); | ||
|
|
||
| if (alwaysThinking) { | ||
| // Officially recommended sampling parameters for GLM-5.3-Flash | ||
| // (https://docs.bigmodel.cn/cn/guide/models/vlm/glm-5.3-flash), and the | ||
| // values its vision integration was field-tested with. | ||
| commonOverrideConfig.temperature = userConfig.temperature ?? 1; | ||
| commonOverrideConfig.top_p = 0.95; | ||
| } else if (userConfig.temperature !== undefined) { | ||
| commonOverrideConfig.temperature = userConfig.temperature; | ||
| } | ||
|
|
||
|
|
@@ -27,7 +44,21 @@ const buildGlmChatCompletionParams = ( | |
|
|
||
| const modelSpecificConfig: Record<string, unknown> = {}; | ||
|
|
||
| if (reasoningEnabled !== 'default') { | ||
| if (alwaysThinking) { | ||
| if (reasoningEnabled !== 'default') { | ||
| modelSpecificConfig.thinking = { | ||
| type: 'enabled', | ||
| clear_thinking: false, | ||
| }; | ||
| // Thinking cannot be disabled, so a "no reasoning" intent maps to the | ||
| // cheapest effort level. `low` was sufficient for the KSL-49 vision | ||
| // probes; users can raise it via the reasoning-effort config. | ||
| modelSpecificConfig.reasoning_effort = | ||
| userConfig.reasoningEffort ?? 'low'; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
| } else if (userConfig.reasoningEffort) { | ||
| modelSpecificConfig.reasoning_effort = userConfig.reasoningEffort; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a GLM-5.3 user sets Useful? React with 👍 / 👎. |
||
| } | ||
| } else if (reasoningEnabled !== 'default') { | ||
| modelSpecificConfig.thinking = { | ||
| type: (reasoningEnabled ?? false) ? 'enabled' : 'disabled', | ||
| }; | ||
|
|
@@ -45,6 +76,8 @@ const buildGlmChatCompletionParams = ( | |
| export const glmAdapters = { | ||
| 'glm-v': { | ||
| chatCompletion: { | ||
| // reasoningEffort is honored only by the always-thinking GLM models | ||
| // (see above); reasoningBudget is not supported by the family at all. | ||
| unsupportedUserConfig: ['reasoningEffort', 'reasoningBudget'], | ||
| buildChatCompletionParams: buildGlmChatCompletionParams, | ||
| useReasoningAsContentFallback: true, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The adapter now consumes
MIDSCENE_MODEL_REASONING_EFFORTfor GLM-5.3-Flash, but the authoritative supported-family list inapps/site/docs/{en,zh}/model-config.mdxstill omits GLM and says only the listed families support this setting. Users therefore cannot discover the knob that the implementation and this new row rely on; add GLM-5.3-Flash to both language versions of that list. apps/site/agents.mdL5-L5Useful? React with 👍 / 👎.