tonko22 commited on
Commit
7cc9db2
·
1 Parent(s): 71067ea

add analysis model_id arg

Browse files
Files changed (3) hide show
  1. agents/single_agent.py +5 -4
  2. app.py +1 -1
  3. tools/analysis_tools.py +5 -2
agents/single_agent.py CHANGED
@@ -3,21 +3,22 @@ Web agent for finding and extracting song lyrics from online sources.
3
  """
4
 
5
  from loguru import logger
6
- from smolagents import CodeAgent, VisitWebpageTool, FinalAnswerTool, DuckDuckGoSearchTool
7
 
8
  from config import load_prompt_templates
9
  from tools.analysis_tools import AnalyzeLyricsTool
10
  from tools.formatting_tools import FormatAnalysisResultsTool
11
- from tools.search_tools import ThrottledDuckDuckGoSearchTool, BraveSearchTool
12
  from tools.image_generation_tools import GenerateImageTool
13
 
14
 
15
- def create_single_agent(model):
16
  """
17
  Create an agent specialized in web browsing and lyrics extraction.
18
 
19
  Args:
20
  model: The LLM model to use with this agent
 
21
 
22
  Returns:
23
  A configured CodeAgent for web searches
@@ -31,7 +32,7 @@ def create_single_agent(model):
31
  BraveSearchTool(),
32
  # ThrottledDuckDuckGoSearchTool(min_delay=7.0, max_delay=15.0),
33
  VisitWebpageTool(),
34
- AnalyzeLyricsTool(),
35
  FormatAnalysisResultsTool(),
36
  GenerateImageTool(),
37
  FinalAnswerTool(),
 
3
  """
4
 
5
  from loguru import logger
6
+ from smolagents import CodeAgent, VisitWebpageTool, FinalAnswerTool
7
 
8
  from config import load_prompt_templates
9
  from tools.analysis_tools import AnalyzeLyricsTool
10
  from tools.formatting_tools import FormatAnalysisResultsTool
11
+ from tools.search_tools import BraveSearchTool
12
  from tools.image_generation_tools import GenerateImageTool
13
 
14
 
15
+ def create_single_agent(model, analysis_tool_model_id=None):
16
  """
17
  Create an agent specialized in web browsing and lyrics extraction.
18
 
19
  Args:
20
  model: The LLM model to use with this agent
21
+ model_id: The model ID string to use for lyrics analysis (optional)
22
 
23
  Returns:
24
  A configured CodeAgent for web searches
 
32
  BraveSearchTool(),
33
  # ThrottledDuckDuckGoSearchTool(min_delay=7.0, max_delay=15.0),
34
  VisitWebpageTool(),
35
+ AnalyzeLyricsTool(model_id=analysis_tool_model_id),
36
  FormatAnalysisResultsTool(),
37
  GenerateImageTool(),
38
  FinalAnswerTool(),
app.py CHANGED
@@ -46,7 +46,7 @@ def main():
46
  model = LiteLLMModel(model_id=model_id)
47
 
48
  # Create the manager agent which will create and manage the other agents
49
- single_agent = create_single_agent(model)
50
 
51
  # Start the Gradio UI server
52
  logger.info("Initializing Gradio UI and launching server")
 
46
  model = LiteLLMModel(model_id=model_id)
47
 
48
  # Create the manager agent which will create and manage the other agents
49
+ single_agent = create_single_agent(model, analysis_tool_model_id=model_id)
50
 
51
  # Start the Gradio UI server
52
  logger.info("Initializing Gradio UI and launching server")
tools/analysis_tools.py CHANGED
@@ -22,6 +22,10 @@ class AnalyzeLyricsTool(Tool):
22
  }
23
  output_type = "string"
24
 
 
 
 
 
25
  def forward(self, song_title: str, artist: str, lyrics: str) -> str:
26
  """
27
  Performs a deep analysis of the given lyrics and artist metadata.
@@ -69,8 +73,7 @@ class AnalyzeLyricsTool(Tool):
69
  {lyrics}
70
  """
71
 
72
- # model_to_use = "gemini/gemini-2.0-flash"
73
- model_to_use = "openrouter/google/gemini-2.0-flash-lite-preview-02-05:free"
74
  logger.info("Using {} for lyrics analysis", model_to_use)
75
 
76
  # Use the function with retry mechanism
 
22
  }
23
  output_type = "string"
24
 
25
+ def __init__(self, model_id=None):
26
+ super().__init__()
27
+ self.model_id = model_id or "openrouter/google/gemini-2.0-flash-lite-preview-02-05:free"
28
+
29
  def forward(self, song_title: str, artist: str, lyrics: str) -> str:
30
  """
31
  Performs a deep analysis of the given lyrics and artist metadata.
 
73
  {lyrics}
74
  """
75
 
76
+ model_to_use = self.model_id
 
77
  logger.info("Using {} for lyrics analysis", model_to_use)
78
 
79
  # Use the function with retry mechanism