CoolFace
Apppublic

HugeFighter/code_agent_template

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
app.py36 linesDownload Raw Back to root
1from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool, LiteLLModel2import datetime3import requests4import pytz5import yaml6from tools.final_answer import FinalAnswerTool7 8from Gradio_UI import GradioUI9 10 11 12@tool13def get_current_time_in_timezone(timezone: str) -> str:14    """A tool that fetches the current local time in a specified timezone.15    Args:16        timezone: A string representing a valid timezone (e.g., 'America/New_York').17    """18    try:19        # Create timezone object20        tz = pytz.timezone(timezone)21        # Get current time rent local time in {timezone} is: {local_time}"22    except Exception as e:23        return f"Error fetching time for timezone '{timezone}': {str(e)}"24 25 26model = LiteLLModel(model_id = "gpt-4o-mini", api_key="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")27 28    29agent = CodeAgent(30    model=model,31    tools=[DuckDuckGoSearchTool()], ## add your tools here (don't remove final answer)32    additional_authorized_imports=['math'],33)34 35agent.run( "Calculate how long does it take to drive from Melbourne to Sydney?")36