From 9ba12a4f3128728e400f43bd4f5d4c63edcde09e Mon Sep 17 00:00:00 2001 From: yangdx Date: Fri, 21 Feb 2025 18:53:43 +0800 Subject: [PATCH] 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 --- lightrag/api/routers/query_routes.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lightrag/api/routers/query_routes.py b/lightrag/api/routers/query_routes.py index b86c170e..10bfe7a8 100644 --- a/lightrag/api/routers/query_routes.py +++ b/lightrag/api/routers/query_routes.py @@ -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