mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +00:00
fix: 添加异常处理以确保提及格式转换的稳定性
This commit is contained in:
parent
4d768becf5
commit
21ec9188ca
@ -505,8 +505,24 @@ class BotReceiveMsgTask extends AbstractTask
|
||||
}
|
||||
$this->generateSystemPromptForAI($msg->userid, $dialog, $extras);
|
||||
// 转换提及格式
|
||||
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 = <<<EOF
|
||||
<quoted_content>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user