Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,35 +9,35 @@ from Gradio_UI import GradioUI
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
|
| 12 |
-
@tool
|
| 13 |
-
def web_search_tool(query: str, num_results: int = 3) -> str:
|
| 14 |
-
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
|
| 42 |
|
| 43 |
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
|
| 12 |
+
# @tool
|
| 13 |
+
# def web_search_tool(query: str, num_results: int = 3) -> str:
|
| 14 |
+
# """A tool that performs a web search and fetches up-to-date information using DuckDuckGo.
|
| 15 |
|
| 16 |
+
# Args:
|
| 17 |
+
# query: The search query or topic to look up on the web.
|
| 18 |
+
# num_results: The number of top search results to return (default is 3).
|
| 19 |
|
| 20 |
+
# Returns:
|
| 21 |
+
# A string containing summarized up-to-date information from the web.
|
| 22 |
+
# """
|
| 23 |
+
# try:
|
| 24 |
+
# ddg = DuckDuckGoSearchTool()
|
| 25 |
+
# results = ddg.text(query, max_results=num_results)
|
| 26 |
+
|
| 27 |
+
# if not results:
|
| 28 |
+
# return f"No results found for '{query}'."
|
| 29 |
+
|
| 30 |
+
# info_list = []
|
| 31 |
+
# for i, r in enumerate(results):
|
| 32 |
+
# title = r.get("title", "No title")
|
| 33 |
+
# body = r.get("body", "No summary available.")
|
| 34 |
+
# link = r.get("href", "")
|
| 35 |
+
# info_list.append(f"{i+1}. {title}\n{body}\n({link})")
|
| 36 |
+
|
| 37 |
+
# return f"Here are the top {num_results} results for '{query}':\n\n" + "\n\n".join(info_list)
|
| 38 |
+
|
| 39 |
+
# except Exception as e:
|
| 40 |
+
# return f"Error performing web search for '{query}': {str(e)}"
|
| 41 |
|
| 42 |
|
| 43 |
|