mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-07-09 17:19:02 +00:00
fix(cli): detect USE_OPENAI auth when the model is set via QWEN_MODEL (#5647)
getAuthTypeFromEnv() only accepted OPENAI_MODEL as the model env var for USE_OPENAI, but QWEN_MODEL is an equally valid one: it is listed in AUTH_ENV_MODEL_VARS[USE_OPENAI], documented in the function's own comment, and honored by the model-resolution path. As a result a config that sets OPENAI_API_KEY + QWEN_MODEL + OPENAI_BASE_URL (without OPENAI_MODEL) failed auth detection and returned undefined. Accept either OPENAI_MODEL or QWEN_MODEL, matching the rest of the file. Signed-off-by: Yufeng He <40085740+he-yufeng@users.noreply.github.com>
This commit is contained in:
parent
3fe3561361
commit
9a63d565aa
2 changed files with 12 additions and 1 deletions
|
|
@ -55,6 +55,17 @@ describe('modelConfigUtils', () => {
|
|||
expect(getAuthTypeFromEnv()).toBe(AuthType.USE_OPENAI);
|
||||
});
|
||||
|
||||
it('should return USE_OPENAI when the model is given via QWEN_MODEL', () => {
|
||||
// QWEN_MODEL is a valid USE_OPENAI model var (see AUTH_ENV_MODEL_VARS),
|
||||
// so a config that sets it instead of OPENAI_MODEL must still resolve.
|
||||
process.env['OPENAI_API_KEY'] = 'test-key';
|
||||
process.env['QWEN_MODEL'] = 'qwen3-coder-plus';
|
||||
process.env['OPENAI_BASE_URL'] =
|
||||
'https://dashscope.aliyuncs.com/compatible-mode/v1';
|
||||
|
||||
expect(getAuthTypeFromEnv()).toBe(AuthType.USE_OPENAI);
|
||||
});
|
||||
|
||||
it('should return undefined when OpenAI env vars are incomplete', () => {
|
||||
process.env['OPENAI_API_KEY'] = 'test-key';
|
||||
process.env['OPENAI_MODEL'] = 'gpt-4';
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ export function getAuthTypeFromEnv(): AuthType | undefined {
|
|||
|
||||
if (
|
||||
process.env['OPENAI_API_KEY'] &&
|
||||
process.env['OPENAI_MODEL'] &&
|
||||
(process.env['OPENAI_MODEL'] || process.env['QWEN_MODEL']) &&
|
||||
process.env['OPENAI_BASE_URL']
|
||||
) {
|
||||
return AuthType.USE_OPENAI;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue