From 55ca652ad88d808e18d710aa4b7623848d1bfe18 Mon Sep 17 00:00:00 2001 From: 6vision Date: Tue, 30 Jul 2024 23:14:23 +0800 Subject: [PATCH] Default close tool plugin. --- plugins/tool/tool.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/tool/tool.py b/plugins/tool/tool.py index a2ce4b6..ab8edf1 100644 --- a/plugins/tool/tool.py +++ b/plugins/tool/tool.py @@ -21,11 +21,15 @@ from plugins import * class Tool(Plugin): def __init__(self): super().__init__() - self.handlers[Event.ON_HANDLE_CONTEXT] = self.on_handle_context - - self.app = self._reset_app() - - logger.info("[tool] inited") + try: + self.handlers[Event.ON_HANDLE_CONTEXT] = self.on_handle_context + self.app = self._reset_app() + if not self.tool_config.get("tools"): + raise Exception("config.json not found") + logger.info("[tool] inited") + except Exception as e: + logger.warn("[tool] init failed, ignore ") + raise e def get_help_text(self, verbose=False, **kwargs): help_text = "这是一个能让chatgpt联网,搜索,数字运算的插件,将赋予强大且丰富的扩展能力。"