Spaces:
Sleeping
Sleeping
| """ | |
| Manager agent for coordinating the lyrics search and analysis process. | |
| """ | |
| from smolagents import CodeAgent, FinalAnswerTool | |
| from loguru import logger | |
| from config import load_prompt_templates | |
| from agents.web_agent import create_web_agent | |
| from agents.analysis_agent import create_analysis_agent | |
| def create_manager_agent(model): | |
| """ | |
| Create a manager agent that coordinates the web and analysis agents. | |
| Args: | |
| model: The LLM model to use with this agent | |
| Returns: | |
| A configured CodeAgent manager for coordinating other agents | |
| """ | |
| # Load prompt templates | |
| prompt_templates = load_prompt_templates() | |
| # Create sub-agents | |
| web_agent = create_web_agent(model) | |
| analysis_agent = create_analysis_agent(model) | |
| # Create and return the manager agent | |
| # Customize the prompts to use our specialized lyrics_manager_agent prompt | |
| custom_prompt_templates = prompt_templates.copy() | |
| # Set our special prompt as the system prompt for better instruction | |
| if 'lyrics_manager_agent' in custom_prompt_templates: | |
| custom_prompt_templates['system_prompt'] = custom_prompt_templates['lyrics_manager_agent'] | |
| agent = CodeAgent( | |
| model=model, | |
| tools=[FinalAnswerTool()], | |
| name="manager_agent", | |
| description="Specialized agent for coordinating lyrics search and analysis", | |
| managed_agents=[web_agent, analysis_agent], | |
| additional_authorized_imports=["json", "re"], | |
| planning_interval=3, # Hardcoded from config | |
| verbosity_level=3, # Hardcoded from config | |
| max_steps=30, # Hardcoded from config | |
| prompt_templates=prompt_templates | |
| ) | |
| logger.info("Manager agent created successfully") | |
| return agent | |