RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Fix: support vLLM's new reasoning field (#13493)
Yongteng Lei3c80a0ae0965
diff --git a/rag/llm/chat_model.py b/rag/llm/chat_model.pyindex 10b2fb5155..4476ccbbde 100644--- a/rag/llm/chat_model.py+++ b/rag/llm/chat_model.py@@ -149,12 +149,13 @@ class Base(ABC):continueif not resp.choices[0].delta.content:resp.choices[0].delta.content = ""- if kwargs.get("with_reasoning", True) and hasattr(resp.choices[0].delta, "reasoning_content") and resp.choices[0].delta.reasoning_content:+ _reasoning = getattr(resp.choices[0].delta, "reasoning_content", None) or getattr(resp.choices[0].delta, "reasoning", None)+ if kwargs.get("with_reasoning", True) and _reasoning:ans = ""if not reasoning_start:reasoning_start = Trueans = "<think>"- ans += resp.choices[0].delta.reasoning_content + "</think>"+ ans += _reasoning + "</think>"else:reasoning_start = Falseans = resp.choices[0].delta.content@@ -294,8 +295,9 @@ class Base(ABC):raise Exception(f"500 response structure error. Response: {response}")if not hasattr(response.choices[0].message, "tool_calls") or not response.choices[0].message.tool_calls:- if hasattr(response.choices[0].message, "reasoning_content") and response.choices[0].message.reasoning_content:- ans += "<think>" + response.choices[0].message.reasoning_content + "</think>"+ _reasoning = getattr(response.choices[0].message, "reasoning_content", None) or getattr(response.choices[0].message, "reasoning", None)+ if _reasoning:+ ans += "<think>" + _reasoning + "</think>"ans += response.choices[0].message.contentif response.choices[0].finish_reason == "length":@@ -370,12 +372,13 @@ class Base(ABC):if not hasattr(delta, "content") or delta.content is None:delta.content = ""- if hasattr(delta, "reasoning_content") and delta.reasoning_content:+ _reasoning = getattr(delta, "reasoning_content", None) or getattr(delta, "reasoning", None)+ if _reasoning:ans = ""if not reasoning_start:reasoning_start = Trueans = "<think>"- ans += delta.reasoning_content + "</think>"+ ans += _reasoning + "</think>"yield anselse:reasoning_start = False@@ -1279,12 +1282,13 @@ class LiteLLMBase(ABC):if not hasattr(delta, "content") or delta.content is None:delta.content = ""- if kwargs.get("with_reasoning", True) and hasattr(delta, "reasoning_content") and delta.reasoning_content:+ _reasoning = getattr(delta, "reasoning_content", None) or getattr(delta, "reasoning", None)+ if kwargs.get("with_reasoning", True) and _reasoning:ans = ""if not reasoning_start:reasoning_start = Trueans = "<think>"- ans += delta.reasoning_content + "</think>"+ ans += _reasoning + "</think>"else:reasoning_start = Falseans = delta.content@@ -1404,8 +1408,9 @@ class LiteLLMBase(ABC):message = response.choices[0].messageif not hasattr(message, "tool_calls") or not message.tool_calls:- if hasattr(message, "reasoning_content") and message.reasoning_content:- ans += f"<think>{message.reasoning_content}</think>"+ _reasoning = getattr(message, "reasoning_content", None) or getattr(message, "reasoning", None)+ if _reasoning:+ ans += f"<think>{_reasoning}</think>"ans += message.content or ""if response.choices[0].finish_reason == "length":ans = self._length_stop(ans)@@ -1485,12 +1490,13 @@ class LiteLLMBase(ABC):if not hasattr(delta, "content") or delta.content is None:delta.content = ""- if hasattr(delta, "reasoning_content") and delta.reasoning_content:+ _reasoning = getattr(delta, "reasoning_content", None) or getattr(delta, "reasoning", None)+ if _reasoning:ans = ""if not reasoning_start:reasoning_start = Trueans = "<think>"- ans += delta.reasoning_content + "</think>"+ ans += _reasoning + "</think>"yield anselse:reasoning_start = False