Spaces:
Sleeping
Sleeping
File size: 1,773 Bytes
ce0ec3b 775ea0b ce0ec3b 775ea0b ce0ec3b 7c390d2 ce0ec3b 7c390d2 ce0ec3b 7c390d2 775ea0b 3726684 ce0ec3b |
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
"""
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
|