LyricsAnalyzerAgent / agents /single_agent.py
tonko22's picture
Update searach tool and description
f252842
"""
Web agent for finding and extracting song lyrics from online sources.
"""
from loguru import logger
from smolagents import CodeAgent, VisitWebpageTool, FinalAnswerTool, DuckDuckGoSearchTool
from config import load_prompt_templates
from tools.analysis_tools import AnalyzeLyricsTool
from tools.formatting_tools import FormatAnalysisResultsTool
from tools.search_tools import ThrottledDuckDuckGoSearchTool
def create_single_agent(model):
"""
Create an agent specialized in web browsing and lyrics extraction.
Args:
model: The LLM model to use with this agent
Returns:
A configured CodeAgent for web searches
"""
prompt_templates = load_prompt_templates()
# Define agent parameters directly in the code instead of using config
# Example usage within the agent
agent = CodeAgent(
tools=[
FinalAnswerTool(),
DuckDuckGoSearchTool(),
# ThrottledDuckDuckGoSearchTool(min_delay=7.0, max_delay=15.0),
VisitWebpageTool(),
AnalyzeLyricsTool(),
FormatAnalysisResultsTool()
],
model=model,
additional_authorized_imports=['numpy', 'bs4', 'rich'],
max_steps=25,
verbosity_level=2,
description="Specialized agent for finding and extracting song lyrics specified by the user. Performs lyrics search and after getting the lyrics full text from the web, it performs the analysis using given tools. Provides detailed commentary with beautiful and human-readable format using rich library formatting. Format analysis results in rich colorful output.",
prompt_templates=prompt_templates
)
logger.info("Web agent (lyrics search) created successfully")
return agent