refactor: remove redundant top_k checks in query routes

The top_k parameter already has a default value set in the QueryParam class (base.py), making these checks unnecessary. This change simplifies the code while maintaining the same functionality.

Changes:

Remove top_k check in query_text function
Remove top_k check in query_text_stream function
This commit is contained in:
yangdx
2025-02-21 18:53:43 +08:00
parent e8efcc335d
commit 9ba12a4f31

View File

@@ -161,8 +161,6 @@ def create_query_routes(rag, api_key: Optional[str] = None, top_k: int = 60):
"""
try:
param = request.to_query_params(False)
if param.top_k is None:
param.top_k = top_k
response = await rag.aquery(request.query, param=param)
# If response is a string (e.g. cache hit), return directly
@@ -192,8 +190,6 @@ def create_query_routes(rag, api_key: Optional[str] = None, top_k: int = 60):
"""
try:
param = request.to_query_params(True)
if param.top_k is None:
param.top_k = top_k
response = await rag.aquery(request.query, param=param)
from fastapi.responses import StreamingResponse