Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import urllib.parse
|
|
| 3 |
import yaml
|
| 4 |
import gradio as gr
|
| 5 |
from smolagents import CodeAgent, HfApiModel, tool
|
|
|
|
| 6 |
|
| 7 |
# @tool
|
| 8 |
# def fetch_latest_arxiv_papers(keywords: list, num_results: int = 3) -> list:
|
|
@@ -194,6 +195,23 @@ def fetch_latest_arxiv_papers(keywords: list, num_results: int = 5) -> list:
|
|
| 194 |
except Exception as e:
|
| 195 |
print(f"ERROR: {str(e)}")
|
| 196 |
return [{"error": f"Error fetching research papers: {str(e)}"}]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
|
| 198 |
|
| 199 |
# AI Model
|
|
|
|
| 3 |
import yaml
|
| 4 |
import gradio as gr
|
| 5 |
from smolagents import CodeAgent, HfApiModel, tool
|
| 6 |
+
from tools.final_answer import FinalAnswerTool
|
| 7 |
|
| 8 |
# @tool
|
| 9 |
# def fetch_latest_arxiv_papers(keywords: list, num_results: int = 3) -> list:
|
|
|
|
| 195 |
except Exception as e:
|
| 196 |
print(f"ERROR: {str(e)}")
|
| 197 |
return [{"error": f"Error fetching research papers: {str(e)}"}]
|
| 198 |
+
@tool
|
| 199 |
+
def get_current_time_in_timezone(timezone: str) -> str:
|
| 200 |
+
"""A tool that fetches the current local time in a specified timezone.
|
| 201 |
+
Args:
|
| 202 |
+
timezone: A string representing a valid timezone (e.g., 'America/New_York').
|
| 203 |
+
"""
|
| 204 |
+
try:
|
| 205 |
+
# Create timezone object
|
| 206 |
+
tz = pytz.timezone(timezone)
|
| 207 |
+
# Get current time in that timezone
|
| 208 |
+
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
| 209 |
+
return f"The current local time in {timezone} is: {local_time}"
|
| 210 |
+
except Exception as e:
|
| 211 |
+
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
final_answer = FinalAnswerTool()
|
| 215 |
|
| 216 |
|
| 217 |
# AI Model
|