From 910f68398cbdbd861bb775f6204968d08a59d71b Mon Sep 17 00:00:00 2001 From: Asankilp Date: Sat, 7 Dec 2024 17:14:06 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=E6=96=B0=E5=A2=9E=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E5=8C=85=E7=9A=84=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + README_EN.md | 1 + nonebot_plugin_marshoai/config.py | 1 + nonebot_plugin_marshoai/config_example.yaml | 2 ++ nonebot_plugin_marshoai/models.py | 6 ++++-- 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6fc71de1..976621bf 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,7 @@ _✨ 使用 OpenAI 标准格式 API 的聊天机器人插件 ✨_ | MARSHOAI_ENABLE_TOOLS | `bool` | `true` | 是否启用小棉工具 | | MARSHOAI_LOAD_BUILTIN_TOOLS | `bool` | `true` | 是否加载内置工具包 | | MARSHOAI_TOOLSET_DIR | `list` | `[]` | 外部工具集路径列表 | +| MARSHOAI_DISABLED_TOOLKITS | `list` | `[]` | 禁用的工具包包名列表 | | MARSHOAI_ENABLE_RICHTEXT_PARSE | `bool` | `true` | 是否启用自动解析消息(若包含图片链接则发送图片、若包含LaTeX公式则发送公式图) | | MARSHOAI_SINGLE_LATEX_PARSE | `bool` | `false` | 单行公式是否渲染(当消息富文本解析启用时可用)(如果单行也渲……只能说不好看) | diff --git a/README_EN.md b/README_EN.md index a248d591..81de6d24 100644 --- a/README_EN.md +++ b/README_EN.md @@ -178,6 +178,7 @@ Add options in the `.env` file from the diagram below in nonebot2 project. | MARSHOAI_ENABLE_TOOLS | `bool` | `true` | Turn on Marsho Tools or not | | MARSHOAI_LOAD_BUILTIN_TOOLS | `bool` | `true` | Loading the built-in toolkit or not | | MARSHOAI_TOOLSET_DIR | `list` | `[]` | List of external toolset directory | +| MARSHOAI_DISABLED_TOOLKITS | `list` | `[]` | List of disabled toolkits' name | | MARSHOAI_ENABLE_RICHTEXT_PARSE | `bool` | `true` | Turn on auto parse rich text feature(including image, LaTeX equation) | | MARSHOAI_SINGLE_LATEX_PARSE | `bool` | `false`| Render single-line equation or not | diff --git a/nonebot_plugin_marshoai/config.py b/nonebot_plugin_marshoai/config.py index 66dc6827..c842fa1e 100644 --- a/nonebot_plugin_marshoai/config.py +++ b/nonebot_plugin_marshoai/config.py @@ -39,6 +39,7 @@ class ConfigModel(BaseModel): marshoai_enable_tools: bool = True marshoai_load_builtin_tools: bool = True marshoai_toolset_dir: list = [] + marshoai_disabled_toolkits: list = [] marshoai_azure_endpoint: str = "https://models.inference.ai.azure.com" marshoai_temperature: float | None = None marshoai_max_tokens: int | None = None diff --git a/nonebot_plugin_marshoai/config_example.yaml b/nonebot_plugin_marshoai/config_example.yaml index 8a2054fc..b4deec32 100644 --- a/nonebot_plugin_marshoai/config_example.yaml +++ b/nonebot_plugin_marshoai/config_example.yaml @@ -40,6 +40,8 @@ marshoai_load_builtin_tools: true # 是否加载内置工具。 marshoai_toolset_dir: [] # 工具集路径。 +marshoai_disabled_toolkits: [] # 已禁用的工具包列表。 + marshoai_azure_endpoint: "https://models.inference.ai.azure.com" # OpenAI 标准格式 API 的端点。 # 模型参数配置 diff --git a/nonebot_plugin_marshoai/models.py b/nonebot_plugin_marshoai/models.py index 0b81b27f..174c03f6 100644 --- a/nonebot_plugin_marshoai/models.py +++ b/nonebot_plugin_marshoai/models.py @@ -75,8 +75,10 @@ class MarshoTools: for package_name in os.listdir(tools_dir): package_path = os.path.join(tools_dir, package_name) - logger.info(f"尝试加载工具包 {package_name}") - + # logger.info(f"尝试加载工具包 {package_name}") + if package_name in config.marshoai_disabled_toolkits: + logger.info(f"工具包 {package_name} 已被禁用。") + continue if os.path.isdir(package_path) and os.path.exists( os.path.join(package_path, "__init__.py") ):