mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-14 21:02:49 +00:00
perf: AI 支持引用文件
This commit is contained in:
parent
c128c58110
commit
a8be330baa
@ -14,7 +14,6 @@ use App\Module\Base;
|
|||||||
use App\Module\Doo;
|
use App\Module\Doo;
|
||||||
use App\Module\Ihttp;
|
use App\Module\Ihttp;
|
||||||
use App\Module\TextExtractor;
|
use App\Module\TextExtractor;
|
||||||
use Cache;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use DB;
|
use DB;
|
||||||
|
|
||||||
@ -453,31 +452,36 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
if (in_array($this->client['platform'], ['win', 'mac', 'web']) && !Base::judgeClientVersion("0.41.11", $this->client['version'])) {
|
if (in_array($this->client['platform'], ['win', 'mac', 'web']) && !Base::judgeClientVersion("0.41.11", $this->client['version'])) {
|
||||||
$errorContent = '当前客户端版本低(所需版本≥v0.41.11)。';
|
$errorContent = '当前客户端版本低(所需版本≥v0.41.11)。';
|
||||||
}
|
}
|
||||||
$attachments = Base::json2array(Cache::get("bot:{$msg->id}:attachments"));
|
|
||||||
foreach ($attachments as $attachment) {
|
|
||||||
$command = str_replace($attachment['search'], $attachment['replace'], $command);
|
|
||||||
$command .= "\n\n" . $attachment['context'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($msg->reply_id > 0) {
|
if ($msg->reply_id > 0) {
|
||||||
$replyMsg = WebSocketDialogMsg::find($msg->reply_id);
|
$replyMsg = WebSocketDialogMsg::find($msg->reply_id);
|
||||||
$replyCommand = '';
|
$replyCommand = null;
|
||||||
if ($replyMsg) {
|
if ($replyMsg) {
|
||||||
|
switch ($replyMsg->type) {
|
||||||
|
case 'text':
|
||||||
$replyCommand = $this->extractCommand($replyMsg, true);
|
$replyCommand = $this->extractCommand($replyMsg, true);
|
||||||
if ($replyCommand) {
|
if ($replyCommand) {
|
||||||
$replyCommand = Base::cutStr($replyCommand, 2000);
|
$replyCommand = Base::cutStr($replyCommand, 20000);
|
||||||
$replyCommand = <<<EOF
|
}
|
||||||
|
break;
|
||||||
|
case 'file':
|
||||||
|
$msgData = Base::json2array($replyMsg->getRawOriginal('msg'));
|
||||||
|
$replyCommand = TextExtractor::getFileContent(public_path($msgData['path']));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($replyCommand) {
|
||||||
|
$command = <<<EOF
|
||||||
<quoted_content>
|
<quoted_content>
|
||||||
{$replyCommand}
|
{$replyCommand}
|
||||||
</quoted_content>
|
</quoted_content>
|
||||||
|
|
||||||
The content within the above quoted_content tags is a citation.
|
The content within the above quoted_content tags is a citation.
|
||||||
|
|
||||||
|
{$command}
|
||||||
EOF;
|
EOF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$command = $replyCommand . $command;
|
|
||||||
}
|
|
||||||
$this->AIGenerateSystemMessageOrBeforeText($msg->userid, $dialog, $extras);
|
$this->AIGenerateSystemMessageOrBeforeText($msg->userid, $dialog, $extras);
|
||||||
$webhookUrl = "{$serverUrl}/ai/chat";
|
$webhookUrl = "{$serverUrl}/ai/chat";
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user