Commit
Β·
d6054c0
1
Parent(s):
635e3eb
update app
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
from tool import LinkupSearchTool
|
|
|
3 |
|
4 |
def run_search(query, depth, api_key):
|
5 |
if not query.strip() or not depth or not api_key.strip():
|
@@ -14,6 +15,12 @@ def run_search(query, depth, api_key):
|
|
14 |
def enable_submit(q, d, k):
|
15 |
return gr.Button.update(interactive=bool(q.strip() and d and k.strip()))
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
with gr.Blocks(title="Linkup Web Search Tool") as demo:
|
18 |
gr.Markdown(
|
19 |
"""
|
@@ -30,7 +37,7 @@ with gr.Blocks(title="Linkup Web Search Tool") as demo:
|
|
30 |
with gr.Row():
|
31 |
query_input = gr.Textbox(
|
32 |
label="Search Query",
|
33 |
-
placeholder="e.g.
|
34 |
lines=1,
|
35 |
)
|
36 |
depth_input = gr.Dropdown(
|
@@ -45,10 +52,9 @@ with gr.Blocks(title="Linkup Web Search Tool") as demo:
|
|
45 |
type="password",
|
46 |
)
|
47 |
|
48 |
-
search_btn = gr.Button("π Search", interactive=
|
49 |
output = gr.Markdown("π¬ *Enter a query and click Search to begin.*", elem_id="output")
|
50 |
|
51 |
-
# Loading spinner and search button connection
|
52 |
search_btn.click(
|
53 |
fn=run_search,
|
54 |
inputs=[query_input, depth_input, api_key_input],
|
@@ -56,19 +62,12 @@ with gr.Blocks(title="Linkup Web Search Tool") as demo:
|
|
56 |
show_progress=True,
|
57 |
)
|
58 |
|
59 |
-
# Dynamic form validation
|
60 |
query_input.input(enable_submit, [query_input, depth_input, api_key_input], [search_btn])
|
61 |
depth_input.input(enable_submit, [query_input, depth_input, api_key_input], [search_btn])
|
62 |
api_key_input.input(enable_submit, [query_input, depth_input, api_key_input], [search_btn])
|
63 |
|
64 |
-
|
65 |
-
gr.Markdown(
|
66 |
-
|
67 |
-
---
|
68 |
-
β
Built with [SmolAgents](https://github.com/huggingface/smolagents) + [Gradio](https://gradio.app)
|
69 |
-
π Powered by [Linkup](https://linkup.so)
|
70 |
-
""",
|
71 |
-
elem_id="footer",
|
72 |
-
)
|
73 |
|
74 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from tool import LinkupSearchTool
|
3 |
+
from pathlib import Path
|
4 |
|
5 |
def run_search(query, depth, api_key):
|
6 |
if not query.strip() or not depth or not api_key.strip():
|
|
|
15 |
def enable_submit(q, d, k):
|
16 |
return gr.Button.update(interactive=bool(q.strip() and d and k.strip()))
|
17 |
|
18 |
+
def load_readme():
|
19 |
+
path = Path(__file__).parent / "README.md"
|
20 |
+
if path.exists():
|
21 |
+
return path.read_text()
|
22 |
+
return "README.md not found."
|
23 |
+
|
24 |
with gr.Blocks(title="Linkup Web Search Tool") as demo:
|
25 |
gr.Markdown(
|
26 |
"""
|
|
|
37 |
with gr.Row():
|
38 |
query_input = gr.Textbox(
|
39 |
label="Search Query",
|
40 |
+
placeholder="e.g. Linkup French AI Startup",
|
41 |
lines=1,
|
42 |
)
|
43 |
depth_input = gr.Dropdown(
|
|
|
52 |
type="password",
|
53 |
)
|
54 |
|
55 |
+
search_btn = gr.Button("π Search", interactive=False)
|
56 |
output = gr.Markdown("π¬ *Enter a query and click Search to begin.*", elem_id="output")
|
57 |
|
|
|
58 |
search_btn.click(
|
59 |
fn=run_search,
|
60 |
inputs=[query_input, depth_input, api_key_input],
|
|
|
62 |
show_progress=True,
|
63 |
)
|
64 |
|
|
|
65 |
query_input.input(enable_submit, [query_input, depth_input, api_key_input], [search_btn])
|
66 |
depth_input.input(enable_submit, [query_input, depth_input, api_key_input], [search_btn])
|
67 |
api_key_input.input(enable_submit, [query_input, depth_input, api_key_input], [search_btn])
|
68 |
|
69 |
+
gr.Markdown("---")
|
70 |
+
gr.Markdown("## π Tool Documentation")
|
71 |
+
gr.Markdown(load_readme())
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
demo.launch()
|