-
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
Conversation
- Add zaiUseGlmCodingPlan field to provider settings schema - Update ZAiHandler to route requests through coding plan endpoints when enabled - Add UI toggle in Z AI settings with appropriate labels and descriptions - Add comprehensive tests for the new functionality - Add English translation keys for the new toggle This allows users with a Z AI GLM Coding Plan to use their plan instead of API credits
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.
I reviewed my own code and found 17 missing translations. Classic me.
| "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 comment
The 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?
| 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 comment
The 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?
| 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 comment
The 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:
| </div> | ||
| <div> | ||
| <VSCodeCheckbox | ||
| checked={apiConfiguration?.zaiUseGlmCodingPlan || false} |
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.
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.
| new ZAiHandler({ zaiApiKey: "test-zai-api-key", zaiApiLine: "international", zaiUseGlmCodingPlan: true }) | ||
| expect(OpenAI).toHaveBeenCalledWith( | ||
| expect.objectContaining({ baseURL: "https://api.z.ai/api/coding/paas/v4" }), | ||
| ) |
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:
- What happens when switching regions while GLM Coding Plan is enabled?
- How does it behave with missing API key but toggle enabled?
- Could we test the actual API error responses when plan limits are hit?
|
Closed by #8003 |
This PR attempts to address Issue #8001. Feedback and guidance are welcome.
Summary
Adds a toggle in Settings > Providers > Z AI to enable GLM Coding Plan routing, allowing users with an active plan to use it instead of API credits.
Changes
zaiUseGlmCodingPlanfield to provider settings schemaZAiHandlerto route requests through coding plan endpoints when enabled:https://api.z.ai/api/coding/paas/v4https://open.bigmodel.cn/api/coding/paas/v4Behavior
Testing
Notes
Closes #8001
Important
Adds GLM Coding Plan toggle to Z AI provider settings, updating routing logic, UI, and tests.
zaiUseGlmCodingPlantoggle in Z AI provider settings to route requests through GLM Coding Plan endpoints.zaiUseGlmCodingPlantozaiSchemainprovider-settings.ts.ZAiHandlerinzai.tsto use GLM Coding Plan URLs based on toggle and region.ZAi.tsxwith labels and descriptions.settings.json.zai.spec.tsfor GLM Coding Plan toggle behavior and URL routing.This description was created by
for 5f6f2be. You can customize this summary. It will automatically update as commits are pushed.