新增禁用工具包的配置项

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

View File

@ -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

View File

@ -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 的端点。
# 模型参数配置

View File

@ -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")
):