From 699ca3ba008e0fb2b2b5f5c78600c135a3b6f520 Mon Sep 17 00:00:00 2001 From: yangdx Date: Thu, 25 Sep 2025 04:58:57 +0800 Subject: [PATCH] Remove deprecated `history_turns` and `ids` parameters from query API endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Update QueryParam documentation • Mark history_turns as deprecated • Clean up splash screen display • Clarify conversation_history usage --- README-zh.md | 5 +---- README.md | 5 +---- lightrag/api/routers/ollama_api.py | 6 ------ lightrag/api/routers/query_routes.py | 10 ---------- lightrag/api/utils_api.py | 2 -- lightrag/base.py | 4 ++-- lightrag/constants.py | 3 ++- 7 files changed, 6 insertions(+), 29 deletions(-) diff --git a/README-zh.md b/README-zh.md index 9f80b7c0..2ed0b276 100644 --- a/README-zh.md +++ b/README-zh.md @@ -335,15 +335,12 @@ class QueryParam: ll_keywords: list[str] = field(default_factory=list) """List of low-level keywords to refine retrieval focus.""" + # History mesages is only send to LLM for context, not used for retrieval conversation_history: list[dict[str, str]] = field(default_factory=list) """Stores past conversation history to maintain context. Format: [{"role": "user/assistant", "content": "message"}]. """ - # Deprated: history message have negtive effect on query performance - history_turns: int = 0 - """Number of complete conversation turns (user-assistant pairs) to consider in the response context.""" - ids: list[str] | None = None """List of ids to filter the results.""" diff --git a/README.md b/README.md index 7e9315a3..720637de 100644 --- a/README.md +++ b/README.md @@ -336,15 +336,12 @@ class QueryParam: max_total_tokens: int = int(os.getenv("MAX_TOTAL_TOKENS", "30000")) """Maximum total tokens budget for the entire query context (entities + relations + chunks + system prompt).""" + # History mesages is only send to LLM for context, not used for retrieval conversation_history: list[dict[str, str]] = field(default_factory=list) """Stores past conversation history to maintain context. Format: [{"role": "user/assistant", "content": "message"}]. """ - # Deprated: history message have negtive effect on query performance - history_turns: int = 0 - """Number of complete conversation turns (user-assistant pairs) to consider in the response context.""" - ids: list[str] | None = None """List of ids to filter the results.""" diff --git a/lightrag/api/routers/ollama_api.py b/lightrag/api/routers/ollama_api.py index 9ef7c55f..c8cf94a2 100644 --- a/lightrag/api/routers/ollama_api.py +++ b/lightrag/api/routers/ollama_api.py @@ -510,12 +510,6 @@ class OllamaAPI: if user_prompt is not None: param_dict["user_prompt"] = user_prompt - if ( - hasattr(self.rag, "args") - and self.rag.args.history_turns is not None - ): - param_dict["history_turns"] = self.rag.args.history_turns - query_param = QueryParam(**param_dict) if request.stream: diff --git a/lightrag/api/routers/query_routes.py b/lightrag/api/routers/query_routes.py index 821be0b2..c6e050db 100644 --- a/lightrag/api/routers/query_routes.py +++ b/lightrag/api/routers/query_routes.py @@ -78,16 +78,6 @@ class QueryRequest(BaseModel): description="Stores past conversation history to maintain context. Format: [{'role': 'user/assistant', 'content': 'message'}].", ) - history_turns: Optional[int] = Field( - ge=0, - default=None, - description="Number of complete conversation turns (user-assistant pairs) to consider in the response context.", - ) - - ids: list[str] | None = Field( - default=None, description="List of ids to filter the results." - ) - user_prompt: Optional[str] = Field( default=None, description="User-provided prompt for the query. If provided, this will be used instead of the default value from prompt template.", diff --git a/lightrag/api/utils_api.py b/lightrag/api/utils_api.py index 563cc2e4..47751772 100644 --- a/lightrag/api/utils_api.py +++ b/lightrag/api/utils_api.py @@ -218,8 +218,6 @@ def display_splash_screen(args: argparse.Namespace) -> None: ASCIIColors.yellow(f"{args.log_level}") ASCIIColors.white(" ├─ Verbose Debug: ", end="") ASCIIColors.yellow(f"{args.verbose}") - ASCIIColors.white(" ├─ History Turns: ", end="") - ASCIIColors.yellow(f"{args.history_turns}") ASCIIColors.white(" ├─ API Key: ", end="") ASCIIColors.yellow("Set" if args.key else "Not Set") ASCIIColors.white(" └─ JWT Auth: ", end="") diff --git a/lightrag/base.py b/lightrag/base.py index 4ffc9505..0ee64949 100644 --- a/lightrag/base.py +++ b/lightrag/base.py @@ -132,13 +132,13 @@ class QueryParam: ll_keywords: list[str] = field(default_factory=list) """List of low-level keywords to refine retrieval focus.""" - # TODO: Deprecated - history message have negtive effect on query performance + # History mesages is only send to LLM for context, not used for retrieval conversation_history: list[dict[str, str]] = field(default_factory=list) """Stores past conversation history to maintain context. Format: [{"role": "user/assistant", "content": "message"}]. """ - # TODO: Deprecated - history message have negtive effect on query performance + # TODO: deprecated. No longer used in the codebase, all conversation_history messages is send to LLM history_turns: int = int(os.getenv("HISTORY_TURNS", str(DEFAULT_HISTORY_TURNS))) """Number of complete conversation turns (user-assistant pairs) to consider in the response context.""" diff --git a/lightrag/constants.py b/lightrag/constants.py index 2e19d822..14584559 100644 --- a/lightrag/constants.py +++ b/lightrag/constants.py @@ -49,7 +49,8 @@ DEFAULT_MAX_TOTAL_TOKENS = 30000 DEFAULT_COSINE_THRESHOLD = 0.2 DEFAULT_RELATED_CHUNK_NUMBER = 5 DEFAULT_KG_CHUNK_PICK_METHOD = "VECTOR" -# Deprated: history message have negtive effect on query performance + +# TODO: Deprated. All conversation_history messages is send to LLM. DEFAULT_HISTORY_TURNS = 0 # Rerank configuration defaults