Commit
·
e923eaa
1
Parent(s):
86537bd
update app
Browse files
app.py
CHANGED
@@ -4,9 +4,6 @@ from tool import LinkupSearchTool
|
|
4 |
tool = LinkupSearchTool()
|
5 |
|
6 |
def run_search(query, depth, api_key):
|
7 |
-
if not query or not depth or not api_key:
|
8 |
-
return "❌ All fields are required."
|
9 |
-
|
10 |
try:
|
11 |
return tool.forward(query=query, depth=depth, api_key=api_key)
|
12 |
except Exception as e:
|
@@ -17,11 +14,11 @@ with gr.Blocks() as demo:
|
|
17 |
|
18 |
with gr.Row():
|
19 |
query_input = gr.Textbox(label="Search Query", placeholder="e.g. AI trends in 2024")
|
20 |
-
depth_input = gr.Dropdown(label="Search Depth", choices=["standard", "deep"]
|
21 |
-
api_key_input = gr.Textbox(label="Linkup API Key", type="password")
|
22 |
|
23 |
output = gr.Markdown()
|
24 |
-
btn = gr.Button("Search", interactive=False) #
|
25 |
|
26 |
btn.click(
|
27 |
fn=run_search,
|
@@ -30,11 +27,11 @@ with gr.Blocks() as demo:
|
|
30 |
)
|
31 |
|
32 |
def enable_submit(q, d, k):
|
33 |
-
return gr.Button.update(interactive=bool(q
|
34 |
|
35 |
-
#
|
36 |
-
query_input.
|
37 |
-
depth_input.
|
38 |
-
api_key_input.
|
39 |
|
40 |
-
demo.launch()
|
|
|
4 |
tool = LinkupSearchTool()
|
5 |
|
6 |
def run_search(query, depth, api_key):
|
|
|
|
|
|
|
7 |
try:
|
8 |
return tool.forward(query=query, depth=depth, api_key=api_key)
|
9 |
except Exception as e:
|
|
|
14 |
|
15 |
with gr.Row():
|
16 |
query_input = gr.Textbox(label="Search Query", placeholder="e.g. AI trends in 2024")
|
17 |
+
depth_input = gr.Dropdown(label="Search Depth", choices=["standard", "deep"])
|
18 |
+
api_key_input = gr.Textbox(label="Linkup API Key", type="password", placeholder="Required")
|
19 |
|
20 |
output = gr.Markdown()
|
21 |
+
btn = gr.Button("Search", interactive=False) # Start disabled
|
22 |
|
23 |
btn.click(
|
24 |
fn=run_search,
|
|
|
27 |
)
|
28 |
|
29 |
def enable_submit(q, d, k):
|
30 |
+
return gr.Button.update(interactive=bool(q and d and k))
|
31 |
|
32 |
+
# ✅ Use .input() instead of .change()
|
33 |
+
query_input.input(enable_submit, [query_input, depth_input, api_key_input], [btn])
|
34 |
+
depth_input.input(enable_submit, [query_input, depth_input, api_key_input], [btn])
|
35 |
+
api_key_input.input(enable_submit, [query_input, depth_input, api_key_input], [btn])
|
36 |
|
37 |
+
demo.launch()
|