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:
@@ -161,8 +161,6 @@ def create_query_routes(rag, api_key: Optional[str] = None, top_k: int = 60):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
param = request.to_query_params(False)
|
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)
|
response = await rag.aquery(request.query, param=param)
|
||||||
|
|
||||||
# If response is a string (e.g. cache hit), return directly
|
# 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:
|
try:
|
||||||
param = request.to_query_params(True)
|
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)
|
response = await rag.aquery(request.query, param=param)
|
||||||
|
|
||||||
from fastapi.responses import StreamingResponse
|
from fastapi.responses import StreamingResponse
|
||||||
|
Reference in New Issue
Block a user