Spaces:
Runtime error
Runtime error
File size: 1,814 Bytes
775ea0b 0e9bb01 775ea0b 0e9bb01 7539685 775ea0b 45b377e 775ea0b 0e9bb01 775ea0b 7539685 f252842 775ea0b 0e9bb01 7539685 775ea0b 660052c 45b377e a7b6f49 0e9bb01 775ea0b 45b377e |
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 |
"""
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, BraveSearchTool
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=[
BraveSearchTool(),
# ThrottledDuckDuckGoSearchTool(min_delay=7.0, max_delay=15.0),
VisitWebpageTool(),
AnalyzeLyricsTool(),
FormatAnalysisResultsTool(),
FinalAnswerTool(),
],
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 using search and analysis tools. 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 |