From a0bcb5339af025a144045cd622e3b34e236d021a Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Mon, 27 Jan 2025 19:48:08 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E8=87=AA=E5=8A=A8=E5=88=A0=E9=99=A4=20?= =?UTF-8?q?deepseek-r1=20=E6=A8=A1=E5=9E=8B=E8=87=AA=E5=B8=A6=E7=9A=84=20t?= =?UTF-8?q?hink=20=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/provider/sources/openai_source.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/astrbot/core/provider/sources/openai_source.py b/astrbot/core/provider/sources/openai_source.py index b4a4f649c..15931fff5 100644 --- a/astrbot/core/provider/sources/openai_source.py +++ b/astrbot/core/provider/sources/openai_source.py @@ -1,5 +1,6 @@ import base64 import json +import re from openai import AsyncOpenAI, NOT_GIVEN from openai.types.chat.chat_completion import ChatCompletion @@ -128,6 +129,12 @@ class ProviderOpenAIOfficial(Provider): if choice.message.content: # text completion completion_text = str(choice.message.content).strip() + + # ้€‚้… deepseek-r1 ๆจกๅž‹ + if r'' in completion_text: + completion_text = re.sub(r'.*?', '', completion_text).strip() + completion_text = completion_text.replace(r'', '').replace(r'', '').strip() + return LLMResponse("assistant", completion_text) elif choice.message.tool_calls: # tools call (function calling)