All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 4s
34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
"""
|
|
FILE: app/routers/query.py
|
|
DESCRIPTION: Klassische Such-Endpunkte (Semantic & Hybrid). Initiiert asynchrones Feedback-Logging und ruft den richtigen Retriever Modus auf
|
|
VERSION: 0.2.0
|
|
STATUS: Active
|
|
DEPENDENCIES: app.models.dto, app.core.retriever, app.services.feedback_service
|
|
LAST_ANALYSIS: 2025-12-15
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
from fastapi import APIRouter, HTTPException, BackgroundTasks
|
|
from app.models.dto import QueryRequest, QueryResponse
|
|
from app.core.retrieval.retriever import hybrid_retrieve, semantic_retrieve
|
|
# NEU:
|
|
from app.services.feedback_service import log_search
|
|
|
|
router = APIRouter()
|
|
|
|
@router.post("", response_model=QueryResponse)
|
|
def post_query(req: QueryRequest, background_tasks: BackgroundTasks) -> QueryResponse:
|
|
try:
|
|
if req.mode == "semantic":
|
|
res = semantic_retrieve(req)
|
|
else:
|
|
res = hybrid_retrieve(req)
|
|
|
|
# WP-04c: Logging im Hintergrund (bremst Antwort nicht)
|
|
background_tasks.add_task(log_search, req, res)
|
|
|
|
return res
|
|
except ValueError as e:
|
|
raise HTTPException(status_code=400, detail=str(e))
|
|
except Exception as e:
|
|
raise HTTPException(status_code=500, detail=f"query failed: {e}") |