91 lines
2.1 KiB
Python
91 lines
2.1 KiB
Python
"""
|
|
报告相关的Pydantic模式
|
|
"""
|
|
|
|
from pydantic import BaseModel, Field
|
|
from typing import List, Optional, Dict, Any
|
|
from datetime import datetime
|
|
from uuid import UUID
|
|
|
|
|
|
class AnalysisModuleSchema(BaseModel):
|
|
"""分析模块模式"""
|
|
id: UUID
|
|
module_type: str
|
|
module_order: int
|
|
title: str
|
|
content: Optional[Dict[str, Any]] = None
|
|
status: str
|
|
started_at: Optional[datetime] = None
|
|
completed_at: Optional[datetime] = None
|
|
error_message: Optional[str] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class ReportBase(BaseModel):
|
|
"""报告基础模式"""
|
|
symbol: str = Field(..., description="证券代码")
|
|
market: str = Field(..., description="交易市场")
|
|
|
|
|
|
class ReportCreate(ReportBase):
|
|
"""创建报告请求模式"""
|
|
pass
|
|
|
|
|
|
class ReportUpdate(BaseModel):
|
|
"""更新报告请求模式"""
|
|
status: Optional[str] = None
|
|
|
|
|
|
class ReportResponse(ReportBase):
|
|
"""报告响应模式"""
|
|
id: UUID
|
|
status: str
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
analysis_modules: List[AnalysisModuleSchema] = []
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class ReportListResponse(BaseModel):
|
|
"""报告列表响应模式"""
|
|
reports: List[ReportResponse]
|
|
total: int
|
|
skip: int
|
|
limit: int
|
|
|
|
|
|
class DeleteReportResponse(BaseModel):
|
|
"""删除报告响应模式"""
|
|
message: str
|
|
report_id: str
|
|
|
|
|
|
class RegenerateRequest(BaseModel):
|
|
"""重新生成报告请求模式"""
|
|
force: bool = Field(False, description="是否强制重新生成")
|
|
|
|
|
|
class AIAnalysisRequest(BaseModel):
|
|
"""AI分析请求模式"""
|
|
symbol: str = Field(..., description="证券代码")
|
|
market: str = Field(..., description="交易市场")
|
|
analysis_type: str = Field(..., description="分析类型")
|
|
context_data: Optional[Dict[str, Any]] = Field(None, description="上下文数据")
|
|
|
|
|
|
class AIAnalysisResponse(BaseModel):
|
|
"""AI分析响应模式"""
|
|
symbol: str
|
|
market: str
|
|
analysis_type: str
|
|
content: Dict[str, Any]
|
|
model_used: str
|
|
generated_at: datetime
|
|
|
|
model_config = {"protected_namespaces": ()} |