refactor(agent_builder): remove get_current_time method and related instructions
This commit is contained in:
parent
f98a6c405e
commit
0e3043779d
@ -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 += "<get_current_time_instructions>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.</get_current_time_instructions>\n\n"
|
||||
|
||||
# Check if load_memory is enabled
|
||||
if agent.config.get("load_memory"):
|
||||
all_tools.append(load_memory)
|
||||
|
Loading…
Reference in New Issue
Block a user