Skip to content

Commit

Permalink
✨新增禁用工具包的配置项
Browse files Browse the repository at this point in the history
  • Loading branch information
Asankilp committed Dec 7, 2024
1 parent add6058 commit 910f683
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` | 单行公式是否渲染(当消息富文本解析启用时可用)(如果单行也渲……只能说不好看) |

Expand Down
1 change: 1 addition & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

Expand Down
1 change: 1 addition & 0 deletions nonebot_plugin_marshoai/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions nonebot_plugin_marshoai/config_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 的端点。

# 模型参数配置
Expand Down
6 changes: 4 additions & 2 deletions nonebot_plugin_marshoai/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ def load_tools(self, tools_dir):
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")
):
Expand Down

0 comments on commit 910f683

Please sign in to comment.