fixes azure

This commit is contained in:
nai-degen 2024-10-01 16:15:04 -05:00
parent 22d7f966c6
commit 514d1b7e31
2 changed files with 10 additions and 2 deletions

View File

@ -43,8 +43,8 @@ const azureOpenaiResponseHandler: ProxyResHandlerWithBody = async (
const azureOpenAIProxy = createQueuedProxyMiddleware({
target: ({ signedRequest }) => {
if (!signedRequest) throw new Error("Must sign request before proxying");
const { hostname, path } = signedRequest;
return `https://${hostname}${path}`;
const { hostname, protocol } = signedRequest;
return `${protocol}//${hostname}`;
},
mutations: [addAzureKey, finalizeSignedRequest],
blockingResponseHandler: azureOpenaiResponseHandler,

View File

@ -68,6 +68,14 @@ export class AzureOpenAIKeyChecker extends KeyCheckerBase<AzureOpenAIKey> {
});
case "429":
const headers = error.response.headers;
const retryAfter = Number(headers["retry-after"] || 0);
if (retryAfter > 3600) {
this.log.warn(
{ key: key.hash, errorType, error: error.response.data, headers },
"Key has an excessive rate limit and will be disabled."
);
return this.updateKey(key.hash, { isDisabled: true });
}
this.log.warn(
{ key: key.hash, errorType, error: error.response.data, headers },
"Key is rate limited. Rechecking key in 1 minute."