feat: Agent 工作区初始提交(源码+文档+Skills)
包含 CodeAgent 前后端源码、SKILLS、MCP、demo 代码与工作区文档。 排除依赖缓存、运行数据、备份与二进制附件,规则见 .gitignore。 Co-Authored-By: Claude Code <[email protected]>
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
"""
|
||||
Pydantic 数据模型 —— 模型配置
|
||||
============================
|
||||
|
||||
【功能说明】模型偏好配置的数据契约,支持前端增删改查。
|
||||
【技术选型理由】Pydantic v2 与 FastAPI 原生集成,与 Project/Task 同构。
|
||||
【安全设计】API key 不入库,只存 provider_key 引用(映射到 .env 里的真实密钥)。
|
||||
【实现思路】ModelConfigCreate 入参 → ModelConfig 实体 → 库表。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class ModelConfigCreate(BaseModel):
|
||||
"""创建模型配置的入参"""
|
||||
|
||||
display_name: str = Field(
|
||||
..., min_length=1, max_length=100, description="显示名称(前端下拉框展示)"
|
||||
)
|
||||
model_id: str = Field(
|
||||
..., min_length=1, max_length=100,
|
||||
description="真实模型 ID(发送给 API 的 model 字段,如 glm-5.3)",
|
||||
)
|
||||
provider_key: str = Field(
|
||||
default="ccswitch",
|
||||
description="Provider 标识(映射到 .env 里的 base_url/api_key):ccswitch | direct",
|
||||
)
|
||||
model_role: str = Field(
|
||||
default="general",
|
||||
description="模型定位:strong=强模型 | weak=弱模型 | general=通用",
|
||||
)
|
||||
is_enabled: bool = Field(default=True, description="是否启用(停用后不出现在下拉框)")
|
||||
sort_order: int = Field(default=0, description="排序值(越小越靠前)")
|
||||
fallback_order: int = Field(
|
||||
default=999,
|
||||
description="降级链顺序(越小越优先,额度用完后按此顺序无缝切换)",
|
||||
)
|
||||
description: str = Field(default="", max_length=200, description="备注说明")
|
||||
|
||||
|
||||
class ModelConfigUpdate(BaseModel):
|
||||
"""更新模型配置(全部字段可选)"""
|
||||
|
||||
display_name: Optional[str] = Field(default=None, min_length=1, max_length=100)
|
||||
model_id: Optional[str] = Field(default=None, min_length=1, max_length=100)
|
||||
provider_key: Optional[str] = None
|
||||
model_role: Optional[str] = None
|
||||
is_enabled: Optional[bool] = None
|
||||
sort_order: Optional[int] = None
|
||||
fallback_order: Optional[int] = None
|
||||
description: Optional[str] = None
|
||||
|
||||
|
||||
class ModelConfig(BaseModel):
|
||||
"""模型配置完整实体"""
|
||||
|
||||
id: str
|
||||
display_name: str
|
||||
model_id: str
|
||||
provider_key: str
|
||||
model_role: str
|
||||
is_enabled: bool
|
||||
sort_order: int
|
||||
fallback_order: int = 999
|
||||
description: str
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
Reference in New Issue
Block a user