superdup95
commited on
Commit
•
fe74017
1
Parent(s):
93ab703
Update api_usage.py
Browse files- api_usage.py +15 -8
api_usage.py
CHANGED
@@ -570,19 +570,23 @@ def is_model_working(form_info, model_info):
|
|
570 |
entitlementAvai = model_info['entitlementAvailability']
|
571 |
|
572 |
if 'formData' in form_status and agreement_status == 'AVAILABLE' and auth_status == 'AUTHORIZED' and entitlementAvai == 'AVAILABLE':
|
573 |
-
return
|
574 |
-
|
|
|
|
|
575 |
except:
|
576 |
#print(form_status)
|
577 |
-
return
|
578 |
|
579 |
async def get_model_status(session, key, secret, region, model_name, form_info):
|
580 |
model_info = await bedrock_model_available(session, key, secret, region, f"anthropic.{model_name}")
|
581 |
model_status = is_model_working(form_info, model_info)
|
582 |
-
if model_status:
|
583 |
-
return region, model_name
|
|
|
|
|
584 |
else:
|
585 |
-
return None,
|
586 |
|
587 |
async def check_bedrock_claude_status(key, secret):
|
588 |
regions = ['us-east-1', 'us-west-2', 'eu-central-1', 'eu-west-3', 'ap-northeast-1', 'ap-southeast-2'] # currently these regions aren't "gated" nor having only "low context" models
|
@@ -601,10 +605,13 @@ async def check_bedrock_claude_status(key, secret):
|
|
601 |
for model in models:
|
602 |
tasks.append(get_model_status(session, key, secret, region, model, form_info))
|
603 |
results = await asyncio.gather(*tasks)
|
604 |
-
for region, model_name in results:
|
605 |
if region and model_name:
|
606 |
models[model_name].append(region)
|
607 |
-
|
|
|
|
|
|
|
608 |
return models
|
609 |
|
610 |
def check_aws_billing(session):
|
|
|
570 |
entitlementAvai = model_info['entitlementAvailability']
|
571 |
|
572 |
if 'formData' in form_status and agreement_status == 'AVAILABLE' and auth_status == 'AUTHORIZED' and entitlementAvai == 'AVAILABLE':
|
573 |
+
return "Yes"
|
574 |
+
if agreement_status == "ERROR":
|
575 |
+
return model_info['agreementAvailability']['errorMessage']
|
576 |
+
return "No"
|
577 |
except:
|
578 |
#print(form_status)
|
579 |
+
return "No"
|
580 |
|
581 |
async def get_model_status(session, key, secret, region, model_name, form_info):
|
582 |
model_info = await bedrock_model_available(session, key, secret, region, f"anthropic.{model_name}")
|
583 |
model_status = is_model_working(form_info, model_info)
|
584 |
+
if model_status == "Yes":
|
585 |
+
return region, model_name, ""
|
586 |
+
elif model_status == "No":
|
587 |
+
return None, model_name, ""
|
588 |
else:
|
589 |
+
return None, model_name, model_status
|
590 |
|
591 |
async def check_bedrock_claude_status(key, secret):
|
592 |
regions = ['us-east-1', 'us-west-2', 'eu-central-1', 'eu-west-3', 'ap-northeast-1', 'ap-southeast-2'] # currently these regions aren't "gated" nor having only "low context" models
|
|
|
605 |
for model in models:
|
606 |
tasks.append(get_model_status(session, key, secret, region, model, form_info))
|
607 |
results = await asyncio.gather(*tasks)
|
608 |
+
for region, model_name, msg in results:
|
609 |
if region and model_name:
|
610 |
models[model_name].append(region)
|
611 |
+
elif form_info.get('message') == "Operation not allowed" and "Operation not allowed" not in models[model_name]:
|
612 |
+
models[model_name].append('Operation not allowed')
|
613 |
+
elif msg and msg not in models[model_name]:
|
614 |
+
models[model_name].append(msg)
|
615 |
return models
|
616 |
|
617 |
def check_aws_billing(session):
|