tonko22 commited on
Commit
45b377e
·
1 Parent(s): 660052c

Update search tool

Browse files
Files changed (2) hide show
  1. agents/single_agent.py +8 -7
  2. tools/search_tools.py +2 -2
agents/single_agent.py CHANGED
@@ -3,13 +3,14 @@ Web agent for finding and extracting song lyrics from online sources.
3
  """
4
 
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):
12
- """
13
  Create an agent specialized in web browsing and lyrics extraction.
14
 
15
  Args:
@@ -24,16 +25,16 @@ def create_single_agent(model):
24
  agent = CodeAgent(
25
  tools=[
26
  FinalAnswerTool(),
27
- DuckDuckGoSearchTool(),
28
  VisitWebpageTool(),
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")
39
- return agent
 
3
  """
4
 
5
  from loguru import logger
6
+ from smolagents import CodeAgent, VisitWebpageTool, FinalAnswerTool
7
 
8
  from tools.analysis_tools import analyze_lyrics_tool
9
+ from tool.search_tools import ThrottledDuckDuckGoSearchTool
10
 
11
 
12
  def create_single_agent(model):
13
+ """
14
  Create an agent specialized in web browsing and lyrics extraction.
15
 
16
  Args:
 
25
  agent = CodeAgent(
26
  tools=[
27
  FinalAnswerTool(),
28
+ ThrottledDuckDuckGoSearchTool(),
29
  VisitWebpageTool(),
30
  analyze_lyrics_tool
31
  ],
32
  model=model,
33
  additional_authorized_imports=['numpy', 'bs4', 'rich'],
34
+ max_steps=25,
35
+ verbosity_level=2,
36
+ description="Specialized agent for finding and extracting song, specified by the user. Does not use genius.com and AZlyrics.com 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.",
37
  )
38
 
39
  logger.info("Web agent (lyrics search) created successfully")
40
+ return agent
tools/search_tools.py CHANGED
@@ -6,7 +6,7 @@ import time
6
  import random
7
  from typing import Dict, List, Any
8
  from loguru import logger
9
- from smolagents import DuckDuckGoSearchTool, Tool
10
 
11
  class ThrottledDuckDuckGoSearchTool(DuckDuckGoSearchTool):
12
  """
@@ -17,7 +17,7 @@ class ThrottledDuckDuckGoSearchTool(DuckDuckGoSearchTool):
17
  Each search request will be followed by a random delay within the specified range.
18
  """
19
 
20
- def __init__(self, min_delay: float = 2.0, max_delay: float = 5.0, **kwargs):
21
  """
22
  Initialize the throttled search tool with delay parameters.
23
 
 
6
  import random
7
  from typing import Dict, List, Any
8
  from loguru import logger
9
+ from smolagents import DuckDuckGoSearchTool
10
 
11
  class ThrottledDuckDuckGoSearchTool(DuckDuckGoSearchTool):
12
  """
 
17
  Each search request will be followed by a random delay within the specified range.
18
  """
19
 
20
+ def __init__(self, min_delay: float = 5.0, max_delay: float = 12.0, **kwargs):
21
  """
22
  Initialize the throttled search tool with delay parameters.
23