fix http log message order for streaming respond

- Move aquery_llm call outside generator
- Execute query before stream starts
This commit is contained in:
yangdx 2025-09-26 19:27:44 +08:00
parent 8cd4139cbf
commit 3ba06478a8

View file

@ -218,9 +218,10 @@ def create_query_routes(rag, api_key: Optional[str] = None, top_k: int = 60):
from fastapi.responses import StreamingResponse
# Unified approach: always use aquery_llm for all cases
result = await rag.aquery_llm(request.query, param=param)
async def stream_generator():
# Unified approach: always use aquery_llm for all cases
result = await rag.aquery_llm(request.query, param=param)
# Extract references and LLM response from unified result
references = result.get("data", {}).get("references", [])