from smolagents import launch_gradio_demo | |
from tool import LinkupSearchTool | |
import gradio as gr | |
tool = LinkupSearchTool() | |
# Launch original demo to extract layout | |
demo = launch_gradio_demo(tool, return_interface=True) | |
# Find the submit button and inputs | |
submit_btn = demo.children[-1] # last element is usually the submit button | |
input_components = demo.children[0].children # first child is the input layout | |
# Hook: disable submit if any input is empty | |
def check_required_fields(*args): | |
return all(args) | |
demo.load( | |
check_required_fields, | |
inputs=input_components, | |
outputs=[submit_btn], | |
every=0.1, | |
queue=False, | |
) | |
demo.launch() | |