From 13bc171e9dd4d18cb7e1831ce9bc41608df257d4 Mon Sep 17 00:00:00 2001 From: fuzhongyun <15339891972@163.com> Date: Thu, 15 Jan 2026 18:13:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=201.=E6=96=B0=E5=A2=9Ethink=E5=8F=82?= =?UTF-8?q?=E6=95=B0=202.=E7=A7=BB=E9=99=A4enable=5Fcot=E6=84=8F=E5=A4=96?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/routes.py | 2 ++ app/core/rag.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/api/routes.py b/app/api/routes.py index d221903..cba5952 100644 --- a/app/api/routes.py +++ b/app/api/routes.py @@ -34,6 +34,7 @@ class QueryRequest(BaseModel): mode: str = "hybrid" # 可选: naive, local, global, hybrid top_k: int = 5 stream: bool = False + think: bool = False class IngestResponse(BaseModel): filename: str @@ -111,6 +112,7 @@ async def query_knowledge_base( request.query, system_prompt=sys_prompt, stream=True, + think=request.think, hashing_kv=rag.llm_response_cache ) diff --git a/app/core/rag.py b/app/core/rag.py index 8968f46..9581cd6 100644 --- a/app/core/rag.py +++ b/app/core/rag.py @@ -19,11 +19,13 @@ async def llm_func(prompt, system_prompt=None, history_messages=[], **kwargs) -> # 移除可能存在的 model 参数,避免冲突 kwargs.pop('model', None) kwargs.pop('hashing_kv', None) + kwargs.pop('enable_cot', None) # 移除不支持的参数 keyword_extraction = kwargs.pop("keyword_extraction", False) if keyword_extraction: kwargs["format"] = "json" stream = kwargs.pop("stream", False) + think = kwargs.pop("think", False) # Debug: 检查流式参数 if stream: logging.info("LLM called with stream=True") @@ -40,7 +42,7 @@ async def llm_func(prompt, system_prompt=None, history_messages=[], **kwargs) -> if stream: async def inner(): # 使用 **kwargs 透传参数,确保 format 等顶级参数生效 - response = await client.chat(model=settings.LLM_MODEL, messages=messages, stream=True, **kwargs) + response = await client.chat(model=settings.LLM_MODEL, messages=messages, stream=True, think=think, **kwargs) async for chunk in response: msg = chunk.get("message", {})