mirror of
https://github.com/cunnymessiah/keychecker.git
synced 2026-05-10 18:39:04 -07:00
mmm jamba
This commit is contained in:
@@ -2,25 +2,19 @@ import APIKey
|
|||||||
|
|
||||||
|
|
||||||
async def check_ai21(key: APIKey, session):
|
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 = {
|
payload = {
|
||||||
"prompt": "a",
|
"messages": [],
|
||||||
"maxTokens": 1,
|
"model": "jamba-1.5-large",
|
||||||
}
|
}
|
||||||
headers = {
|
headers = {
|
||||||
"accept": "application/json",
|
|
||||||
"content-type": "application/json",
|
|
||||||
"Authorization": f"Bearer {key.api_key}"
|
"Authorization": f"Bearer {key.api_key}"
|
||||||
}
|
}
|
||||||
|
|
||||||
async with session.post(url, json=payload, headers=headers) as response:
|
async with session.post(url, data=payload, headers=headers) as response:
|
||||||
if response.status not in [200, 402]:
|
if response.status not in [200, 422]:
|
||||||
return
|
return
|
||||||
|
|
||||||
if response.status == 402: # unsure if this error code also applies to empty keys
|
|
||||||
key.trial_elapsed = True
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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_-]+)')
|
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_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_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}')
|
ai21_and_mistral_regex = re.compile('[A-Za-z0-9]{32}')
|
||||||
elevenlabs_regex = re.compile(r'([a-z0-9]{32})')
|
elevenlabs_regex = re.compile(r'([a-z0-9]{32})')
|
||||||
elevenlabs_secondary_regex = re.compile(r'sk_[a-z0-9]{48}')
|
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)
|
key_obj = APIKey(Provider.OPENROUTER, key)
|
||||||
tasks.append(execute_with_retries(validate_openrouter, key_obj, concurrent_connections, 5))
|
tasks.append(execute_with_retries(validate_openrouter, key_obj, concurrent_connections, 5))
|
||||||
elif "sk-" in key:
|
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:
|
if not match:
|
||||||
continue
|
continue
|
||||||
key_obj = APIKey(Provider.OPENAI, key)
|
key_obj = APIKey(Provider.ANTHROPIC if anthropic_flag else Provider.OPENAI, key)
|
||||||
tasks.append(execute_with_retries(validate_openai, key_obj, concurrent_connections, 5))
|
tasks.append(execute_with_retries(validate_anthropic if anthropic_flag else validate_openai, key_obj, concurrent_connections, 5))
|
||||||
elif ":" and "AKIA" in key:
|
elif ":" and "AKIA" in key:
|
||||||
match = aws_regex.match(key)
|
match = aws_regex.match(key)
|
||||||
if not match:
|
if not match:
|
||||||
|
|||||||
Reference in New Issue
Block a user