bug fixes

This commit is contained in:
based
2024-01-24 07:07:55 +10:00
parent 333a519a2e
commit b3416a6e49
2 changed files with 13 additions and 11 deletions
+11 -9
View File
@@ -55,16 +55,18 @@ async def get_oai_key_tier(key: APIKey, session):
if key.trial:
return 'Free'
tts_object = {"model": "tts-1-hd", "input": "", "voice": "alloy"}
async with session.post(f'{oai_api_url}/audio/speech',
headers={'Authorization': f'Bearer {key.api_key}', 'accept': 'application/json'},
json=tts_object) as response:
if response.status in [400, 429]:
try:
return oai_tiers[int(response.headers.get("x-ratelimit-limit-requests"))]
except KeyError:
for _ in range(3): # we'll give it 3 shots if oai decides to shid itself.
async with session.post(f'{oai_api_url}/audio/speech',
headers={'Authorization': f'Bearer {key.api_key}', 'accept': 'application/json'},
json=tts_object) as response:
if response.status in [400, 429]:
try:
return oai_tiers[int(response.headers.get("x-ratelimit-limit-requests"))]
except (KeyError, TypeError, ValueError):
continue
else:
return
else:
return
return
async def get_oai_org(key: APIKey, session):
+2 -2
View File
@@ -93,7 +93,7 @@ async def validate_makersuite(key: APIKey, sem):
api_keys.add(key)
async def validate_aws(key: APIKey):
def validate_aws(key: APIKey):
if check_aws(key) is None:
return
api_keys.add(key)
@@ -106,7 +106,7 @@ async def validate_azure(key: APIKey, sem):
api_keys.add(key)
async def validate_vertexai(key: APIKey):
def validate_vertexai(key: APIKey):
if check_vertexai(key) is None:
return
api_keys.add(key)