mmm jamba

This commit is contained in:
based
2024-10-01 13:43:32 +10:00
parent 672db73977
commit 6f664b9964
2 changed files with 13 additions and 14 deletions
+5 -11
View File
@@ -2,25 +2,19 @@ import APIKey
async def check_ai21(key: APIKey, session):
url = "https://api.ai21.com/studio/v1/j2-light/complete"
url = "https://api.ai21.com/studio/v1/chat/completions"
payload = {
"prompt": "a",
"maxTokens": 1,
"messages": [],
"model": "jamba-1.5-large",
}
headers = {
"accept": "application/json",
"content-type": "application/json",
"Authorization": f"Bearer {key.api_key}"
}
async with session.post(url, json=payload, headers=headers) as response:
if response.status not in [200, 402]:
async with session.post(url, data=payload, headers=headers) as response:
if response.status not in [200, 422]:
return
if response.status == 402: # unsure if this error code also applies to empty keys
key.trial_elapsed = True
return True
+8 -3
View File
@@ -202,6 +202,7 @@ async def execute_with_retries(func, key, sem, retries):
oai_regex = re.compile(r'(sk-[a-zA-Z0-9_-]+T3BlbkFJ[a-zA-Z0-9_-]+)')
anthropic_regex = re.compile(r'sk-ant-api03-[A-Za-z0-9\-_]{93}AA')
anthropic_secondary_regex = re.compile(r'sk-ant-[A-Za-z0-9\-_]{86}')
anthropic_third_regex = re.compile(r'sk-[A-Za-z0-9]{86}')
ai21_and_mistral_regex = re.compile('[A-Za-z0-9]{32}')
elevenlabs_regex = re.compile(r'([a-z0-9]{32})')
elevenlabs_secondary_regex = re.compile(r'sk_[a-z0-9]{48}')
@@ -244,11 +245,15 @@ async def validate_keys():
key_obj = APIKey(Provider.OPENROUTER, key)
tasks.append(execute_with_retries(validate_openrouter, key_obj, concurrent_connections, 5))
elif "sk-" in key:
match = oai_regex.match(key)
anthropic_flag = "T3BlbkFJ" not in key
if anthropic_flag:
match = anthropic_third_regex.match(key)
else:
match = oai_regex.match(key)
if not match:
continue
key_obj = APIKey(Provider.OPENAI, key)
tasks.append(execute_with_retries(validate_openai, key_obj, concurrent_connections, 5))
key_obj = APIKey(Provider.ANTHROPIC if anthropic_flag else Provider.OPENAI, key)
tasks.append(execute_with_retries(validate_anthropic if anthropic_flag else validate_openai, key_obj, concurrent_connections, 5))
elif ":" and "AKIA" in key:
match = aws_regex.match(key)
if not match: