add training configuration APIs
This commit is contained in:
+2
-1
@@ -1,11 +1,12 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
from app.api import agent, auth, cases, evaluations, knowledge, llm_test, sessions
|
||||
from app.api import agent, auth, cases, evaluations, knowledge, llm_test, sessions, training_config
|
||||
|
||||
api_router = APIRouter()
|
||||
api_router.include_router(agent.router, tags=["agent"])
|
||||
api_router.include_router(auth.router, prefix="/auth", tags=["auth"])
|
||||
api_router.include_router(cases.router, prefix="/cases", tags=["cases"])
|
||||
api_router.include_router(training_config.router, prefix="/training-config", tags=["training-config"])
|
||||
api_router.include_router(sessions.router, prefix="/sessions", tags=["sessions"])
|
||||
api_router.include_router(evaluations.router, prefix="/evaluations", tags=["evaluations"])
|
||||
api_router.include_router(knowledge.router, prefix="/knowledge", tags=["knowledge"])
|
||||
|
||||
@@ -123,6 +123,73 @@ async def generate_hints(
|
||||
return ok(result)
|
||||
|
||||
|
||||
@router.post("/{session_id}/hints/stream", response_class=StreamingResponse)
|
||||
async def stream_hints(
|
||||
session_id: int,
|
||||
payload: HintRequest,
|
||||
ctx: UserContext = Depends(get_user_context),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""流式练习提示:返回一句话形式的 SSE 提示。"""
|
||||
response = await SessionService(db).stream_hints(ctx, session_id, payload)
|
||||
db.commit()
|
||||
return StreamingResponse(
|
||||
response,
|
||||
media_type="text/event-stream",
|
||||
headers={
|
||||
"Cache-Control": "no-cache",
|
||||
"Connection": "keep-alive",
|
||||
"X-Accel-Buffering": "no",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@router.get("/{session_id}/physical-exams", response_model=ApiResponse[OrderItemsResponse])
|
||||
def list_physical_exam_items(
|
||||
session_id: int,
|
||||
ctx: UserContext = Depends(get_user_context),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""体格检查列表:返回当前病例可申请的体格检查项目。"""
|
||||
return ok(OrderService(db).list_physical_exam_items(session_id, ctx.user_id))
|
||||
|
||||
|
||||
@router.get("/{session_id}/auxiliary-exams", response_model=ApiResponse[OrderItemsResponse])
|
||||
def list_auxiliary_exam_items(
|
||||
session_id: int,
|
||||
ctx: UserContext = Depends(get_user_context),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""辅助检查列表:返回当前病例可申请的辅助检查项目。"""
|
||||
return ok(OrderService(db).list_auxiliary_exam_items(session_id, ctx.user_id))
|
||||
|
||||
|
||||
@router.post("/{session_id}/physical-exams/{item_code}", response_model=ApiResponse[CreateOrderResponse])
|
||||
def create_physical_exam_order(
|
||||
session_id: int,
|
||||
item_code: str,
|
||||
ctx: UserContext = Depends(get_user_context),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""体格检查结果:按项目编码返回数据库固定结果。"""
|
||||
result = OrderService(db).create_physical_exam_order(session_id, ctx.user_id, item_code)
|
||||
db.commit()
|
||||
return ok(result)
|
||||
|
||||
|
||||
@router.post("/{session_id}/auxiliary-exams/{item_code}", response_model=ApiResponse[CreateOrderResponse])
|
||||
def create_auxiliary_exam_order(
|
||||
session_id: int,
|
||||
item_code: str,
|
||||
ctx: UserContext = Depends(get_user_context),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""辅助检查结果:按项目编码返回数据库固定结果。"""
|
||||
result = OrderService(db).create_auxiliary_exam_order(session_id, ctx.user_id, item_code)
|
||||
db.commit()
|
||||
return ok(result)
|
||||
|
||||
|
||||
@router.post("/{session_id}/diagnosis", response_model=ApiResponse[SubmitDiagnosisResponse])
|
||||
def submit_diagnosis(
|
||||
session_id: int,
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
from fastapi import APIRouter, Depends, Query
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.response import ApiResponse, ok
|
||||
from app.core.user_context import UserContext, get_user_context
|
||||
from app.db.session import get_db
|
||||
from app.schemas.training_config import TrainingConfigOptionsResponse, TrainingConfigRecommendedResponse
|
||||
from app.services.training_config_service import TrainingConfigService
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/recommended", response_model=ApiResponse[TrainingConfigRecommendedResponse])
|
||||
def get_recommended_training_config(
|
||||
case_id: int = Query(..., ge=1),
|
||||
_: UserContext = Depends(get_user_context),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""推荐配置信息:返回训练页默认病人初始化配置。"""
|
||||
return ok(TrainingConfigService(db).get_recommended(case_id))
|
||||
|
||||
|
||||
@router.get("/options", response_model=ApiResponse[TrainingConfigOptionsResponse])
|
||||
def get_training_config_options(
|
||||
case_id: int = Query(..., ge=1),
|
||||
_: UserContext = Depends(get_user_context),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""训练配置信息:返回训练页自定义病人初始化配置选项。"""
|
||||
return ok(TrainingConfigService(db).get_options(case_id))
|
||||
Reference in New Issue
Block a user