From bd31ec498d266a69eb0822da18d5dd210a1501d9 Mon Sep 17 00:00:00 2001 From: Zack Date: Fri, 8 Dec 2023 11:05:36 -0800 Subject: [PATCH] feat: update plugin loading --- app.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app.py b/app.py index ec4725a2..6093b974 100644 --- a/app.py +++ b/app.py @@ -115,17 +115,16 @@ tools_mappings = { "walmart": "http://127.0.0.1:8079/tools/walmart", } -# # Load the JSON file -# with open('swarms/tools/openai.json', 'r') as f: -# data = json.load(f) -# for plugin in data: -# url = plugin['manifest']['api']['url'].replace('/.well-known/openapi.yaml', '') -# tool_name = plugin['namespace'] -# tools_mappings[tool_name] = url -# valid_tools_info = [] +data = json.load(open('swarms/tools/openai.json')) # Load the JSON file +items = data['items'] # Get the list of items + +for plugin in items: # Iterate over items, not data + url = plugin['manifest']['api']['url'] + tool_name = plugin['namespace'] + tools_mappings[tool_name] = url[:-len('/.well-known/openai.yaml')] + +print(tools_mappings) all_tools_list = [] -# print(data) -# print(plugin) gr.close_all() @@ -151,6 +150,8 @@ def download_model(model_url: str, memory_utilization: int , model_dir: str): # Update the dropdown choices with the new available_models list model_chosen.update(choices=available_models) +valid_tools_info = {} + def load_tools(): global valid_tools_info global all_tools_list @@ -369,7 +370,6 @@ with gr.Blocks() as demo: # iface = gr.Interface(fn=serve_iframe, inputs=[], outputs=gr.outputs.HTML()) - iface.launch() key_set_btn.click(fn=set_environ, inputs=[ OPENAI_API_KEY, WOLFRAMALPH_APP_ID,