63 lines
1.5 KiB
Python
63 lines
1.5 KiB
Python
"""AI模型配置Schema"""
|
||
from pydantic import BaseModel
|
||
from datetime import datetime
|
||
from typing import Optional, List
|
||
|
||
|
||
class AIModelCreate(BaseModel):
|
||
provider: str
|
||
provider_name: str = ""
|
||
model_id: str
|
||
model_name: str = ""
|
||
api_key: str = ""
|
||
base_url: str = ""
|
||
task_type: str = ""
|
||
is_enabled: bool = True
|
||
is_default: bool = False
|
||
web_search_enabled: bool = False
|
||
web_search_count: int = 5 # 联网搜索结果条数,1-50
|
||
description: str = ""
|
||
|
||
|
||
class AIModelUpdate(BaseModel):
|
||
provider_name: Optional[str] = None
|
||
model_id: Optional[str] = None
|
||
model_name: Optional[str] = None
|
||
api_key: Optional[str] = None
|
||
base_url: Optional[str] = None
|
||
task_type: Optional[str] = None
|
||
is_enabled: Optional[bool] = None
|
||
is_default: Optional[bool] = None
|
||
web_search_enabled: Optional[bool] = None
|
||
web_search_count: Optional[int] = None
|
||
description: Optional[str] = None
|
||
|
||
|
||
class AIModelResponse(BaseModel):
|
||
id: int
|
||
provider: str
|
||
provider_name: str = ""
|
||
model_id: str
|
||
model_name: str = ""
|
||
api_key_masked: str = "" # 脱敏后的API Key
|
||
base_url: str = ""
|
||
task_type: str = ""
|
||
is_enabled: bool = True
|
||
is_default: bool = False
|
||
web_search_enabled: bool = False
|
||
web_search_count: int = 5
|
||
description: str = ""
|
||
created_at: datetime
|
||
updated_at: datetime
|
||
|
||
class Config:
|
||
from_attributes = True
|
||
|
||
|
||
class ProviderInfo(BaseModel):
|
||
"""服务商信息"""
|
||
provider: str
|
||
name: str
|
||
models: List[dict]
|
||
default_base_url: str = ""
|