mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-10 18:02:55 +00:00
perf: AI机器人支持多会话
This commit is contained in:
parent
fb286cea3c
commit
30d88761b4
@ -489,6 +489,8 @@ class DialogController extends AbstractController
|
||||
* @apiName msg__list
|
||||
*
|
||||
* @apiParam {Number} dialog_id 对话ID
|
||||
* @apiParam {Number} [session_id] 会话ID
|
||||
* - 此参数目前仅和AI的对话有效,AI对话支持新建对话,此参数为会话ID
|
||||
* @apiParam {Number} [msg_id] 消息ID
|
||||
* @apiParam {Number} [position_id] 此消息ID前后的数据
|
||||
* @apiParam {Number} [prev_id] 此消息ID之前的数据
|
||||
@ -514,6 +516,7 @@ class DialogController extends AbstractController
|
||||
$user = User::auth();
|
||||
//
|
||||
$dialog_id = intval(Request::input('dialog_id'));
|
||||
$session_id = intval(Request::input('session_id'));
|
||||
$msg_id = intval(Request::input('msg_id'));
|
||||
$position_id = intval(Request::input('position_id'));
|
||||
$prev_id = intval(Request::input('prev_id'));
|
||||
@ -536,6 +539,9 @@ class DialogController extends AbstractController
|
||||
->on('read.msg_id', '=', 'web_socket_dialog_msgs.id');
|
||||
})->where('web_socket_dialog_msgs.dialog_id', $dialog_id);
|
||||
//
|
||||
if ($session_id > 0) {
|
||||
$builder->whereSessionId($session_id);
|
||||
}
|
||||
if ($msg_type) {
|
||||
if ($msg_type === 'tag') {
|
||||
$builder->where('tag', '>', 0);
|
||||
|
||||
@ -205,8 +205,15 @@ class UserBot extends AbstractModel
|
||||
]
|
||||
],
|
||||
[
|
||||
'key' => '%3A.clear',
|
||||
'label' => Doo::translate('清空上下文')
|
||||
'key' => '~ai-chat-new',
|
||||
'label' => Doo::translate('开启新对话'),
|
||||
'config' => [
|
||||
'model' => $aibotSetting[$match[1] . '_model']
|
||||
]
|
||||
],
|
||||
[
|
||||
'key' => '~ai-chat-history',
|
||||
'label' => Doo::translate('历史对话'),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @property int|null $read 已阅数量
|
||||
* @property int|null $send 发送数量
|
||||
* @property int|null $tag 标注会员ID
|
||||
* @property string|null $session 会话标识符
|
||||
* @property int|null $session_id 会话ID
|
||||
* @property int|null $todo 设为待办会员ID
|
||||
* @property int|null $link 是否存在链接
|
||||
* @property int|null $modify 是否编辑
|
||||
@ -70,7 +70,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereReplyId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereReplyNum($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereSend($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereSession($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereSessionId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereTag($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereTodo($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereType($value)
|
||||
|
||||
@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class WebSocketDialogMsgsAddSession extends Migration
|
||||
class WebSocketDialogMsgsAddSessionId extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
@ -14,8 +14,8 @@ class WebSocketDialogMsgsAddSession extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::table('web_socket_dialog_msgs', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('web_socket_dialog_msgs', 'session')) {
|
||||
$table->string('session', 36)->nullable()->default('')->after('tag')->comment('会话标识符');
|
||||
if (!Schema::hasColumn('web_socket_dialog_msgs', 'session_id')) {
|
||||
$table->bigInteger('session_id')->index()->nullable()->default(0)->after('dialog_type')->comment('会话ID');
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -28,7 +28,7 @@ class WebSocketDialogMsgsAddSession extends Migration
|
||||
public function down()
|
||||
{
|
||||
Schema::table('web_socket_dialog_msgs', function (Blueprint $table) {
|
||||
$table->dropColumn('session');
|
||||
$table->dropColumn('session_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -805,3 +805,5 @@ AI机器人不存在
|
||||
|
||||
内容不存在
|
||||
长文本
|
||||
|
||||
选择模型
|
||||
|
||||
@ -1927,3 +1927,6 @@ API请求的基础URL路径,如果没有请留空
|
||||
思考过程
|
||||
隐藏翻译
|
||||
重新翻译
|
||||
|
||||
当前客户端不支持该指令
|
||||
默认模型
|
||||
|
||||
@ -1922,6 +1922,20 @@ export default {
|
||||
}
|
||||
break;
|
||||
|
||||
// 开启新对话
|
||||
case "~ai-chat-new":
|
||||
if (!this.isAiBot) {
|
||||
return
|
||||
}
|
||||
break;
|
||||
|
||||
// 历史对话
|
||||
case "~ai-chat-history":
|
||||
if (!this.isAiBot) {
|
||||
return
|
||||
}
|
||||
break;
|
||||
|
||||
// 发送快捷指令
|
||||
default:
|
||||
if (/^~/.test(item.key)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user