mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-13 03:52:50 +00:00
no message
This commit is contained in:
parent
f5847a57c1
commit
c26f73a5a8
@ -30,6 +30,7 @@ use App\Models\WebSocketDialogMsgTranslate;
|
|||||||
use App\Models\WebSocketDialogSession;
|
use App\Models\WebSocketDialogSession;
|
||||||
use App\Module\Table\OnlineData;
|
use App\Module\Table\OnlineData;
|
||||||
use App\Module\ZincSearch\ZincSearchDialogMsg;
|
use App\Module\ZincSearch\ZincSearchDialogMsg;
|
||||||
|
use App\Tasks\BotReceiveMsgTask;
|
||||||
use Hhxsv5\LaravelS\Swoole\Task\Task;
|
use Hhxsv5\LaravelS\Swoole\Task\Task;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2441,6 +2442,33 @@ class DialogController extends AbstractController
|
|||||||
return Base::retSuccess("success", $data);
|
return Base::retSuccess("success", $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @api {post} api/dialog/msg/webhookmsg2ai 48. 转换为AI对话
|
||||||
|
*
|
||||||
|
* @apiDescription 需要token身份,将webhook消息转换为适合AI对话的格式消息,用于AI对话
|
||||||
|
* @apiVersion 1.0.0
|
||||||
|
* @apiGroup dialog
|
||||||
|
* @apiName msg__webhookmsg2ai
|
||||||
|
*
|
||||||
|
* @apiParam {String} msg 消息内容
|
||||||
|
*
|
||||||
|
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||||
|
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||||
|
* @apiSuccess {Object} data 返回数据
|
||||||
|
*/
|
||||||
|
public function msg__webhookmsg2ai()
|
||||||
|
{
|
||||||
|
User::auth();
|
||||||
|
//
|
||||||
|
$msg = Request::input('msg');
|
||||||
|
try {
|
||||||
|
$res = BotReceiveMsgTask::convertMentionForAI($msg);
|
||||||
|
return Base::retSuccess("success", ['msg' => $res]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return Base::retError($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} api/dialog/group/add 48. 新增群组
|
* @api {get} api/dialog/group/add 48. 新增群组
|
||||||
*
|
*
|
||||||
|
|||||||
@ -505,8 +505,8 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
}
|
}
|
||||||
$this->generateSystemPromptForAI($msg->userid, $dialog, $extras);
|
$this->generateSystemPromptForAI($msg->userid, $dialog, $extras);
|
||||||
// 转换提及格式
|
// 转换提及格式
|
||||||
$sendText = $this->convertMentionForAI($sendText);
|
$sendText = self::convertMentionForAI($sendText);
|
||||||
$replyText = $this->convertMentionForAI($replyText);
|
$replyText = self::convertMentionForAI($replyText);
|
||||||
if ($replyText) {
|
if ($replyText) {
|
||||||
$sendText = <<<EOF
|
$sendText = <<<EOF
|
||||||
<quoted_content>
|
<quoted_content>
|
||||||
@ -698,7 +698,7 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
* @return string 转换后的消息文本,包含相关内容的标签
|
* @return string 转换后的消息文本,包含相关内容的标签
|
||||||
* @throws Exception 当提及的对象不存在或读取失败时抛出异常
|
* @throws Exception 当提及的对象不存在或读取失败时抛出异常
|
||||||
*/
|
*/
|
||||||
private function convertMentionForAI($original)
|
public static function convertMentionForAI($original)
|
||||||
{
|
{
|
||||||
$array = [];
|
$array = [];
|
||||||
$original = preg_replace_callback('/<!--(.*?)#(.*?)#(.*?)-->/', function ($match) use (&$array) {
|
$original = preg_replace_callback('/<!--(.*?)#(.*?)#(.*?)-->/', function ($match) use (&$array) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user