Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,36 +7,31 @@ from tools.final_answer import FinalAnswerTool
|
|
7 |
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
10 |
-
import wikipedia
|
11 |
-
|
12 |
@tool
|
13 |
-
def
|
14 |
"""
|
15 |
-
Fetches a summary
|
16 |
|
17 |
Args:
|
18 |
-
|
19 |
|
20 |
Returns:
|
21 |
-
str: A
|
22 |
"""
|
23 |
try:
|
24 |
-
#
|
25 |
-
|
26 |
-
|
27 |
-
# Get a short summary from Wikipedia
|
28 |
-
summary = wikipedia.summary(topic, sentences=2)
|
29 |
-
|
30 |
-
# Generate an image based on the summary
|
31 |
-
image = image_generation_tool(summary)
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
|
|
|
|
|
40 |
|
41 |
@tool
|
42 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
7 |
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
|
|
|
|
10 |
@tool
|
11 |
+
def fetch_duckduckgo_summary(query: str) -> str:
|
12 |
"""
|
13 |
+
Fetches a short summary from web search results.
|
14 |
|
15 |
Args:
|
16 |
+
query (str): The search query.
|
17 |
|
18 |
Returns:
|
19 |
+
str: A brief summary of the top search results.
|
20 |
"""
|
21 |
try:
|
22 |
+
# Perform a DuckDuckGo search
|
23 |
+
search_tool = DuckDuckGoSearchTool()
|
24 |
+
search_results = search_tool(query=query, max_results=3)
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
+
# Extract the top results
|
27 |
+
if search_results and isinstance(search_results, list):
|
28 |
+
summary = "\n".join([f"{res['title']}: {res.get('body', 'No description')}" for res in search_results])
|
29 |
+
return summary
|
30 |
+
else:
|
31 |
+
return "No relevant results found."
|
32 |
|
33 |
+
except Exception as e:
|
34 |
+
return f"Error fetching search results: {str(e)}"
|
35 |
|
36 |
@tool
|
37 |
def get_current_time_in_timezone(timezone: str) -> str:
|