Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,6 +33,19 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
|
|
@@ -55,7 +68,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer, DuckDuckGoSearchTool()], ## add your tools here (don't remove final answer)
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
+
@tool
|
| 37 |
+
def get_wikipedia_summary(query: str) -> str:
|
| 38 |
+
"""Fetches a short summary of a topic from Wikipedia.
|
| 39 |
+
Args:
|
| 40 |
+
query: The topic to look up on Wikipedia.
|
| 41 |
+
"""
|
| 42 |
+
try:
|
| 43 |
+
url = f"https://en.wikipedia.org/api/rest_v1/page/summary/{query.replace(' ', '_')}"
|
| 44 |
+
response = requests.get(url)
|
| 45 |
+
data = response.json()
|
| 46 |
+
return data.get("extract", "No summary found.")
|
| 47 |
+
except Exception as e:
|
| 48 |
+
return f"Error fetching Wikipedia summary: {str(e)}"
|
| 49 |
|
| 50 |
final_answer = FinalAnswerTool()
|
| 51 |
|
|
|
|
| 68 |
|
| 69 |
agent = CodeAgent(
|
| 70 |
model=model,
|
| 71 |
+
tools=[final_answer, DuckDuckGoSearchTool(),get_wikipedia_summary], ## add your tools here (don't remove final answer)
|
| 72 |
max_steps=6,
|
| 73 |
verbosity_level=1,
|
| 74 |
grammar=None,
|