app/routers/query.py hinzugefügt
All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 3s

This commit is contained in:
Lars 2025-10-07 11:31:26 +02:00
parent 4b5c33bb90
commit c0979b69e2

38
app/routers/query.py Normal file
View File

@ -0,0 +1,38 @@
"""
app/routers/query.py Query-Endpunkte (WP-04)
Zweck:
Stellt POST /query bereit und ruft den passenden Retriever-Modus auf.
Kompatibilität:
Python 3.12+, FastAPI 0.110+
Version:
0.1.0 (Erstanlage)
Stand:
2025-10-07
Bezug:
- app/core/retriever.py
- app/models/dto.py
Nutzung:
app.include_router(query.router, prefix="/query", tags=["query"])
Änderungsverlauf:
0.1.0 (2025-10-07) Erstanlage.
"""
from __future__ import annotations
from fastapi import APIRouter, HTTPException
from app.models.dto import QueryRequest, QueryResponse
from app.core.retriever import hybrid_retrieve, semantic_retrieve
router = APIRouter()
@router.post("", response_model=QueryResponse)
def post_query(req: QueryRequest) -> QueryResponse:
try:
if req.mode == "semantic":
return semantic_retrieve(req)
# default: hybrid
return hybrid_retrieve(req)
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}")