Commit
Β·
a0d8cc7
1
Parent(s):
e923eaa
update app
Browse files
app.py
CHANGED
@@ -9,29 +9,26 @@ def run_search(query, depth, api_key):
|
|
9 |
except Exception as e:
|
10 |
return f"β Error: {str(e)}"
|
11 |
|
|
|
|
|
|
|
|
|
|
|
12 |
with gr.Blocks() as demo:
|
13 |
-
gr.Markdown("## π Linkup Web Search Tool
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
api_key_input = gr.Textbox(label="Linkup API Key", type="password", placeholder="Required")
|
19 |
|
20 |
output = gr.Markdown()
|
21 |
-
|
22 |
-
|
23 |
-
btn.click(
|
24 |
-
fn=run_search,
|
25 |
-
inputs=[query_input, depth_input, api_key_input],
|
26 |
-
outputs=output
|
27 |
-
)
|
28 |
|
29 |
-
|
30 |
-
return gr.Button.update(interactive=bool(q and d and k))
|
31 |
|
32 |
-
#
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
|
37 |
demo.launch()
|
|
|
9 |
except Exception as e:
|
10 |
return f"β Error: {str(e)}"
|
11 |
|
12 |
+
def check_inputs(query, depth, api_key):
|
13 |
+
if query and depth and api_key:
|
14 |
+
return gr.Button.update(interactive=True)
|
15 |
+
return gr.Button.update(interactive=False)
|
16 |
+
|
17 |
with gr.Blocks() as demo:
|
18 |
+
gr.Markdown("## π Linkup Web Search Tool")
|
19 |
|
20 |
+
query = gr.Textbox(label="Search Query", placeholder="e.g. AI trends in 2024")
|
21 |
+
depth = gr.Dropdown(label="Search Depth", choices=["standard", "deep"])
|
22 |
+
api_key = gr.Textbox(label="Linkup API Key", type="password")
|
|
|
23 |
|
24 |
output = gr.Markdown()
|
25 |
+
search_btn = gr.Button("Search", interactive=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
+
search_btn.click(run_search, inputs=[query, depth, api_key], outputs=output)
|
|
|
28 |
|
29 |
+
# Dynamically update button interactivity
|
30 |
+
query.input(check_inputs, [query, depth, api_key], [search_btn])
|
31 |
+
depth.input(check_inputs, [query, depth, api_key], [search_btn])
|
32 |
+
api_key.input(check_inputs, [query, depth, api_key], [search_btn])
|
33 |
|
34 |
demo.launch()
|