Merge pull request #2060 from QwenLM/fix/dashscope-subdomain-url-pattern
Some checks are pending
Qwen Code CI / Lint (push) Waiting to run
Qwen Code CI / Test (push) Blocked by required conditions
Qwen Code CI / Test-1 (push) Blocked by required conditions
Qwen Code CI / Test-2 (push) Blocked by required conditions
Qwen Code CI / Test-3 (push) Blocked by required conditions
Qwen Code CI / Test-4 (push) Blocked by required conditions
Qwen Code CI / Test-5 (push) Blocked by required conditions
Qwen Code CI / Test-6 (push) Blocked by required conditions
Qwen Code CI / Test-7 (push) Blocked by required conditions
Qwen Code CI / Test-8 (push) Blocked by required conditions
Qwen Code CI / Post Coverage Comment (push) Blocked by required conditions
Qwen Code CI / CodeQL (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:docker (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:none (push) Waiting to run
E2E Tests / E2E Test - macOS (push) Waiting to run

fix(dashscope): support subdomain URL patterns for DashScope provider detection
This commit is contained in:
tanzhenxin 2026-03-03 20:47:20 +08:00 committed by GitHub
commit 9d8921db5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 11 deletions

View file

@ -159,7 +159,7 @@ export class LoggingContentGenerator implements ContentGenerator {
return response;
} catch (error) {
const durationMs = Date.now() - startTime;
this._logApiError(undefined, durationMs, error, req.model, userPromptId);
this._logApiError('', durationMs, error, req.model, userPromptId);
await this.logOpenAIInteraction(openaiRequest, undefined, error);
throw error;
}
@ -178,7 +178,7 @@ export class LoggingContentGenerator implements ContentGenerator {
stream = await this.wrapped.generateContentStream(req, userPromptId);
} catch (error) {
const durationMs = Date.now() - startTime;
this._logApiError(undefined, durationMs, error, req.model, userPromptId);
this._logApiError('', durationMs, error, req.model, userPromptId);
await this.logOpenAIInteraction(openaiRequest, undefined, error);
throw error;
}
@ -225,7 +225,7 @@ export class LoggingContentGenerator implements ContentGenerator {
} catch (error) {
const durationMs = Date.now() - startTime;
this._logApiError(
undefined,
responses[0]?.responseId ?? '',
durationMs,
error,
responses[0]?.modelVersion || model,

View file

@ -117,6 +117,28 @@ describe('DashScopeOpenAICompatibleProvider', () => {
expect(result).toBe(true);
});
it('should return true for DashScope coding plan URL', () => {
const config = {
authType: AuthType.USE_OPENAI,
baseUrl: 'https://coding.dashscope.aliyuncs.com/v1',
} as ContentGeneratorConfig;
const result =
DashScopeOpenAICompatibleProvider.isDashScopeProvider(config);
expect(result).toBe(true);
});
it('should return true for DashScope international coding plan URL', () => {
const config = {
authType: AuthType.USE_OPENAI,
baseUrl: 'https://coding-intl.dashscope-intl.aliyuncs.com/v1',
} as ContentGeneratorConfig;
const result =
DashScopeOpenAICompatibleProvider.isDashScopeProvider(config);
expect(result).toBe(true);
});
it('should return false for non-DashScope configurations', () => {
const configs = [
{

View file

@ -35,14 +35,13 @@ export class DashScopeOpenAICompatibleProvider
static isDashScopeProvider(
contentGeneratorConfig: ContentGeneratorConfig,
): boolean {
const authType = contentGeneratorConfig.authType;
const baseUrl = contentGeneratorConfig.baseUrl;
return (
authType === AuthType.QWEN_OAUTH ||
baseUrl === 'https://dashscope.aliyuncs.com/compatible-mode/v1' ||
baseUrl === 'https://dashscope-intl.aliyuncs.com/compatible-mode/v1' ||
!baseUrl
);
const { authType, baseUrl } = contentGeneratorConfig;
if (authType === AuthType.QWEN_OAUTH) return true;
if (!baseUrl) return true;
// Matches: dashscope.aliyuncs.com, *.dashscope.aliyuncs.com, or *.dashscope-intl.aliyuncs.com
return /([\w-]+\.)?dashscope(-intl)?\.aliyuncs\.com/i.test(baseUrl);
}
buildHeaders(): Record<string, string | undefined> {