From d6c663f79d76b4f4021f64e7f0670e26e3e3e2e4 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Fri, 30 May 2025 10:09:09 +0800 Subject: [PATCH 1/6] fix: do not display change password dialog in demo mode --- astrbot/dashboard/routes/auth.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/astrbot/dashboard/routes/auth.py b/astrbot/dashboard/routes/auth.py index 896bea4e7..5ce578305 100644 --- a/astrbot/dashboard/routes/auth.py +++ b/astrbot/dashboard/routes/auth.py @@ -21,7 +21,11 @@ class AuthRoute(Route): post_data = await request.json if post_data["username"] == username and post_data["password"] == password: change_pwd_hint = False - if username == "astrbot" and password == "77b90590a8945a7d36c963981a307dc9": + if ( + username == "astrbot" + and password == "77b90590a8945a7d36c963981a307dc9" + and not DEMO_MODE + ): change_pwd_hint = True logger.warning("为了保证安全,请尽快修改默认密码。") From 2bc3bcd102875f94d0334bcddbb099cfb14e5714 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Fri, 30 May 2025 10:17:33 +0800 Subject: [PATCH 2/6] fix: handle missing nh3 library gracefully for README cleaning --- astrbot/core/star/star_manager.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/astrbot/core/star/star_manager.py b/astrbot/core/star/star_manager.py index 5fa1e23c5..ff07de712 100644 --- a/astrbot/core/star/star_manager.py +++ b/astrbot/core/star/star_manager.py @@ -13,7 +13,6 @@ import traceback from types import ModuleType from typing import List -import nh3 import yaml from astrbot.core import logger, pip_installer, sp @@ -38,6 +37,12 @@ except ImportError: if os.getenv("ASTRBOT_RELOAD", "0") == "1": logger.warning("未安装 watchfiles,无法实现插件的热重载。") +try: + import nh3 +except ImportError: + logger.warning("未安装 nh3 库,无法清理插件 README.md 中的 HTML 标签。") + nh3 = None + class PluginManager: def __init__(self, context: Context, config: AstrBotConfig): @@ -141,11 +146,13 @@ class PluginManager: if os.path.exists(os.path.join(path, d, "main.py")) or os.path.exists( os.path.join(path, d, d + ".py") ): - modules.append({ - "pname": d, - "module": module_str, - "module_path": os.path.join(path, d, module_str), - }) + modules.append( + { + "pname": d, + "module": module_str, + "module_path": os.path.join(path, d, module_str), + } + ) return modules def _get_plugin_modules(self) -> List[dict]: @@ -635,7 +642,7 @@ class PluginManager: if not os.path.exists(readme_path): readme_path = os.path.join(plugin_path, "readme.md") - if os.path.exists(readme_path): + if os.path.exists(readme_path) and nh3: try: with open(readme_path, "r", encoding="utf-8") as f: readme_content = f.read() From 9a4c2cf341393e0d80a4ad2d20067f909e3ef039 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Fri, 30 May 2025 10:21:31 +0800 Subject: [PATCH 3/6] fix: downgrade faiss-cpu dependency to version 1.10.0 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 70c9fc6a6..d3636d34f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ dependencies = [ "defusedxml>=0.7.1", "dingtalk-stream>=0.22.1", "docstring-parser>=0.16", - "faiss-cpu>=1.11.0", + "faiss-cpu>=1.10.0", "filelock>=3.18.0", "google-genai>=1.14.0", "googlesearch-python>=1.3.0", From af98cb11c59876b7c3efc3f1911f56a057d63197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B8=A6=E7=BE=BD?= Date: Fri, 30 May 2025 10:30:53 +0800 Subject: [PATCH 4/6] fix: handle missing nh3 library in plugin.py --- astrbot/dashboard/routes/plugin.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/astrbot/dashboard/routes/plugin.py b/astrbot/dashboard/routes/plugin.py index 5c7832003..4f89dbcfc 100644 --- a/astrbot/dashboard/routes/plugin.py +++ b/astrbot/dashboard/routes/plugin.py @@ -4,7 +4,6 @@ import os import ssl import certifi -import nh3 from .route import Route, Response, RouteContext from astrbot.core import logger @@ -19,6 +18,12 @@ from astrbot.core.star.filter.regex import RegexFilter from astrbot.core.star.star_handler import EventType from astrbot.core import DEMO_MODE +try: + import nh3 +except ImportError: + logger.warning("未安装 nh3 库,无法清理插件 README.md 中的 HTML 标签。") + nh3 = None + class PluginRoute(Route): def __init__( @@ -327,6 +332,9 @@ class PluginRoute(Route): return Response().error(str(e)).__dict__ async def get_plugin_readme(self): + if not nh3: + return Response().error("未安装 nh3 库").__dict__ + plugin_name = request.args.get("name") logger.debug(f"正在获取插件 {plugin_name} 的README文件内容") From 716a5dbb8afc57cd094d7eb354c9e2521180fee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B8=A6=E7=BE=BD?= Date: Fri, 30 May 2025 10:31:29 +0800 Subject: [PATCH 5/6] chore: add nh3 to requirements.txt --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c5b640e20..ec81128db 100644 --- a/requirements.txt +++ b/requirements.txt @@ -36,4 +36,5 @@ filelock watchfiles websockets faiss-cpu -aiosqlite \ No newline at end of file +aiosqlite +nh3 \ No newline at end of file From 1641549016b4e6bf2195bd5f61a546471eb4622e Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Fri, 30 May 2025 10:35:12 +0800 Subject: [PATCH 6/6] perf: improve WebUI --- dashboard/src/components/shared/ExtensionCard.vue | 2 +- dashboard/src/views/ChatPage.vue | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/dashboard/src/components/shared/ExtensionCard.vue b/dashboard/src/components/shared/ExtensionCard.vue index b9d4d8c6c..5956e1f78 100644 --- a/dashboard/src/components/shared/ExtensionCard.vue +++ b/dashboard/src/components/shared/ExtensionCard.vue @@ -77,7 +77,7 @@ const viewReadme = () => {