nischaypar commited on
Commit
3fc3426
·
1 Parent(s): 9af61ac

update app

Browse files
Files changed (1) hide show
  1. app.py +22 -10
app.py CHANGED
@@ -1,14 +1,26 @@
 
 
1
  import gradio as gr
2
- from pathlib import Path
3
 
4
- def load_readme() -> str:
5
- readme_path = Path(__file__).parent / "README.md"
6
- if readme_path.exists():
7
- return readme_path.read_text()
8
- return "# README.md not found\nPlease add a README.md file to the root directory."
9
 
10
- with gr.Blocks() as demo:
11
- gr.Markdown(load_readme())
12
 
13
- if __name__ == "__main__":
14
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import launch_gradio_demo
2
+ from tool import LinkupSearchTool
3
  import gradio as gr
 
4
 
5
+ tool = LinkupSearchTool()
 
 
 
 
6
 
7
+ # Launch original demo to extract layout
8
+ demo = launch_gradio_demo(tool, return_interface=True)
9
 
10
+ # Find the submit button and inputs
11
+ submit_btn = demo.children[-1] # last element is usually the submit button
12
+ input_components = demo.children[0].children # first child is the input layout
13
+
14
+ # Hook: disable submit if any input is empty
15
+ def check_required_fields(*args):
16
+ return all(args)
17
+
18
+ demo.load(
19
+ check_required_fields,
20
+ inputs=input_components,
21
+ outputs=[submit_btn],
22
+ every=0.1,
23
+ queue=False,
24
+ )
25
+
26
+ demo.launch()