diff --git a/app/api/search.py b/app/api/search.py index b781986..023ffc9 100644 --- a/app/api/search.py +++ b/app/api/search.py @@ -647,6 +647,39 @@ async def ask( - 일반 client 의 X-Source=eval 시도는 무시되고 source='document_server' 로 강제. - source != 'eval' 이면 eval_case_id 항상 None. """ + # 오케스트레이션은 _run_ask 로 분리(라우터=입력+deps 해소만). 동작 무변경 (refactor: ask-orchestrator). + return await _run_ask( + q=q, + user=user, + session=session, + background_tasks=background_tasks, + limit=limit, + debug=debug, + backend=backend, + corpus_variant=corpus_variant, + exact_knn=exact_knn, + x_source=x_source, + x_eval_case_id=x_eval_case_id, + x_eval_token=x_eval_token, + ) + + +async def _run_ask( + q: str, + user: User, + session: AsyncSession, + background_tasks: BackgroundTasks, + limit: int, + debug: bool, + backend: str | None, + corpus_variant: str | None, + exact_knn: bool, + x_source: str | None, + x_eval_case_id: str | None, + x_eval_token: str | None, +) -> "AskResponse | JSONResponse": + """/ask 오케스트레이션 — 검색→evidence/classifier→refusal→synthesis→grounding/verifier→ + 7-tier 재게이트→telemetry. ask() 가 FastAPI deps 해소 후 호출. 동작은 기존 핸들러와 동일.""" t_total = time.perf_counter() defense_log: dict = {} # per-layer flag snapshot source, eval_case_id = _resolve_eval_identity(x_source, x_eval_case_id, x_eval_token)