Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -130,6 +130,19 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 130 |
except Exception as e:
|
| 131 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
|
| 134 |
final_answer = FinalAnswerTool()
|
| 135 |
model = LiteLLMModel(
|
|
@@ -147,7 +160,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 147 |
|
| 148 |
agent = CodeAgent(
|
| 149 |
model=model,
|
| 150 |
-
tools=[final_answer, get_current_time_in_timezone, get_weather_forecast], ## add your tools here (don't remove final answer)
|
| 151 |
max_steps=6,
|
| 152 |
verbosity_level=1,
|
| 153 |
grammar=None,
|
|
|
|
| 130 |
except Exception as e:
|
| 131 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 132 |
|
| 133 |
+
@tool
|
| 134 |
+
def get_current_time() -> str:
|
| 135 |
+
"""A tool that fetches the current local time.
|
| 136 |
+
"""
|
| 137 |
+
try:
|
| 138 |
+
# Create timezone object
|
| 139 |
+
tz = pytz.timezone("UK/London")
|
| 140 |
+
# Get current time in that timezone
|
| 141 |
+
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
| 142 |
+
return f"The current local time in {timezone} is: {local_time}"
|
| 143 |
+
except Exception as e:
|
| 144 |
+
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 145 |
+
|
| 146 |
|
| 147 |
final_answer = FinalAnswerTool()
|
| 148 |
model = LiteLLMModel(
|
|
|
|
| 160 |
|
| 161 |
agent = CodeAgent(
|
| 162 |
model=model,
|
| 163 |
+
tools=[final_answer, get_current_time_in_timezone, get_current_time, get_weather_forecast], ## add your tools here (don't remove final answer)
|
| 164 |
max_steps=6,
|
| 165 |
verbosity_level=1,
|
| 166 |
grammar=None,
|