forked from cline/cline
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat: add GLM-4.5V model support with image capabilities for z.ai provider #8416
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
Closed
+161
−23
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e5f5438
feat: add GLM-4.5V model support with image capabilities for z.ai pro…
hungthai1401 6283e1f
fix: remove extra space in GLM-4.5V model description
hungthai1401 f25ab8e
feat(types): expand Z.AI international model catalog and add GLM-4.6 …
roomote 06de0f1
chore: trigger CI rerun for Z.AI updates
roomote 47b968b
fix(types): relax ZAiHandler generics and casts to satisfy CI type-ch…
roomote 7aa4e2d
fix(zai): restore typed model IDs, add GLM-4.5V tiers test, clarify i…
hannesrudolph f65a52b
fix(types): break circular import in ZAI types; inline ZaiApiLine lit…
hannesrudolph 09da30d
fix(zai): inline ZAI line configs to avoid runtime/type export issues
hannesrudolph fb9f4ee
fix(types): include 'international' and 'china' in ZAI api line schem…
hannesrudolph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,29 +3,47 @@ import { | |
| mainlandZAiModels, | ||
| internationalZAiDefaultModelId, | ||
| mainlandZAiDefaultModelId, | ||
| type InternationalZAiModelId, | ||
| type MainlandZAiModelId, | ||
| ZAI_DEFAULT_TEMPERATURE, | ||
| zaiApiLineConfigs, | ||
| } from "@roo-code/types" | ||
|
Collaborator
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. P2: Re-introduce type-only imports so the class can use the precise union type without any-casts (e.g., |
||
|
|
||
| import type { ApiHandlerOptions } from "../../shared/api" | ||
| import type { InternationalZAiModelId, MainlandZAiModelId, ModelInfo } from "@roo-code/types" | ||
|
|
||
| import { BaseOpenAiCompatibleProvider } from "./base-openai-compatible-provider" | ||
|
|
||
| export class ZAiHandler extends BaseOpenAiCompatibleProvider<InternationalZAiModelId | MainlandZAiModelId> { | ||
| type ZAiModelId = InternationalZAiModelId | MainlandZAiModelId | ||
|
|
||
| // Local mapping to avoid cross-package runtime dependency issues in CI | ||
| type ZaiApiLineLocal = "international_coding" | "international" | "china_coding" | "china" | ||
| const ZAI_LINE_CONFIGS: Record<ZaiApiLineLocal, { name: string; baseUrl: string; isChina: boolean }> = { | ||
| international_coding: { | ||
| name: "International Coding Plan", | ||
| baseUrl: "https://api.z.ai/api/coding/paas/v4", | ||
| isChina: false, | ||
| }, | ||
| international: { name: "International Standard", baseUrl: "https://api.z.ai/api/paas/v4", isChina: false }, | ||
| china_coding: { name: "China Coding Plan", baseUrl: "https://open.bigmodel.cn/api/coding/paas/v4", isChina: true }, | ||
| china: { name: "China Standard", baseUrl: "https://open.bigmodel.cn/api/paas/v4", isChina: true }, | ||
| } | ||
|
|
||
| export class ZAiHandler extends BaseOpenAiCompatibleProvider<ZAiModelId> { | ||
| constructor(options: ApiHandlerOptions) { | ||
| const isChina = zaiApiLineConfigs[options.zaiApiLine ?? "international_coding"].isChina | ||
| const models = isChina ? mainlandZAiModels : internationalZAiModels | ||
| const line = (options.zaiApiLine ?? "international_coding") as ZaiApiLineLocal | ||
| const { isChina, baseUrl } = ZAI_LINE_CONFIGS[line] | ||
|
|
||
| const defaultModelId = isChina ? mainlandZAiDefaultModelId : internationalZAiDefaultModelId | ||
| const providerModels = (isChina ? mainlandZAiModels : internationalZAiModels) as unknown as Record< | ||
| ZAiModelId, | ||
| ModelInfo | ||
| > | ||
|
|
||
| super({ | ||
| ...options, | ||
| providerName: "Z AI", | ||
| baseURL: zaiApiLineConfigs[options.zaiApiLine ?? "international_coding"].baseUrl, | ||
| baseURL: baseUrl, | ||
| apiKey: options.zaiApiKey ?? "not-provided", | ||
| defaultProviderModelId: defaultModelId, | ||
| providerModels: models, | ||
| providerModels, | ||
| defaultTemperature: ZAI_DEFAULT_TEMPERATURE, | ||
| }) | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.