feat: move loading config method to base class

This commit is contained in:
zhayujie
2023-07-20 16:08:19 +08:00
parent aae9b64833
commit 9ef8e1be3f
6 changed files with 21 additions and 33 deletions

View File

@@ -10,7 +10,6 @@ from bridge.bridge import Bridge
from bridge.context import ContextType
from bridge.reply import Reply, ReplyType
from common import const
from common.log import logger
from config import conf
from plugins import *
@@ -119,16 +118,8 @@ class Tool(Plugin):
return
def _read_json(self) -> dict:
curdir = os.path.dirname(__file__)
config_path = os.path.join(curdir, "config.json")
tool_config = super().load_config()
if not tool_config:
if not os.path.exists(config_path):
return {"tools": [], "kwargs": {}}
else:
with open(config_path, "r") as f:
tool_config = json.load(f)
return tool_config
default_config = {"tools": [], "kwargs": {}}
return super().load_config() or default_config
def _build_tool_kwargs(self, kwargs: dict):
tool_model_name = kwargs.get("model_name")