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\Module\Table\OnlineData;
|
||||
use App\Module\ZincSearch\ZincSearchDialogMsg;
|
||||
use App\Tasks\BotReceiveMsgTask;
|
||||
use Hhxsv5\LaravelS\Swoole\Task\Task;
|
||||
|
||||
/**
|
||||
@ -2441,6 +2442,33 @@ class DialogController extends AbstractController
|
||||
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. 新增群组
|
||||
*
|
||||
|
||||
@ -505,8 +505,8 @@ class BotReceiveMsgTask extends AbstractTask
|
||||
}
|
||||
$this->generateSystemPromptForAI($msg->userid, $dialog, $extras);
|
||||
// 转换提及格式
|
||||
$sendText = $this->convertMentionForAI($sendText);
|
||||
$replyText = $this->convertMentionForAI($replyText);
|
||||
$sendText = self::convertMentionForAI($sendText);
|
||||
$replyText = self::convertMentionForAI($replyText);
|
||||
if ($replyText) {
|
||||
$sendText = <<<EOF
|
||||
<quoted_content>
|
||||
@ -698,7 +698,7 @@ class BotReceiveMsgTask extends AbstractTask
|
||||
* @return string 转换后的消息文本,包含相关内容的标签
|
||||
* @throws Exception 当提及的对象不存在或读取失败时抛出异常
|
||||
*/
|
||||
private function convertMentionForAI($original)
|
||||
public static function convertMentionForAI($original)
|
||||
{
|
||||
$array = [];
|
||||
$original = preg_replace_callback('/<!--(.*?)#(.*?)#(.*?)-->/', function ($match) use (&$array) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user