async auto load plugin

This commit is contained in:
yhjun1026 2023-06-14 21:51:05 +08:00
parent eec43dbfd5
commit cc4d70d4d5

View File

@ -83,6 +83,7 @@ def load_native_plugins(cfg: Config):
branch_name = cfg.plugins_git_branch
native_plugin_repo = "DB-GPT-Plugins"
url = "https://github.com/csunny/{repo}/archive/{branch}.zip"
try:
response = requests.get(url.format(repo=native_plugin_repo, branch=branch_name),
headers={'Authorization': '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'})
@ -101,6 +102,8 @@ def load_native_plugins(cfg: Config):
cfg.set_plugins(scan_plugins(cfg, cfg.debug_mode))
else:
print("get file faildresponse code", response.status_code)
except Exception as e:
print("load plugin from git exception!" + str(e))
# 创建一个线程
t = threading.Thread(target=load_from_git, args=(cfg,))
@ -108,6 +111,7 @@ def load_native_plugins(cfg: Config):
t.start()
def scan_plugins(cfg: Config, debug: bool = False) -> List[AutoGPTPluginTemplate]:
"""Scan the plugins directory for plugins and loads them.