From db46551b518f992ba6c3dfcfc18219153bcc7e94 Mon Sep 17 00:00:00 2001 From: SengokuCola <1026294844@qq.com> Date: Sun, 3 May 2026 17:59:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=81=E8=AE=B8=E6=9C=AC=E5=9C=B0webui?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E8=BF=90=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 2 - dashboard/package-lock.json | 73 +++++++++++++++++++++++++++++++++- src/config/official_configs.py | 3 +- src/webui/app.py | 16 +++++--- 4 files changed, 83 insertions(+), 11 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 5cec7c47..a66d71ca 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -41,8 +41,6 @@ # 配置文件修改 如果你需要改动配置文件,不需要修改实际的bot_config.toml或者model_config.toml,只需要修改配置文件模版,并新增一个版本号即可,也不必要为配置改动创建测试文件。 -# 关于webui修改 -不要修改dashboard下的内容,因为这部分内容由另一个仓库build # 关于 A_memorix 修改 如果修改涉及 `src/A_memorix`,请先阅读 `src/A_memorix/MODIFICATION_POLICY.md`。 diff --git a/dashboard/package-lock.json b/dashboard/package-lock.json index a0e1d02c..c187f9e9 100644 --- a/dashboard/package-lock.json +++ b/dashboard/package-lock.json @@ -1,12 +1,12 @@ { "name": "maibot-dashboard", - "version": "1.0.0", + "version": "1.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "maibot-dashboard", - "version": "1.0.0", + "version": "1.0.2", "dependencies": { "@codemirror/lang-css": "^6.3.1", "@codemirror/lang-javascript": "^6.2.4", @@ -62,6 +62,7 @@ "idb": "^8.0.3", "katex": "^0.16.27", "lucide-react": "^0.556.0", + "motion": "^12.38.0", "react": "^19.2.1", "react-day-picker": "^9.12.0", "react-dom": "^19.2.1", @@ -9794,6 +9795,33 @@ "node": ">= 6" } }, + "node_modules/framer-motion": { + "version": "12.38.0", + "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-12.38.0.tgz", + "integrity": "sha512-rFYkY/pigbcswl1XQSb7q424kSTQ8q6eAC+YUsSKooHQYuLdzdHjrt6uxUC+PRAO++q5IS7+TamgIw1AphxR+g==", + "license": "MIT", + "dependencies": { + "motion-dom": "^12.38.0", + "motion-utils": "^12.36.0", + "tslib": "^2.4.0" + }, + "peerDependencies": { + "@emotion/is-prop-valid": "*", + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@emotion/is-prop-valid": { + "optional": true + }, + "react": { + "optional": true + }, + "react-dom": { + "optional": true + } + } + }, "node_modules/fs-extra": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", @@ -13187,6 +13215,47 @@ "mkdirp": "bin/cmd.js" } }, + "node_modules/motion": { + "version": "12.38.0", + "resolved": "https://registry.npmjs.org/motion/-/motion-12.38.0.tgz", + "integrity": "sha512-uYfXzeHlgThchzwz5Te47dlv5JOUC7OB4rjJ/7XTUgtBZD8CchMN8qEJ4ZVsUmTyYA44zjV0fBwsiktRuFnn+w==", + "license": "MIT", + "dependencies": { + "framer-motion": "^12.38.0", + "tslib": "^2.4.0" + }, + "peerDependencies": { + "@emotion/is-prop-valid": "*", + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@emotion/is-prop-valid": { + "optional": true + }, + "react": { + "optional": true + }, + "react-dom": { + "optional": true + } + } + }, + "node_modules/motion-dom": { + "version": "12.38.0", + "resolved": "https://registry.npmjs.org/motion-dom/-/motion-dom-12.38.0.tgz", + "integrity": "sha512-pdkHLD8QYRp8VfiNLb8xIBJis1byQ9gPT3Jnh2jqfFtAsWUA3dEepDlsWe/xMpO8McV+VdpKVcp+E+TGJEtOoA==", + "license": "MIT", + "dependencies": { + "motion-utils": "^12.36.0" + } + }, + "node_modules/motion-utils": { + "version": "12.36.0", + "resolved": "https://registry.npmjs.org/motion-utils/-/motion-utils-12.36.0.tgz", + "integrity": "sha512-eHWisygbiwVvf6PZ1vhaHCLamvkSbPIeAYxWUuL3a2PD/TROgE7FvfHWTIH4vMl798QLfMw15nRqIaRDXTlYRg==", + "license": "MIT" + }, "node_modules/mrmime": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz", diff --git a/src/config/official_configs.py b/src/config/official_configs.py index ba11426a..2291d28c 100644 --- a/src/config/official_configs.py +++ b/src/config/official_configs.py @@ -108,7 +108,7 @@ class PersonalityConfig(ConfigBase): """可选的多种表达风格列表,当配置不为空时可按概率随机替换 reply_style""" multiple_probability: float = Field( - default=0.2, + default=0, ge=0, le=1, json_schema_extra={ @@ -405,6 +405,7 @@ class MemoryConfig(ConfigBase): ) """_wrap_全局记忆黑名单,当启用全局记忆时,不将特定聊天流纳入检索""" + enable_memory_query_tool: bool = Field( default=True, json_schema_extra={ diff --git a/src/webui/app.py b/src/webui/app.py index 54b1288b..e7ccbe5f 100644 --- a/src/webui/app.py +++ b/src/webui/app.py @@ -1,6 +1,7 @@ """FastAPI 应用工厂 - 创建和配置 WebUI 应用实例""" from importlib import import_module +from os import getenv from pathlib import Path from typing import Any, Dict, Tuple @@ -16,6 +17,7 @@ from src.common.logger import get_logger logger = get_logger("webui.app") _DASHBOARD_PACKAGE_NAME = "maibot-dashboard" +_LOCAL_DASHBOARD_ENV = "MAIBOT_WEBUI_USE_LOCAL_DASHBOARD" _MANUAL_INSTALL_COMMAND = f"pip install {_DASHBOARD_PACKAGE_NAME}" @@ -36,6 +38,10 @@ def _get_project_root() -> Path: return Path(__file__).resolve().parents[2] +def _is_local_dashboard_enabled() -> bool: + return getenv(_LOCAL_DASHBOARD_ENV, "").strip().lower() in {"1", "true", "yes", "on"} + + def _validate_static_path(static_path: Path | None) -> Tuple[str, Dict[str, Any]] | None: if static_path is None: return "startup.webui_static_dir_missing", {} @@ -205,12 +211,10 @@ def _setup_static_files(app: FastAPI): def _resolve_static_path() -> Path | None: - # 临时仅允许使用已安装的 maibot-dashboard 包,不使用仓库本地 dashboard/dist。 - # 如需恢复本地回退逻辑,可取消下方注释。 - # base_dir = _get_project_root() - # static_path = base_dir / "dashboard" / "dist" - # if static_path.is_dir() and (static_path / "index.html").exists(): - # return static_path + if _is_local_dashboard_enabled(): + static_path = _get_project_root() / "dashboard" / "dist" + if static_path.is_dir() and (static_path / "index.html").exists(): + return static_path try: module = import_module("maibot_dashboard")