Spaces:
Sleeping
Sleeping
Download api/routes/query.py from Qurrah/replyflow-rag: direct link, hf CLI and curl.
- Browser
- Download file 953 Bytes
-
https://huggingface.co/spaces/Qurrah/replyflow-rag/resolve/main/api/routes/query.py
- Command line
-
hf download hf://spaces/Qurrah/replyflow-rag/api/routes/query.py
-
curl -L -o query.py https://huggingface.co/spaces/Qurrah/replyflow-rag/resolve/main/api/routes/query.py
953 Bytes
| # api/routes/query.py | |
| import logging | |
| from fastapi import APIRouter, Security | |
| from api.schemas import QueryRequest, QueryResponse | |
| from core.config import query_executor | |
| from core.executor import run_blocking | |
| from core.security import verify_api_key | |
| from services.query_service import answer_query_request | |
| logger = logging.getLogger(__name__) | |
| router = APIRouter(tags=["query"]) | |
| async def health(): | |
| return {"status": "ok"} | |
| async def query(req: QueryRequest, _: str = Security(verify_api_key)): | |
| reply = await run_blocking( | |
| query_executor, | |
| answer_query_request, | |
| query=req.query, | |
| channel=req.channel, | |
| channel_identifier=req.channel_identifier, | |
| external_id=req.external_id, | |
| commenter_handle=req.commenter_handle, | |
| post_caption=req.post_caption, | |
| ) | |
| return QueryResponse(answer=reply, query=req.query) |