Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
|
|
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
@@ -33,6 +34,16 @@ 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 |
model = HfApiModel(
|
|
@@ -53,6 +64,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 53 |
agent = CodeAgent(
|
| 54 |
model=model,
|
| 55 |
tools=[get_current_time_in_timezone,
|
|
|
|
| 56 |
image_generation_tool,
|
| 57 |
DuckDuckGoSearchTool(),
|
| 58 |
final_answer], ## add your tools here (don't remove final answer)
|
|
|
|
| 1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
| 2 |
+
from datetime import date
|
| 3 |
import datetime
|
| 4 |
import requests
|
| 5 |
import pytz
|
|
|
|
| 34 |
except Exception as e:
|
| 35 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 36 |
|
| 37 |
+
@tool
|
| 38 |
+
def get_current_date() -> str:
|
| 39 |
+
'''
|
| 40 |
+
A tool that fetches the current date.
|
| 41 |
+
'''
|
| 42 |
+
try:
|
| 43 |
+
this_date = date()
|
| 44 |
+
return this_date.strftime("%d %B %Y")
|
| 45 |
+
except Exception as e
|
| 46 |
+
return "Error fetching the date"
|
| 47 |
|
| 48 |
final_answer = FinalAnswerTool()
|
| 49 |
model = HfApiModel(
|
|
|
|
| 64 |
agent = CodeAgent(
|
| 65 |
model=model,
|
| 66 |
tools=[get_current_time_in_timezone,
|
| 67 |
+
get_current_date,
|
| 68 |
image_generation_tool,
|
| 69 |
DuckDuckGoSearchTool(),
|
| 70 |
final_answer], ## add your tools here (don't remove final answer)
|