新增禁用工具包的配置项

This commit is contained in:
Asankilp 2024-12-07 17:14:06 +08:00
parent add6058bee
commit 910f68398c
5 changed files with 9 additions and 2 deletions

View File

@ -170,6 +170,7 @@ _✨ 使用 OpenAI 标准格式 API 的聊天机器人插件 ✨_
| MARSHOAI_ENABLE_TOOLS | `bool` | `true` | 是否启用小棉工具 | | MARSHOAI_ENABLE_TOOLS | `bool` | `true` | 是否启用小棉工具 |
| MARSHOAI_LOAD_BUILTIN_TOOLS | `bool` | `true` | 是否加载内置工具包 | | MARSHOAI_LOAD_BUILTIN_TOOLS | `bool` | `true` | 是否加载内置工具包 |
| MARSHOAI_TOOLSET_DIR | `list` | `[]` | 外部工具集路径列表 | | MARSHOAI_TOOLSET_DIR | `list` | `[]` | 外部工具集路径列表 |
| MARSHOAI_DISABLED_TOOLKITS | `list` | `[]` | 禁用的工具包包名列表 |
| MARSHOAI_ENABLE_RICHTEXT_PARSE | `bool` | `true` | 是否启用自动解析消息若包含图片链接则发送图片、若包含LaTeX公式则发送公式图 | | MARSHOAI_ENABLE_RICHTEXT_PARSE | `bool` | `true` | 是否启用自动解析消息若包含图片链接则发送图片、若包含LaTeX公式则发送公式图 |
| MARSHOAI_SINGLE_LATEX_PARSE | `bool` | `false` | 单行公式是否渲染(当消息富文本解析启用时可用)(如果单行也渲……只能说不好看) | | MARSHOAI_SINGLE_LATEX_PARSE | `bool` | `false` | 单行公式是否渲染(当消息富文本解析启用时可用)(如果单行也渲……只能说不好看) |

View File

@ -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_ENABLE_TOOLS | `bool` | `true` | Turn on Marsho Tools or not |
| MARSHOAI_LOAD_BUILTIN_TOOLS | `bool` | `true` | Loading the built-in toolkit 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_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_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 | | MARSHOAI_SINGLE_LATEX_PARSE | `bool` | `false`| Render single-line equation or not |

View File

@ -39,6 +39,7 @@ class ConfigModel(BaseModel):
marshoai_enable_tools: bool = True marshoai_enable_tools: bool = True
marshoai_load_builtin_tools: bool = True marshoai_load_builtin_tools: bool = True
marshoai_toolset_dir: list = [] marshoai_toolset_dir: list = []
marshoai_disabled_toolkits: list = []
marshoai_azure_endpoint: str = "https://models.inference.ai.azure.com" marshoai_azure_endpoint: str = "https://models.inference.ai.azure.com"
marshoai_temperature: float | None = None marshoai_temperature: float | None = None
marshoai_max_tokens: int | None = None marshoai_max_tokens: int | None = None

View File

@ -40,6 +40,8 @@ marshoai_load_builtin_tools: true # 是否加载内置工具。
marshoai_toolset_dir: [] # 工具集路径。 marshoai_toolset_dir: [] # 工具集路径。
marshoai_disabled_toolkits: [] # 已禁用的工具包列表。
marshoai_azure_endpoint: "https://models.inference.ai.azure.com" # OpenAI 标准格式 API 的端点。 marshoai_azure_endpoint: "https://models.inference.ai.azure.com" # OpenAI 标准格式 API 的端点。
# 模型参数配置 # 模型参数配置

View File

@ -75,8 +75,10 @@ class MarshoTools:
for package_name in os.listdir(tools_dir): for package_name in os.listdir(tools_dir):
package_path = os.path.join(tools_dir, package_name) 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( if os.path.isdir(package_path) and os.path.exists(
os.path.join(package_path, "__init__.py") os.path.join(package_path, "__init__.py")
): ):