From 0e3043779dccdc45f7de99a12b5984c575b237d8 Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Wed, 7 May 2025 19:49:10 -0300 Subject: [PATCH] refactor(agent_builder): remove get_current_time method and related instructions --- src/services/agent_builder.py | 62 +---------------------------------- 1 file changed, 1 insertion(+), 61 deletions(-) diff --git a/src/services/agent_builder.py b/src/services/agent_builder.py index aab800d4..8e4ae84e 100644 --- a/src/services/agent_builder.py +++ b/src/services/agent_builder.py @@ -27,63 +27,6 @@ class AgentBuilder: self.custom_tool_builder = CustomToolBuilder() self.mcp_service = MCPService() - def get_current_time(self, city: str = "new york") -> dict: - """Get the current time in a city.""" - city_timezones = { - "new york": "America/New_York", - "los angeles": "America/Los_Angeles", - "chicago": "America/Chicago", - "toronto": "America/Toronto", - "mexico city": "America/Mexico_City", - "sao paulo": "America/Sao_Paulo", - "rio de janeiro": "America/Sao_Paulo", - "buenos aires": "America/Argentina/Buenos_Aires", - "london": "Europe/London", - "paris": "Europe/Paris", - "berlin": "Europe/Berlin", - "rome": "Europe/Rome", - "madrid": "Europe/Madrid", - "moscow": "Europe/Moscow", - "dubai": "Asia/Dubai", - "mumbai": "Asia/Kolkata", - "delhi": "Asia/Kolkata", - "singapore": "Asia/Singapore", - "hong kong": "Asia/Hong_Kong", - "beijing": "Asia/Shanghai", - "shanghai": "Asia/Shanghai", - "tokyo": "Asia/Tokyo", - "seoul": "Asia/Seoul", - "sydney": "Australia/Sydney", - "melbourne": "Australia/Melbourne", - "auckland": "Pacific/Auckland", - "johannesburg": "Africa/Johannesburg", - "cairo": "Africa/Cairo", - "lagos": "Africa/Lagos", - } - - try: - if city.lower() in city_timezones: - try: - tz = ZoneInfo(city_timezones[city.lower()]) - now = datetime.now(tz) - return { - "status": "success", - "report": f"The current time in {city} is {now.strftime('%Y-%m-%d %H:%M:%S %Z')}", - } - except Exception: - pass - - return { - "status": "error", - "error_message": f"Time information for '{city}' unavailable.", - } - except Exception as e: - logger.error(f"Error getting current time: {e}") - return { - "status": "error", - "error_message": f"Error getting current time: {e}", - } - async def _create_llm_agent( self, agent ) -> Tuple[LlmAgent, Optional[AsyncExitStack]]: @@ -102,7 +45,7 @@ class AgentBuilder: ) # Combine all tools - all_tools = custom_tools + mcp_tools + [self.get_current_time] + all_tools = custom_tools + mcp_tools now = datetime.now() current_datetime = now.strftime("%d/%m/%Y %H:%M") @@ -118,9 +61,6 @@ class AgentBuilder: current_time=current_time, ) - # Add get_current_time instructions to prompt - formatted_prompt += "Use the get_current_time tool to get the current time in a city. The tool is available in the tools section of the configuration. Use 'new york' by default if no city is provided.ALWAYS use the 'get_current_time' tool when you need to use the current date and time in any type of situation, whether in interaction with the user or for calling other tools.\n\n" - # Check if load_memory is enabled if agent.config.get("load_memory"): all_tools.append(load_memory)