Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,33 +1,27 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
query (str): the query for getiing information
|
| 9 |
-
Returns:
|
| 10 |
-
list[dict]: A list of dictionaries containing title, href and body
|
| 11 |
-
"""
|
| 12 |
with DDGS() as ddgs:
|
| 13 |
-
results = ddgs.text(query, max_results=
|
| 14 |
-
|
| 15 |
-
return results
|
| 16 |
|
| 17 |
with gr.Blocks() as app:
|
| 18 |
-
gr.Markdown("# DuckDuckGo Search Tool")
|
| 19 |
-
gr.Markdown("##
|
| 20 |
gr.HTML(
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
),
|
| 26 |
-
with gr.Row():
|
| 27 |
-
query_input = gr.Textbox(label="Enter Search Query")
|
| 28 |
-
search_btn = gr.Button("Search")
|
| 29 |
-
output = gr.Textbox(label="Results", interactive=False)
|
| 30 |
|
|
|
|
|
|
|
|
|
|
| 31 |
search_btn.click(fn=search_duckduckgo, inputs=query_input, outputs=output)
|
| 32 |
|
| 33 |
app.launch(mcp_server=True)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from ddgs import DDGS
|
| 3 |
+
import spaces
|
| 4 |
|
| 5 |
+
MAX_RESULTS = 5
|
| 6 |
+
|
| 7 |
+
@spaces.queue # ✅ CPU-safe, enables Streamable HTTP MCP
|
| 8 |
+
def search_duckduckgo(query: str) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
with DDGS() as ddgs:
|
| 10 |
+
results = ddgs.text(query, max_results=MAX_RESULTS)
|
| 11 |
+
return "\n".join([f"{r['title']} - {r['href']}" for r in results])
|
|
|
|
| 12 |
|
| 13 |
with gr.Blocks() as app:
|
| 14 |
+
gr.Markdown("# DuckDuckGo Search Tool")
|
| 15 |
+
gr.Markdown("## Example Video")
|
| 16 |
gr.HTML(
|
| 17 |
+
"""<iframe width="560" height="315"
|
| 18 |
+
src="https://www.youtube.com/embed/0EE3sD1MHeg"
|
| 19 |
+
frameborder="0" allowfullscreen></iframe>"""
|
| 20 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
query_input = gr.Textbox(label="Enter Search Query")
|
| 23 |
+
search_btn = gr.Button("Search")
|
| 24 |
+
output = gr.Textbox(label="Results", interactive=False)
|
| 25 |
search_btn.click(fn=search_duckduckgo, inputs=query_input, outputs=output)
|
| 26 |
|
| 27 |
app.launch(mcp_server=True)
|