From 154e0039d1b7b5ea89c28b473a1aa8ebb96415a3 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Sat, 22 Feb 2025 11:13:16 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=20AI=20=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/WebSocketDialogMsg.php | 3 +++ resources/assets/js/functions/web.js | 3 +++ .../pages/manage/setting/components/SystemAibot.vue | 13 +++++++++++++ resources/assets/js/store/ai.js | 1 + 4 files changed, 20 insertions(+) diff --git a/app/Models/WebSocketDialogMsg.php b/app/Models/WebSocketDialogMsg.php index fa965af1a..f0cfad1da 100644 --- a/app/Models/WebSocketDialogMsg.php +++ b/app/Models/WebSocketDialogMsg.php @@ -665,6 +665,9 @@ class WebSocketDialogMsg extends AbstractModel if (!$text) return ''; if ($msgData['type'] === 'md') { $text = preg_replace("/:::\s*reasoning[\s\S]*?:::/", "", $text); + if (preg_match('/:::\s*reasoning\s+/', $text)) { + return Doo::translate('思考中...'); + } $text = Base::markdown2html($text); $text = self::previewConvertTaskList($text); } diff --git a/resources/assets/js/functions/web.js b/resources/assets/js/functions/web.js index e34edb352..cfb88649a 100755 --- a/resources/assets/js/functions/web.js +++ b/resources/assets/js/functions/web.js @@ -247,6 +247,9 @@ import {convertLocalResourcePath} from "../components/Replace/utils"; } if (type === 'md') { text = text.replace(/:::\s*reasoning[\s\S]*?:::/g, ""); + if (/:::\s*reasoning\s+/.test(text)) { + return $A.L('思考中...') + } text = MarkdownPreview(text); } // diff --git a/resources/assets/js/pages/manage/setting/components/SystemAibot.vue b/resources/assets/js/pages/manage/setting/components/SystemAibot.vue index b3dbbc8c6..5fd820e01 100644 --- a/resources/assets/js/pages/manage/setting/components/SystemAibot.vue +++ b/resources/assets/js/pages/manage/setting/components/SystemAibot.vue @@ -133,6 +133,18 @@ export default { } }); + // 处理sort参数并排序 + let sort = 9999999; + prefixedFields.forEach(field => { + if (typeof field.sort === 'undefined') { + field.sort = ++sort; + } + }); + + // 按sort字段正序排序 + prefixedFields.sort((a, b) => a.sort - b.sort); + + // 返回处理后的字段 return prefixedFields; }, }, @@ -189,6 +201,7 @@ export default { return; } data.base_url = this.formData[`${this.type}_base_url`]; + data.key = this.formData[`${this.type}_key`]; } this.$store.dispatch("call", { url: 'system/setting/aibot_defmodels?type=' + this.type, diff --git a/resources/assets/js/store/ai.js b/resources/assets/js/store/ai.js index dc7bdd4fc..e3a8b6324 100644 --- a/resources/assets/js/store/ai.js +++ b/resources/assets/js/store/ai.js @@ -211,6 +211,7 @@ const AISystemConfig = { prop: "base_url", placeholder: "Enter base URL...", tip: "API请求的URL路径", + sort: 1, } ] },