mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-04-23 14:19:42 +08:00

Co-authored-by: StyleZhang <jasonapring2015@outlook.com> Co-authored-by: Garfield Dai <dai.hai@foxmail.com> Co-authored-by: chenhe <guchenhe@gmail.com> Co-authored-by: jyong <jyong@dify.ai> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: Yeuoly <admin@srmxy.cn>
68 lines
1.5 KiB
Python
68 lines
1.5 KiB
Python
from enum import Enum
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from core.model_runtime.entities.model_entities import ModelType
|
|
from models.provider import ProviderQuotaType
|
|
|
|
|
|
class QuotaUnit(Enum):
|
|
TIMES = 'times'
|
|
TOKENS = 'tokens'
|
|
|
|
|
|
class SystemConfigurationStatus(Enum):
|
|
"""
|
|
Enum class for system configuration status.
|
|
"""
|
|
ACTIVE = 'active'
|
|
QUOTA_EXCEEDED = 'quota-exceeded'
|
|
UNSUPPORTED = 'unsupported'
|
|
|
|
|
|
class QuotaConfiguration(BaseModel):
|
|
"""
|
|
Model class for provider quota configuration.
|
|
"""
|
|
quota_type: ProviderQuotaType
|
|
quota_unit: QuotaUnit
|
|
quota_limit: int
|
|
quota_used: int
|
|
is_valid: bool
|
|
restrict_llms: list[str] = []
|
|
|
|
|
|
class SystemConfiguration(BaseModel):
|
|
"""
|
|
Model class for provider system configuration.
|
|
"""
|
|
enabled: bool
|
|
current_quota_type: Optional[ProviderQuotaType] = None
|
|
quota_configurations: list[QuotaConfiguration] = []
|
|
credentials: Optional[dict] = None
|
|
|
|
|
|
class CustomProviderConfiguration(BaseModel):
|
|
"""
|
|
Model class for provider custom configuration.
|
|
"""
|
|
credentials: dict
|
|
|
|
|
|
class CustomModelConfiguration(BaseModel):
|
|
"""
|
|
Model class for provider custom model configuration.
|
|
"""
|
|
model: str
|
|
model_type: ModelType
|
|
credentials: dict
|
|
|
|
|
|
class CustomConfiguration(BaseModel):
|
|
"""
|
|
Model class for provider custom configuration.
|
|
"""
|
|
provider: Optional[CustomProviderConfiguration] = None
|
|
models: list[CustomModelConfiguration] = []
|