-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: add qwen-code provider support with complete translations #7364
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 QwenCode provider type definition and models in packages/types/src/providers/qwen-code.ts - Implement OAuth-based provider in src/api/providers/qwen-code.ts with proper error handling - Add comprehensive test coverage in src/api/providers/__tests__/qwen-code.spec.ts - Create QwenCode settings UI component in webview-ui/src/components/settings/providers/QwenCode.tsx - Add qwenCodeOAuthPath field to provider settings schema - Add qwenCode error translations to all backend common.json files (17 languages) - Add qwenCode provider settings to all frontend settings.json files (17 languages) - Include OAuth path configuration and setup instructions for all locales Supported languages: ca, de, es, fr, hi, id, it, ja, ko, nl, pl, pt-BR, ru, tr, vi, zh-CN, zh-TW
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.
Thank you for your contribution! I've reviewed the changes and found several issues that need attention. The implementation looks promising, but there are some critical security and configuration issues that should be addressed before merging.
|
|
||
| const QWEN_OAUTH_BASE_URL = "https://chat.qwen.ai" | ||
| const QWEN_OAUTH_TOKEN_ENDPOINT = `${QWEN_OAUTH_BASE_URL}/api/v1/oauth2/token` | ||
| const QWEN_OAUTH_CLIENT_ID = "f0304373b74a44d2b584a3fb70ca9e56" |
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.
Security concern: The OAuth client ID is hardcoded here. Could we move this to environment variables or a configuration file for better security practices?
| }) | ||
| } | ||
|
|
||
| private async loadCachedQwenCredentials(): Promise<QwenOAuthCredentials> { |
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.
This method doesn't use the qwenCodeOAuthPath option that's defined in the schema and exposed in the UI. Should we check this.options.qwenCodeOAuthPath first before falling back to the default path?
| const credsStr = await fs.readFile(keyFile, "utf-8") | ||
| return JSON.parse(credsStr) | ||
| } catch (error) { | ||
| console.error(`Error reading or parsing credentials file at ${getQwenCachedCredentialPath()}`) |
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 using a proper logging service instead of console.error for production code. Also, the error path should use the configured path if available.
| expiry_date: Date.now() + tokenData.expires_in * 1000, | ||
| } | ||
|
|
||
| const filePath = getQwenCachedCredentialPath() |
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.
When writing back the refreshed credentials, should we also respect the custom OAuth path if configured?
|
|
||
| this.addMaxTokensIfNeeded(requestOptions, modelInfo) | ||
|
|
||
| const stream = await this.callApiWithRetry(() => this.client!.chat.completions.create(requestOptions)) |
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 non-null assertion (!) isn't necessary here since this.client is initialized in the constructor and is never null.
| join: vi.fn((...args) => args.join("/")), | ||
| })) | ||
|
|
||
| describe("QwenCodeHandler", () => { |
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 test coverage seems insufficient. Consider adding tests for:
- OAuth authentication flow
- Token refresh logic
- API call retry on 401 errors
- Error handling scenarios
- The actual
createMessageandcompletePromptmethods
Would you like me to suggest some additional test cases?
| return qwenCodeModels[qwenCodeDefaultModelId] | ||
| } | ||
|
|
||
| export type QwenCodeProvider = { |
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 QwenCodeProvider type includes apiKey and baseUrl fields, but this is an OAuth-based provider that doesn't use API keys. Should these fields be removed to avoid confusion?
|
@roomote-agent address the issues you found except the QWEN_OAUTH_CLIENT_ID we'll leave this to reviewers |
|
Hi @shariqriazz! I've reviewed the PR comments and identified the issues to address. I'll fix all the issues except for the QWEN_OAUTH_CLIENT_ID as requested. Working on the fixes now:
I'll push the changes shortly. |
|
Hi @shariqriazz! I've addressed all the review comments except for QWEN_OAUTH_CLIENT_ID as requested: ✅ Fixed Issues:
📝 Changes Made:
The QWEN_OAUTH_CLIENT_ID has been left as-is per your request for reviewers to handle. |
|
Where are the changes? did u make a new branch again? please make changes in the same branch do not create any new branches |
|
Thank you @shariqriazz. We merged another PR that added this provider. We appreciate your contribution! |
Supported languages: ca, de, es, fr, hi, id, it, ja, ko, nl, pl, pt-BR, ru, tr, vi, zh-CN, zh-TW
Important
Add QwenCode provider support with OAuth authentication, UI integration, and translations in 17 languages.
QwenCodeprovider type definition inqwen-code.ts.qwen-code.tswith error handling.QwenCodeHandlertoindex.tsfor API handling.QwenCodesettings component inQwenCode.tsx.qwenCodeOAuthPathto provider settings schema.qwenCodeerror translations tocommon.jsonin 17 languages.qwenCodeprovider settings tosettings.jsonin 17 languages.QwenCodeHandlerinqwen-code.spec.ts.This description was created by
for 7f52b77. You can customize this summary. It will automatically update as commits are pushed.