1.0.0初始化源代码
This commit is contained in:
64
backend/app/schemas/ai_model.py
Normal file
64
backend/app/schemas/ai_model.py
Normal file
@@ -0,0 +1,64 @@
|
||||
"""
|
||||
AI 模型配置相关 Schema
|
||||
"""
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional, List
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class AIModelConfigBase(BaseModel):
|
||||
"""AI 模型配置基础 Schema"""
|
||||
model_name: str = Field(..., description="模型名称", max_length=100)
|
||||
provider: str = Field(..., description="提供商", max_length=50)
|
||||
display_name: Optional[str] = Field(None, description="显示名称", max_length=200)
|
||||
api_url: str = Field(..., description="API 地址", max_length=500)
|
||||
api_key: str = Field(..., description="API Key", max_length=500)
|
||||
temperature: float = Field(0.7, description="温度", ge=0, le=1)
|
||||
max_tokens: int = Field(1000, description="最大 Token 数", ge=1)
|
||||
|
||||
|
||||
class AIModelConfigCreate(AIModelConfigBase):
|
||||
"""创建 AI 模型配置请求"""
|
||||
description: Optional[str] = Field(None, description="模型描述")
|
||||
|
||||
|
||||
class AIModelConfigUpdate(BaseModel):
|
||||
"""更新 AI 模型配置请求"""
|
||||
display_name: Optional[str] = Field(None, description="显示名称", max_length=200)
|
||||
api_url: Optional[str] = Field(None, description="API 地址", max_length=500)
|
||||
api_key: Optional[str] = Field(None, description="API Key", max_length=500)
|
||||
temperature: Optional[float] = Field(None, description="温度", ge=0, le=1)
|
||||
max_tokens: Optional[int] = Field(None, description="最大 Token 数", ge=1)
|
||||
is_default: Optional[bool] = Field(None, description="是否为默认模型")
|
||||
is_active: Optional[bool] = Field(None, description="是否启用")
|
||||
description: Optional[str] = Field(None, description="模型描述")
|
||||
|
||||
|
||||
class AIModelConfigResponse(AIModelConfigBase):
|
||||
"""AI 模型配置响应"""
|
||||
id: int
|
||||
api_version: Optional[str]
|
||||
top_p: float
|
||||
is_default: bool
|
||||
is_active: bool
|
||||
description: Optional[str]
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class AIModelTestRequest(BaseModel):
|
||||
"""AI 模型测试请求"""
|
||||
model_id: int = Field(..., description="模型 ID")
|
||||
test_prompt: str = Field(..., description="测试提示词", min_length=1, max_length=1000)
|
||||
|
||||
|
||||
class AIModelTestResponse(BaseModel):
|
||||
"""AI 模型测试响应"""
|
||||
success: bool
|
||||
content: Optional[str]
|
||||
tokens_used: int
|
||||
cost_time: float
|
||||
error_message: Optional[str]
|
||||
Reference in New Issue
Block a user