LyricsAnalyzerAgent / agents /analysis_agent.py
tonko22's picture
refactor: decompose monolithic app into modular architecture
ce0ec3b
raw
history blame
1.39 kB
"""
Analysis agent for interpreting song lyrics and providing deeper context.
"""
from smolagents import CodeAgent, VisitWebpageTool
from loguru import logger
from config import AGENT_CONFIG, load_prompt_templates
from tools.search_tools import ThrottledDuckDuckGoSearchTool
from tools.analysis_tools import analyze_lyrics_tool
def create_analysis_agent(model):
"""
Create an agent specialized in analyzing and interpreting song lyrics.
Args:
model: The LLM model to use with this agent
Returns:
A configured CodeAgent for lyrics analysis
"""
# Get configuration values
config = AGENT_CONFIG['analysis_agent']
prompt_templates = load_prompt_templates()
# Create the throttled search tool
throttled_search_tool = ThrottledDuckDuckGoSearchTool(
min_delay=3.0,
max_delay=7.0
)
# Create and return the agent
agent = CodeAgent(
model=model,
tools=[throttled_search_tool, VisitWebpageTool(), analyze_lyrics_tool],
name="lyrics_analysis_agent",
description=config['description'],
additional_authorized_imports=["numpy", "bs4"],
max_steps=config['max_steps'],
verbosity_level=config['verbosity_level'],
prompt_templates=prompt_templates
)
logger.info("Analysis agent created successfully")
return agent