mirror of
https://github.com/cita-777/metapi.git
synced 2026-11-01 03:53:43 +08:00
- Updated proxyRetryPolicy to retry on all 4xx and 5xx status codes. - Introduced 'responses' target format in TestChatRequestPayload. - Implemented extractResponsesContent function to handle responses format in ModelTester. - Enhanced ModelTester to support responses target format and display appropriate labels. - Updated ProxyLogs to extract and display upstream paths from error messages. - Added tests to ensure responses target format is preserved during payload sync. - Created responses proxy route to handle requests to the new OpenAI Responses endpoint. - Updated upstreamEndpoint logic to include responses endpoint handling. - Added modelService tests to validate token route rebuilding logic.
28 lines
926 B
TypeScript
28 lines
926 B
TypeScript
const MODEL_UNSUPPORTED_PATTERNS: RegExp[] = [
|
|
/当前\s*api\s*不支持所选模型/i,
|
|
/不支持所选模型/i,
|
|
/不支持.*模型/i,
|
|
/模型.*不支持/i,
|
|
/unsupported\s+model/i,
|
|
/model\s+not\s+supported/i,
|
|
/does\s+not\s+support(?:\s+the)?\s+model/i,
|
|
/model.*does\s+not\s+exist/i,
|
|
/no\s+such\s+model/i,
|
|
/unknown\s+model/i,
|
|
/invalid\s+model/i,
|
|
/model[_\s-]?not[_\s-]?found/i,
|
|
/you\s+do\s+not\s+have\s+access\s+to\s+the\s+model/i,
|
|
];
|
|
|
|
function isModelUnsupportedErrorMessage(rawMessage?: string | null): boolean {
|
|
const text = (rawMessage || '').trim();
|
|
if (!text) return false;
|
|
return MODEL_UNSUPPORTED_PATTERNS.some((pattern) => pattern.test(text));
|
|
}
|
|
|
|
export function shouldRetryProxyRequest(status: number, upstreamErrorText?: string | null): boolean {
|
|
if (status >= 400) return true;
|
|
if (!upstreamErrorText) return false;
|
|
return isModelUnsupportedErrorMessage(upstreamErrorText);
|
|
}
|