-
Couldn't load subscription status.
- Fork 2.4k
feat: add GLM Coding Plan toggle for Z AI provider #8002
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -18,10 +18,20 @@ export class ZAiHandler extends BaseOpenAiCompatibleProvider<InternationalZAiMod | |
| const models = isChina ? mainlandZAiModels : internationalZAiModels | ||
| const defaultModelId = isChina ? mainlandZAiDefaultModelId : internationalZAiDefaultModelId | ||
|
|
||
| // Determine the base URL based on region and GLM Coding Plan toggle | ||
|
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. Consider adding a comment here explaining the endpoint routing logic for future maintainability: |
||
| let baseURL: string | ||
| if (options.zaiUseGlmCodingPlan) { | ||
| // Use coding plan endpoints | ||
| baseURL = isChina ? "https://open.bigmodel.cn/api/coding/paas/v4" : "https://api.z.ai/api/coding/paas/v4" | ||
|
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. The implementation looks clean, but I notice there's no error handling specific to GLM Coding Plan failures. The issue mentions showing "a brief notice explaining the situation" when plan limits are reached. Is this intentional? Should we consider adding a try-catch that could detect plan limit errors and provide user feedback? |
||
| } else { | ||
| // Use standard endpoints | ||
| baseURL = isChina ? "https://open.bigmodel.cn/api/paas/v4" : "https://api.z.ai/api/paas/v4" | ||
| } | ||
|
|
||
| super({ | ||
| ...options, | ||
| providerName: "Z AI", | ||
| baseURL: isChina ? "https://open.bigmodel.cn/api/paas/v4" : "https://api.z.ai/api/paas/v4", | ||
| baseURL, | ||
| apiKey: options.zaiApiKey ?? "not-provided", | ||
| defaultProviderModelId: defaultModelId, | ||
| providerModels: models, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import { useCallback } from "react" | ||
| import { VSCodeTextField, VSCodeDropdown, VSCodeOption } from "@vscode/webview-ui-toolkit/react" | ||
| import { VSCodeTextField, VSCodeDropdown, VSCodeOption, VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react" | ||
|
|
||
| import type { ProviderSettings } from "@roo-code/types" | ||
|
|
||
|
|
@@ -71,6 +71,16 @@ export const ZAi = ({ apiConfiguration, setApiConfigurationField }: ZAiProps) => | |
| </VSCodeButtonLink> | ||
| )} | ||
| </div> | ||
| <div> | ||
| <VSCodeCheckbox | ||
| checked={apiConfiguration?.zaiUseGlmCodingPlan || false} | ||
|
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. Should we validate that the API key is configured before allowing the GLM Coding Plan toggle to be enabled? Users might enable this without having set up their API key first. Consider disabling the checkbox when or showing a warning message. |
||
| onChange={(e: any) => setApiConfigurationField("zaiUseGlmCodingPlan", e.target.checked)}> | ||
| {t("settings:providers.zaiUseGlmCodingPlan")} | ||
| </VSCodeCheckbox> | ||
| <div className="text-xs text-vscode-descriptionForeground mt-1"> | ||
| {t("settings:providers.zaiUseGlmCodingPlanDescription")} | ||
| </div> | ||
| </div> | ||
| </> | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -294,6 +294,8 @@ | |
| "getZaiApiKey": "Get Z AI API Key", | ||
| "zaiEntrypoint": "Z AI Entrypoint", | ||
| "zaiEntrypointDescription": "Please select the appropriate API entrypoint based on your location. If you are in China, choose open.bigmodel.cn. Otherwise, choose api.z.ai.", | ||
| "zaiUseGlmCodingPlan": "Use GLM Coding Plan", | ||
| "zaiUseGlmCodingPlanDescription": "Route requests through GLM Coding Plan endpoints to use your plan instead of API credits. When plan limits are reached, disable this toggle to continue with API credits.", | ||
|
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. Critical issue: You've only added the new translation keys to the English locale. All other 17 supported languages are missing and , which will cause the UI to display missing translation keys for non-English users. Could we add placeholder translations or at least copy the English text to other locales to prevent broken UI? |
||
| "geminiApiKey": "Gemini API Key", | ||
| "getGroqApiKey": "Get Groq API Key", | ||
| "groqApiKey": "Groq API Key", | ||
|
|
||
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.
Good test coverage for the basic functionality! Consider adding edge case tests: