toolshed / app.py
K00B404's picture
Update app.py
bdfa8f2 verified
raw
history blame
998 Bytes
import gradio as gr
import requests
def register_tool(tool_data):
# Send a POST request to register the tool
response = requests.post("https://huggingface.co/chat/tools/new", json=tool_data)
return response.json()
def create_tool(display_name, description, inputs):
tool_data = {
"displayName": display_name,
"description": description,
"color": "yellow", # Example color
"icon": "tools",
"baseUrl": "K00B404/toolshed",
"endpoint": "/query",
"name": "query",
"inputs": inputs,
"outputComponent": "0;image", # Adjust based on your tool's output
"outputComponentIdx": 0,
"showOutput": True
}
return register_tool(tool_data)
inputs = [
gr.inputs.Textbox(label="Display Name"),
gr.inputs.Textbox(label="Description"),
gr.inputs.JSON(label="Inputs (JSON format)"), # Allow user to input inputs in JSON
]
gr.Interface(fn=create_tool, inputs=inputs, outputs="json").launch()