From c90f5da5bf020c0513d9d54581898175eb9eae3f Mon Sep 17 00:00:00 2001 From: mzr1996 Date: Wed, 13 Mar 2024 14:50:51 +0800 Subject: [PATCH] Support import openapi in webui --- webui/modules/ui_tools.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/webui/modules/ui_tools.py b/webui/modules/ui_tools.py index cd4f4dbb..dc853f91 100644 --- a/webui/modules/ui_tools.py +++ b/webui/modules/ui_tools.py @@ -1,4 +1,5 @@ import inspect +import os.path as osp from functools import partial import gradio as gr @@ -96,9 +97,11 @@ def setup_tools(*args): def import_remote_tools(server: str): - if not server.startswith('http'): - server = 'http://' + server - tools = RemoteTool.from_server(server) + if osp.isfile(server): + tools = RemoteTool.from_openapi(server) + else: + server = server if server.startswith('http') else f'http://{server}' + tools = RemoteTool.from_openapi(server) msg = '' for tool in tools: if tool.name in shared.tool_settings: