|
import gradio as gr |
|
import requests |
|
|
|
def register_tool(tool_data): |
|
|
|
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", |
|
"icon": "tools", |
|
"baseUrl": "K00B404/toolshed", |
|
"endpoint": "/query", |
|
"name": "query", |
|
"inputs": inputs, |
|
"outputComponent": "0;image", |
|
"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)"), |
|
] |
|
|
|
gr.Interface(fn=create_tool, inputs=inputs, outputs="json").launch() |