mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 17:27:54 +00:00
feat(oauth): add Qwen OAuth integration
This commit is contained in:
@@ -8,6 +8,8 @@ import { AuthType } from '../core/contentGenerator.js';
|
||||
import {
|
||||
isProQuotaExceededError,
|
||||
isGenericQuotaExceededError,
|
||||
isQwenQuotaExceededError,
|
||||
isQwenThrottlingError,
|
||||
} from './quotaErrorDetection.js';
|
||||
|
||||
export interface HttpError extends Error {
|
||||
@@ -150,9 +152,23 @@ export async function retryWithBackoff<T>(
|
||||
}
|
||||
}
|
||||
|
||||
// Track consecutive 429 errors
|
||||
// Check for Qwen OAuth quota exceeded error - throw immediately without retry
|
||||
if (authType === AuthType.QWEN_OAUTH && isQwenQuotaExceededError(error)) {
|
||||
throw new Error(
|
||||
`Qwen API quota exceeded: Your Qwen API quota has been exhausted. Please wait for your quota to reset.`,
|
||||
);
|
||||
}
|
||||
|
||||
// Track consecutive 429 errors, but handle Qwen throttling differently
|
||||
if (errorStatus === 429) {
|
||||
consecutive429Count++;
|
||||
// For Qwen throttling errors, we still want to track them for exponential backoff
|
||||
// but not for quota fallback logic (since Qwen doesn't have model fallback)
|
||||
if (authType === AuthType.QWEN_OAUTH && isQwenThrottlingError(error)) {
|
||||
// Keep track of 429s but reset the consecutive count to avoid fallback logic
|
||||
consecutive429Count = 0;
|
||||
} else {
|
||||
consecutive429Count++;
|
||||
}
|
||||
} else {
|
||||
consecutive429Count = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user