From dcf2b7c1ff5074a0ec41d279feb4305fd5f6be18 Mon Sep 17 00:00:00 2001 From: Charlie Wang Date: Fri, 21 Mar 2025 16:17:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=80=9D=E8=80=83?= =?UTF-8?q?=E8=BF=87=E7=A8=8B=E6=9C=AA=E8=83=BD=E5=A6=A5=E5=BD=93=E5=A4=84?= =?UTF-8?q?=E7=90=86(=E8=87=B3=E5=B0=91=E5=9C=A8=E7=81=AB=E5=B1=B1?= =?UTF-8?q?=E4=B8=8A=E6=98=AF=E8=BF=99=E6=A0=B7)=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/models/utils_model.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/models/utils_model.py b/src/plugins/models/utils_model.py index d915b3759..c8b358a4f 100644 --- a/src/plugins/models/utils_model.py +++ b/src/plugins/models/utils_model.py @@ -274,6 +274,7 @@ class LLM_request: raise RuntimeError(f"请求被拒绝: {error_code_mapping.get(response.status)}") response.raise_for_status() + reasoning_content = "" # 将流式输出转化为非流式输出 if stream_mode: @@ -303,6 +304,8 @@ class LLM_request: accumulated_content += delta_content # 检测流式输出文本是否结束 finish_reason = chunk["choices"][0].get("finish_reason") + if delta.get("reasoning_content", None): + reasoning_content += delta["reasoning_content"] if finish_reason == "stop": chunk_usage = chunk.get("usage", None) if chunk_usage: @@ -314,7 +317,6 @@ class LLM_request: except Exception as e: logger.exception(f"解析流式输出错误: {str(e)}") content = accumulated_content - reasoning_content = "" think_match = re.search(r"(.*?)", content, re.DOTALL) if think_match: reasoning_content = think_match.group(1).strip()