add credential-removed to the model list api

This commit is contained in:
hjlarry 2025-08-19 15:22:14 +08:00
parent a7532fdc83
commit 592b2f59d5
4 changed files with 6 additions and 2 deletions

View File

@ -19,6 +19,7 @@ class ModelStatus(Enum):
QUOTA_EXCEEDED = "quota-exceeded"
NO_PERMISSION = "no-permission"
DISABLED = "disabled"
CREDENTIAL_REMOVED = "credential-removed"
class SimpleModelProviderEntity(BaseModel):

View File

@ -1598,6 +1598,9 @@ class ProviderConfiguration(BaseModel):
if len(model_setting.load_balancing_configs) > 1:
load_balancing_enabled = True
if len(model_configuration.available_model_credentials) > 0 and not model_configuration.credentials:
status = ModelStatus.CREDENTIAL_REMOVED
provider_models.append(
ModelWithProviderEntity(
model=custom_model_schema.model,

View File

@ -107,7 +107,7 @@ class CustomModelConfiguration(BaseModel):
model: str
model_type: ModelType
credentials: dict
credentials: dict | None
current_credential_id: Optional[str] = None
available_model_credentials: list[CredentialConfiguration] = []

View File

@ -726,7 +726,7 @@ class ProviderManager:
# Get cached provider model credentials
cached_provider_model_credentials = provider_model_credentials_cache.get()
if not cached_provider_model_credentials:
if not cached_provider_model_credentials and provider_model_record.encrypted_config:
try:
provider_model_credentials = json.loads(provider_model_record.encrypted_config)
except JSONDecodeError: