chore: finalize backend feature scope
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
|
||||
class CaseListItem(BaseModel):
|
||||
"""病例列表项:不暴露标准答案和隐藏信息。"""
|
||||
|
||||
id: int
|
||||
case_code: str
|
||||
department_id: int
|
||||
title: str
|
||||
difficulty: str
|
||||
chief_complaint: str | None = None
|
||||
supported_training_type: str
|
||||
supported_mode: str
|
||||
has_teaching_video: bool
|
||||
has_knowledge_points: bool
|
||||
has_quiz: bool
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class CaseListResponse(BaseModel):
|
||||
"""病例列表响应:返回激活病例集合。"""
|
||||
|
||||
items: list[CaseListItem]
|
||||
|
||||
|
||||
class CasePatientInfo(BaseModel):
|
||||
"""患者展示信息:用于病例详情页。"""
|
||||
|
||||
name: str | None = None
|
||||
age: int | None = None
|
||||
gender: str | None = None
|
||||
occupation: str | None = None
|
||||
|
||||
|
||||
class CaseDetailResponse(BaseModel):
|
||||
"""病例详情响应:展示训练入口需要的信息。"""
|
||||
|
||||
id: int
|
||||
case_code: str
|
||||
title: str
|
||||
department: str
|
||||
difficulty: str
|
||||
patient: CasePatientInfo
|
||||
chief_complaint: str | None = None
|
||||
supported_training_type: str
|
||||
supported_mode: str
|
||||
has_teaching_video: bool
|
||||
has_knowledge_points: bool
|
||||
has_quiz: bool
|
||||
order_item_types: list[str]
|
||||
@@ -79,13 +79,6 @@ class EvaluationListResponse(BaseModel):
|
||||
pagination: PaginationMeta
|
||||
|
||||
|
||||
class ExportPdfResponse(BaseModel):
|
||||
"""PDF 导出响应:返回导出记录和本地文件路径。"""
|
||||
|
||||
export_id: int
|
||||
file_path: str
|
||||
|
||||
|
||||
class EvaluationDetailResponse(EvaluationResponse):
|
||||
"""评价详情响应:在报告详情页使用。"""
|
||||
|
||||
|
||||
@@ -1,10 +1,30 @@
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class LearningAssistantChatRequest(BaseModel):
|
||||
"""学习助手请求:普通用户面向机构知识库提出医学学习问题。"""
|
||||
class LearningAssistantSessionCreateRequest(BaseModel):
|
||||
"""学习助手会话创建请求:进入 AI 学习助手页面时初始化短期问答会话。"""
|
||||
|
||||
question: str = Field(..., min_length=2, max_length=1000, description="用户问题")
|
||||
title: str | None = Field(default=None, max_length=100, description="会话标题,前端可不传")
|
||||
|
||||
|
||||
class LearningAssistantSessionResponse(BaseModel):
|
||||
"""学习助手会话响应:返回前端后续流式问答需要使用的会话 ID。"""
|
||||
|
||||
assistant_session_id: str
|
||||
user_id: str
|
||||
institution_id: int | None = None
|
||||
institution_name: str | None = None
|
||||
title: str
|
||||
status: str
|
||||
created_at: str
|
||||
updated_at: str
|
||||
expires_in_seconds: int
|
||||
|
||||
|
||||
class LearningAssistantChatRequest(BaseModel):
|
||||
"""学习助手问答请求:普通用户面向机构知识库提出医学学习问题。"""
|
||||
|
||||
question: str = Field(..., min_length=1, max_length=1000, description="用户问题")
|
||||
top_k: int | None = Field(default=None, ge=1, le=10, description="最终返回给 LLM 的来源片段数")
|
||||
score_threshold: float | None = Field(default=None, ge=0, le=1, description="向量相似度过滤阈值")
|
||||
|
||||
@@ -20,17 +40,3 @@ class LearningAssistantSource(BaseModel):
|
||||
chunk_uid: str
|
||||
score: float
|
||||
quote: str
|
||||
|
||||
|
||||
class LearningAssistantChatResponse(BaseModel):
|
||||
"""学习助手回答:返回答案、知识库命中状态、循证来源和耗时。"""
|
||||
|
||||
answer: str
|
||||
retrieval_hit: bool
|
||||
sources: list[LearningAssistantSource] = Field(default_factory=list)
|
||||
retrieval_error: str | None = None
|
||||
model: str | None = None
|
||||
embedding_latency_ms: int | None = None
|
||||
search_latency_ms: int | None = None
|
||||
llm_latency_ms: int | None = None
|
||||
total_latency_ms: int | None = None
|
||||
|
||||
+3
-18
@@ -1,4 +1,4 @@
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from app.schemas.training_config import PatientConfig
|
||||
|
||||
@@ -8,16 +8,10 @@ class CreateSessionRequest(BaseModel):
|
||||
|
||||
case_id: int
|
||||
training_type: str = Field(pattern="^(case_analysis|diagnosis_treatment|consultation)$")
|
||||
mode: str = Field(pattern="^(novice|practice|teaching)$")
|
||||
mode: str = Field(pattern="^practice$")
|
||||
score_type: str = Field(default="percentage", pattern="^(percentage|five_point)$")
|
||||
patient_config: PatientConfig | None = None
|
||||
|
||||
@field_validator("mode")
|
||||
@classmethod
|
||||
def normalize_mode(cls, value: str) -> str:
|
||||
"""训练模式:兼容旧 novice 请求,实际按 practice 练习模式处理。"""
|
||||
return "practice" if value == "novice" else value
|
||||
|
||||
|
||||
class CreateSessionResponse(BaseModel):
|
||||
"""创建会话响应:返回会话标识和 AI 病人开场白。"""
|
||||
@@ -35,15 +29,6 @@ class ChatRequest(BaseModel):
|
||||
message: str = Field(min_length=1, max_length=2000)
|
||||
|
||||
|
||||
class ChatResponse(BaseModel):
|
||||
"""问诊消息响应:返回 AI 病人的非流式回复。"""
|
||||
|
||||
reply: str
|
||||
latency_ms: int
|
||||
model: str
|
||||
fallback_used: bool = False
|
||||
|
||||
|
||||
class OrderItemResponse(BaseModel):
|
||||
"""可申请检查项:只返回名称和类型,不返回结果。"""
|
||||
|
||||
@@ -116,7 +101,7 @@ class SubmitTreatmentResponse(BaseModel):
|
||||
|
||||
|
||||
class HintRequest(BaseModel):
|
||||
"""会话提示入参:基于当前会话上下文生成新手模式提醒。"""
|
||||
"""会话提示入参:基于当前会话上下文生成练习提示。"""
|
||||
|
||||
last_user_message: str | None = Field(default=None, max_length=2000)
|
||||
scope: str = Field(default="current_conversation", pattern="^current_conversation$")
|
||||
|
||||
Reference in New Issue
Block a user