deepdata: core product code (backend, frontend, runtime, deepflow module)
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
from .health import HealthResponse
|
||||
from .models import (
|
||||
ModelType,
|
||||
CreateModelRequest,
|
||||
QueryModelRequest,
|
||||
ModelsResponse,
|
||||
ProviderItem,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"HealthResponse",
|
||||
"ModelType",
|
||||
"CreateModelRequest",
|
||||
"QueryModelRequest",
|
||||
"ModelsResponse",
|
||||
"ProviderItem",
|
||||
]
|
||||
@@ -0,0 +1,10 @@
|
||||
from pydantic import Field
|
||||
|
||||
from app.module.shared.schema import BaseResponseModel
|
||||
from app.module.shared.schema import StandardResponse
|
||||
|
||||
class HealthResponse(BaseResponseModel):
|
||||
"""健康检查响应模型"""
|
||||
status: str = Field(..., description="服务状态")
|
||||
service: str = Field(..., description="服务名称")
|
||||
version: str = Field(..., description="应用版本")
|
||||
@@ -0,0 +1,71 @@
|
||||
"""
|
||||
模型配置 DTO:与 Java 版 t_models 接口保持一致。
|
||||
"""
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class ModelType(str, Enum):
|
||||
"""模型类型枚举,与 Java ModelType 一致。"""
|
||||
CHAT = "CHAT"
|
||||
EMBEDDING = "EMBEDDING"
|
||||
|
||||
|
||||
# --- 请求 DTO ---
|
||||
|
||||
|
||||
class CreateModelRequest(BaseModel):
|
||||
"""创建/更新模型配置请求,与 Java CreateModelRequest 一致。"""
|
||||
model_config = ConfigDict(str_strip_whitespace=True, extra="forbid")
|
||||
|
||||
modelName: str = Field(..., min_length=1, description="模型名称(如 qwen2)")
|
||||
provider: str = Field(..., min_length=1, description="模型提供商(如 Ollama、OpenAI、DeepSeek)")
|
||||
baseUrl: str = Field(..., min_length=1, description="API 基础地址")
|
||||
apiKey: Optional[str] = Field(None, description="API 密钥(无密钥则为空)")
|
||||
type: ModelType = Field(..., description="模型类型(如 chat、embedding)")
|
||||
isEnabled: Optional[bool] = Field(None, description="是否启用:1-启用,0-禁用")
|
||||
isDefault: Optional[bool] = Field(None, description="是否默认:1-默认,0-非默认")
|
||||
|
||||
|
||||
class QueryModelRequest(BaseModel):
|
||||
"""模型查询请求,与 Java QueryModelRequest + PagingQuery 一致。page 从 0 开始,size 默认 20。"""
|
||||
model_config = ConfigDict(str_strip_whitespace=True, extra="forbid")
|
||||
|
||||
page: int = Field(0, ge=0, description="页码,从 0 开始")
|
||||
size: int = Field(20, gt=0, le=2000, description="每页大小")
|
||||
provider: Optional[str] = Field(None, description="模型提供商")
|
||||
type: Optional[ModelType] = Field(None, description="模型类型")
|
||||
isEnabled: Optional[bool] = Field(None, description="是否启用")
|
||||
isDefault: Optional[bool] = Field(None, description="是否默认")
|
||||
|
||||
|
||||
# --- 响应 DTO ---
|
||||
|
||||
|
||||
class ModelsResponse(BaseModel):
|
||||
"""模型配置响应,与 Java Models 实体字段一致。"""
|
||||
model_config = ConfigDict(str_strip_whitespace=True, extra="forbid")
|
||||
|
||||
id: str
|
||||
modelName: str
|
||||
provider: str
|
||||
baseUrl: str
|
||||
apiKey: str = ""
|
||||
type: str # "CHAT" | "EMBEDDING"
|
||||
isEnabled: bool = True
|
||||
isDefault: bool = False
|
||||
createdAt: Optional[datetime] = None
|
||||
updatedAt: Optional[datetime] = None
|
||||
createdBy: Optional[str] = None
|
||||
updatedBy: Optional[str] = None
|
||||
|
||||
|
||||
class ProviderItem(BaseModel):
|
||||
"""厂商项,仅含 provider、baseUrl,与 Java getProviders() 返回结构一致。"""
|
||||
model_config = ConfigDict(str_strip_whitespace=True, extra="forbid")
|
||||
|
||||
provider: str
|
||||
baseUrl: str
|
||||
@@ -0,0 +1,51 @@
|
||||
"""
|
||||
System Parameter DTOs
|
||||
系统参数数据传输对象
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from app.module.shared.schema import BaseResponseModel
|
||||
|
||||
|
||||
class SysParamDto(BaseResponseModel):
|
||||
"""系统参数 DTO"""
|
||||
|
||||
id: str = Field(..., description="参数ID")
|
||||
param_value: str = Field(..., description="参数值")
|
||||
param_type: str = Field(
|
||||
default="string", description="参数类型(string、integer、boolean)"
|
||||
)
|
||||
option_list: Optional[str] = Field(None, description="选项列表(JSON格式)")
|
||||
description: Optional[str] = Field(None, description="参数描述")
|
||||
is_built_in: bool = Field(default=False, description="是否内置")
|
||||
can_modify: bool = Field(default=True, description="是否可修改")
|
||||
is_enabled: bool = Field(default=True, description="是否启用")
|
||||
created_at: Optional[datetime] = Field(None, description="创建时间")
|
||||
updated_at: Optional[datetime] = Field(None, description="更新时间")
|
||||
created_by: Optional[str] = Field(None, description="创建者")
|
||||
updated_by: Optional[str] = Field(None, description="更新者")
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class UpdateParamValueRequest(BaseResponseModel):
|
||||
"""更新参数值请求"""
|
||||
|
||||
param_value: str = Field(..., description="参数值")
|
||||
|
||||
|
||||
class CreateSysParamRequest(BaseResponseModel):
|
||||
"""创建系统参数请求"""
|
||||
|
||||
id: str = Field(..., description="参数ID")
|
||||
param_value: str = Field(..., description="参数值")
|
||||
param_type: str = Field(default="string", description="参数类型")
|
||||
option_list: Optional[str] = Field(None, description="选项列表(JSON格式)")
|
||||
description: Optional[str] = Field(None, description="参数描述")
|
||||
is_built_in: bool = Field(default=False, description="是否内置")
|
||||
can_modify: bool = Field(default=True, description="是否可修改")
|
||||
is_enabled: bool = Field(default=True, description="是否启用")
|
||||
Reference in New Issue
Block a user