From 21ec9188ca0f5d8a185153d4f7a57813bf99127e Mon Sep 17 00:00:00 2001 From: kuaifan Date: Sat, 20 Sep 2025 17:04:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=A4=84=E7=90=86=E4=BB=A5=E7=A1=AE=E4=BF=9D=E6=8F=90=E5=8F=8A?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E8=BD=AC=E6=8D=A2=E7=9A=84=E7=A8=B3=E5=AE=9A?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Tasks/BotReceiveMsgTask.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/app/Tasks/BotReceiveMsgTask.php b/app/Tasks/BotReceiveMsgTask.php index 04857784f..ad57651f8 100644 --- a/app/Tasks/BotReceiveMsgTask.php +++ b/app/Tasks/BotReceiveMsgTask.php @@ -505,8 +505,24 @@ class BotReceiveMsgTask extends AbstractTask } $this->generateSystemPromptForAI($msg->userid, $dialog, $extras); // 转换提及格式 - $sendText = self::convertMentionForAI($sendText); - $replyText = self::convertMentionForAI($replyText); + try { + $sendText = self::convertMentionForAI($sendText); + $replyText = self::convertMentionForAI($replyText); + } catch (Exception $e) { + // 判断会话在聊天状态中,抛出错误消息 + $stateUrl = "http://nginx/ai/chat_state"; + $data = [ + 'dialog_id' => $dialog->id, + 'dialog_type' => $dialog->type, + 'extras' => Base::array2json($extras) + ]; + $result = Ihttp::ihttp_post($stateUrl, $data, 30); + if ($result['data'] && $data = Base::json2array($result['data'])) { + if ($data['code'] === 200) { + throw $e; + } + } + } if ($replyText) { $sendText = <<