File size: 657 Bytes
3fc3426 9af61ac e922dc7 3fc3426 9af61ac 3fc3426 9af61ac 3fc3426 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
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()
|