Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,26 +8,29 @@ from tools.final_answer import FinalAnswerTool
|
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
|
|
|
|
|
|
| 11 |
@tool
|
| 12 |
-
def
|
| 13 |
-
"""A tool that
|
| 14 |
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
|
| 18 |
Returns:
|
| 19 |
-
|
| 20 |
"""
|
| 21 |
try:
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
| 27 |
else:
|
| 28 |
-
return "
|
| 29 |
except Exception as e:
|
| 30 |
-
return f"
|
| 31 |
|
| 32 |
@tool
|
| 33 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
+
import requests
|
| 12 |
+
|
| 13 |
@tool
|
| 14 |
+
def get_wikipedia_summary(topic: str) -> str:
|
| 15 |
+
"""A tool that fetches a short summary of a Wikipedia topic.
|
| 16 |
|
| 17 |
Args:
|
| 18 |
+
topic: The topic to search for on Wikipedia.
|
| 19 |
|
| 20 |
Returns:
|
| 21 |
+
A brief summary of the topic from Wikipedia.
|
| 22 |
"""
|
| 23 |
try:
|
| 24 |
+
url = f"https://en.wikipedia.org/api/rest_v1/page/summary/{topic}"
|
| 25 |
+
response = requests.get(url)
|
| 26 |
+
|
| 27 |
+
if response.status_code == 200:
|
| 28 |
+
data = response.json()
|
| 29 |
+
return data.get("extract", "No summary available.")
|
| 30 |
else:
|
| 31 |
+
return f"Error: Could not retrieve information for '{topic}'."
|
| 32 |
except Exception as e:
|
| 33 |
+
return f"An error occurred: {str(e)}"
|
| 34 |
|
| 35 |
@tool
|
| 36 |
def get_current_time_in_timezone(timezone: str) -> str:
|