feat: 添加额外数据处理,优化AI助手消息生成与发送逻辑

This commit is contained in:
kuaifan
2025-11-07 20:38:06 +00:00
parent e801c09c0f
commit 892ad395a7
8 changed files with 228 additions and 157 deletions

View File

@@ -66,7 +66,7 @@ class BotReceiveMsgTask extends AbstractTask
}
// 判断消息是否存在
$msg = WebSocketDialogMsg::with(['user'])->find($this->msgId);
$msg = WebSocketDialogMsg::with(['user', 'extra'])->find($this->msgId);
if (empty($msg)) {
return;
}
@@ -523,6 +523,16 @@ class BotReceiveMsgTask extends AbstractTask
{$sendText}
EOF;
}
// 处理额外数据
if ($msg->extra && $msg->extra->data) {
$extraData = $msg->extra->data;
if ($extraData['system_prompt']) {
$extras['system_message'] = $extraData['system_prompt'];
}
if ($extraData['context_prompt']) {
$sendText = $extraData['context_prompt'] . $sendText;
}
}
$webhookUrl = "http://nginx/ai/chat";
} else {
// 用户机器人