Skip to content

Commit

Permalink
feat: adjust anthropic trial rule
Browse files Browse the repository at this point in the history
  • Loading branch information
takatost committed Oct 19, 2023
1 parent 3399c07 commit 4f45567
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
12 changes: 6 additions & 6 deletions api/core/model_providers/model_provider_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ def _get_preferred_provider(cls, tenant_id: str, model_provider_name: str):
model_provider_rules = ModelProviderFactory.get_provider_rule(model_provider_name)
for quota_type_enum in ProviderQuotaType:
quota_type = quota_type_enum.value
if quota_type in quota_type_to_provider_dict.keys():
provider = quota_type_to_provider_dict[quota_type]
if provider.is_valid and provider.quota_limit > provider.quota_used:
return provider
elif quota_type == ProviderQuotaType.TRIAL.value:
if quota_type in model_provider_rules['system_config']['supported_quota_types']:
if quota_type in model_provider_rules['system_config']['supported_quota_types']:
if quota_type in quota_type_to_provider_dict.keys():
provider = quota_type_to_provider_dict[quota_type]
if provider.is_valid and provider.quota_limit > provider.quota_used:
return provider
elif quota_type == ProviderQuotaType.TRIAL.value:
try:
provider = Provider(
tenant_id=tenant_id,
Expand Down
3 changes: 2 additions & 1 deletion api/core/model_providers/rules/anthropic.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
],
"system_config": {
"supported_quota_types": [
"paid"
"paid",
"trial"
],
"quota_unit": "tokens",
"quota_limit": 0
Expand Down
13 changes: 0 additions & 13 deletions api/services/provider_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,6 @@ def get_provider_list(self, tenant_id: str):
provider_parameter_dict[key]['quota_limit'] = provider.quota_limit
provider_parameter_dict[key]['last_used'] = int(provider.last_used.timestamp()) \
if provider.last_used else None
else:
provider_parameter_dict[key] = {
"provider_name": model_provider_name,
"provider_type": ProviderType.SYSTEM.value,
"config": None,
"is_valid": provider.is_valid,
"quota_type": quota_type,
"quota_unit": model_provider_rule['system_config']['quota_unit'], # need update
"quota_limit": provider.quota_limit,
"quota_used": provider.quota_used,
"last_used": int(provider.last_used.timestamp()) \
if provider.last_used else None
}
elif provider.provider_type == ProviderType.CUSTOM.value \
and ProviderType.CUSTOM.value in provider_parameter_dict:
# if custom
Expand Down

0 comments on commit 4f45567

Please sign in to comment.