Spaces:
Runtime error
Runtime error
File size: 1,208 Bytes
c05c6bc 9b5b26a c19d193 6aae614 8fe992b 9b5b26a 7921f45 9b5b26a 1d984db 9b5b26a 8c01ffb c05c6bc 8c01ffb 9b5b26a 8c01ffb 8fe992b c05c6bc 8fe992b c05c6bc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool, LiteLLModel
import datetime
import requests
import pytz
import yaml
from tools.final_answer import FinalAnswerTool
from Gradio_UI import GradioUI
@tool
def get_current_time_in_timezone(timezone: str) -> str:
"""A tool that fetches the current local time in a specified timezone.
Args:
timezone: A string representing a valid timezone (e.g., 'America/New_York').
"""
try:
# Create timezone object
tz = pytz.timezone(timezone)
# Get current time rent local time in {timezone} is: {local_time}"
except Exception as e:
return f"Error fetching time for timezone '{timezone}': {str(e)}"
model = LiteLLModel(model_id = "gpt-4o-mini", api_key="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")
agent = CodeAgent(
model=model,
tools=[DuckDuckGoSearchTool()], ## add your tools here (don't remove final answer)
additional_authorized_imports=['math'],
)
agent.run( "Calculate how long does it take to drive from Melbourne to Sydney?")
|