tonko22 commited on
Commit
660052c
·
1 Parent(s): 775ea0b

Update agent description to avoid Genius and AZLyrics websites due to protection

Browse files

- Modified description in single_agent.py to explicitly mention avoidance of Genius and AZLyrics
- Added 'rich' to authorized imports for better formatting
- Cleaned up code structure and imports

Files changed (2) hide show
  1. agents/single_agent.py +2 -6
  2. tools/search_tools.py +0 -36
agents/single_agent.py CHANGED
@@ -5,9 +5,7 @@ Web agent for finding and extracting song lyrics from online sources.
5
  from loguru import logger
6
  from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool, FinalAnswerTool
7
 
8
- from config import load_prompt_templates
9
  from tools.analysis_tools import analyze_lyrics_tool
10
- from tools.search_tools import ThrottledDuckDuckGoSearchTool
11
 
12
 
13
  def create_single_agent(model):
@@ -20,8 +18,6 @@ def create_single_agent(model):
20
  Returns:
21
  A configured CodeAgent for web searches
22
  """
23
- # Load prompt templates
24
- prompt_templates = load_prompt_templates()
25
 
26
  # Define agent parameters directly in the code instead of using config
27
  # Example usage within the agent
@@ -33,10 +29,10 @@ def create_single_agent(model):
33
  analyze_lyrics_tool
34
  ],
35
  model=model,
36
- additional_authorized_imports=['numpy', 'bs4'],
37
  max_steps=22,
38
  verbosity_level=1,
39
- description="Specialized agent for finding and extracting song, specified by the user. Performs lyrics search and analysys using given tools. Provides detailed commentary using FinalAnswerTool meaning.",
40
  )
41
 
42
  logger.info("Web agent (lyrics search) created successfully")
 
5
  from loguru import logger
6
  from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool, FinalAnswerTool
7
 
 
8
  from tools.analysis_tools import analyze_lyrics_tool
 
9
 
10
 
11
  def create_single_agent(model):
 
18
  Returns:
19
  A configured CodeAgent for web searches
20
  """
 
 
21
 
22
  # Define agent parameters directly in the code instead of using config
23
  # Example usage within the agent
 
29
  analyze_lyrics_tool
30
  ],
31
  model=model,
32
+ additional_authorized_imports=['numpy', 'bs4', 'rich'],
33
  max_steps=22,
34
  verbosity_level=1,
35
+ description="Specialized agent for finding and extracting song, specified by the user. Does not use genius and AZlyrics for scraping since they have protection. Performs lyrics search and analysys using given tools. Provides detailed commentary using FinalAnswerTool meaning with beautiful human-readable format.",
36
  )
37
 
38
  logger.info("Web agent (lyrics search) created successfully")
tools/search_tools.py CHANGED
@@ -57,39 +57,3 @@ class ThrottledDuckDuckGoSearchTool(DuckDuckGoSearchTool):
57
  logger.error(f"Error in DuckDuckGo search: {str(e)}")
58
  # Return empty results on error to allow the agent to continue
59
  return [{"title": "Search error", "href": "", "body": f"Error performing search: {str(e)}"}]
60
-
61
-
62
- class LyricsSearchTool(Tool):
63
- """
64
- Uses web search to find song lyrics based on song title and artist name
65
-
66
- The search query should include the song title and artist name. The tool
67
- will return the lyrics of the song if found.
68
-
69
- Parameters
70
- ----------
71
- query : str
72
- The search query for finding song lyrics. Should include song title and artist name.
73
-
74
- Returns
75
- -------
76
- str
77
- The lyrics of the song if found, otherwise an empty string.
78
- """
79
- name = "lyrics_search_tool"
80
- description = "Uses web search to find song lyrics based on song title and artist name"
81
- inputs = {
82
- "query": {
83
- "type": "string",
84
- "description": "The search query for finding song lyrics. Should include song title and artist name.",
85
- }
86
- }
87
- output_type = "string"
88
-
89
- def __init__(self, **kwargs):
90
- super().__init__(**kwargs)
91
-
92
- def forward(self, query: str) -> str:
93
- assert isinstance(query, str), "Your search query must be a string"
94
- # TODO: Implement lyrics search functionality
95
- return "Lyrics search not implemented yet"
 
57
  logger.error(f"Error in DuckDuckGo search: {str(e)}")
58
  # Return empty results on error to allow the agent to continue
59
  return [{"title": "Search error", "href": "", "body": f"Error performing search: {str(e)}"}]