huytofu92 commited on
Commit
da4e402
·
1 Parent(s): 7b52294

Fix audio tools and add browsing tool instead of visit web page tool

Browse files
Files changed (3) hide show
  1. community_tools.py +10 -2
  2. mini_agents.py +5 -5
  3. tools.py +1 -1
community_tools.py CHANGED
@@ -3,6 +3,10 @@ from langchain_community.agent_toolkits.load_tools import load_tools
3
  from smolagents.tools import Tool, tool
4
  from youtube_transcript_api import YouTubeTranscriptApi
5
  from youtube_transcript_api.proxies import WebshareProxyConfig
 
 
 
 
6
  import os
7
 
8
  google_map_tool = Tool.from_langchain(GooglePlacesTool())
@@ -10,11 +14,15 @@ google_map_tool = Tool.from_langchain(GooglePlacesTool())
10
  from langchain_community.tools import WikipediaQueryRun
11
  from langchain_community.utilities import WikipediaAPIWrapper
12
 
13
- wikipedia_tool = Tool.from_langchain(WikipediaQueryRun(api_wrapper=WikipediaAPIWrapper()))
14
 
15
  arxiv_tools = [Tool.from_langchain(tool) for tool in load_tools(["arxiv"])]
16
 
17
- community_tools = [google_map_tool, wikipedia_tool, *arxiv_tools]
 
 
 
 
18
 
19
  @tool
20
  def get_youtube_transcript_from_url(video_url: str)->str:
 
3
  from smolagents.tools import Tool, tool
4
  from youtube_transcript_api import YouTubeTranscriptApi
5
  from youtube_transcript_api.proxies import WebshareProxyConfig
6
+ from langchain_community.tools.playwright.utils import (
7
+ create_async_playwright_browser
8
+ )
9
+ from langchain_community.agent_toolkits import PlayWrightBrowserToolkit
10
  import os
11
 
12
  google_map_tool = Tool.from_langchain(GooglePlacesTool())
 
14
  from langchain_community.tools import WikipediaQueryRun
15
  from langchain_community.utilities import WikipediaAPIWrapper
16
 
17
+ wikipedia_tool = Tool.from_langchain(WikipediaQueryRun(api_wrapper=WikipediaAPIWrapper(top_k_results=2)))
18
 
19
  arxiv_tools = [Tool.from_langchain(tool) for tool in load_tools(["arxiv"])]
20
 
21
+ async_browser = create_async_playwright_browser()
22
+ browser_toolkit = PlayWrightBrowserToolkit.from_browser(async_browser=async_browser)
23
+ browser_tools = browser_toolkit.get_tools()
24
+
25
+ community_tools = [google_map_tool, wikipedia_tool, *arxiv_tools, *browser_tools]
26
 
27
  @tool
28
  def get_youtube_transcript_from_url(video_url: str)->str:
mini_agents.py CHANGED
@@ -1,9 +1,9 @@
1
  from smolagents import CodeAgent, InferenceClientModel
2
  from tools import sort_list, operate_two_numbers, convert_number, load_dataframe_from_csv, load_dataframe_from_excel
3
- from tools import tavily_search_tool, visit_webpage_tool, read_python_file
4
  from tools import to_dataframe, to_json, get_dataframe_data, get_dataframe_column, get_dataframe_row, get_dataframe_groupby
5
  from vlm_tools import image_processing, object_detection_tool, ocr_scan_tool, extract_images_from_video, get_image_from_file_path, get_video_from_file_path
6
- from audio_tools import transcribe_audio_tool, audio_to_base64, noise_reduction, audio_segmentation, speaker_diarization
7
  from community_tools import community_tools, get_youtube_transcript_from_url
8
  import os
9
  import logging
@@ -54,11 +54,11 @@ audio_model = InferenceClientModel(
54
 
55
  audio_agent = CodeAgent(
56
  model=audio_model,
57
- tools=[transcribe_audio_tool, audio_to_base64, noise_reduction, audio_segmentation, speaker_diarization],
58
  max_steps=6,
59
  additional_authorized_imports=AUTHORIZED_IMPORTS,
60
  name="audio_agent",
61
- description="This agent is responsible for processing audio, transcribing audio and extracting text from it. It cannot process videos."
62
  )
63
 
64
  vlm_model = InferenceClientModel(
@@ -136,7 +136,7 @@ master_model = InferenceClientModel(
136
  master_agent = CodeAgent(
137
  model=master_model,
138
  managed_agents=[audio_agent, vlm_agent, arithmetic_agent, pandas_agent],
139
- tools=[sort_list, get_youtube_transcript_from_url, read_python_file, *community_tools, tavily_search_tool, visit_webpage_tool],
140
  add_base_tools=True,
141
  max_steps=20,
142
  additional_authorized_imports=AUTHORIZED_IMPORTS,
 
1
  from smolagents import CodeAgent, InferenceClientModel
2
  from tools import sort_list, operate_two_numbers, convert_number, load_dataframe_from_csv, load_dataframe_from_excel
3
+ from tools import tavily_search_tool, read_python_file
4
  from tools import to_dataframe, to_json, get_dataframe_data, get_dataframe_column, get_dataframe_row, get_dataframe_groupby
5
  from vlm_tools import image_processing, object_detection_tool, ocr_scan_tool, extract_images_from_video, get_image_from_file_path, get_video_from_file_path
6
+ from audio_tools import transcribe_audio_tool, audio_to_base64_from_file_path, noise_reduction, audio_segmentation, speaker_diarization
7
  from community_tools import community_tools, get_youtube_transcript_from_url
8
  import os
9
  import logging
 
54
 
55
  audio_agent = CodeAgent(
56
  model=audio_model,
57
+ tools=[transcribe_audio_tool, audio_to_base64_from_file_path, noise_reduction, audio_segmentation, speaker_diarization],
58
  max_steps=6,
59
  additional_authorized_imports=AUTHORIZED_IMPORTS,
60
  name="audio_agent",
61
+ description="This agent is responsible for processing audio, loading mp3 audio and converting it to base64, reducing noise, segmenting audio and transcribing audio (in base64 format). It cannot process videos."
62
  )
63
 
64
  vlm_model = InferenceClientModel(
 
136
  master_agent = CodeAgent(
137
  model=master_model,
138
  managed_agents=[audio_agent, vlm_agent, arithmetic_agent, pandas_agent],
139
+ tools=[sort_list, get_youtube_transcript_from_url, read_python_file, *community_tools, tavily_search_tool],
140
  add_base_tools=True,
141
  max_steps=20,
142
  additional_authorized_imports=AUTHORIZED_IMPORTS,
tools.py CHANGED
@@ -60,7 +60,7 @@ def sort_list(my_list: List[int], order: Literal["asc", "desc", "alphabetize", "
60
  return sorted(my_list, reverse=how[order] == "desc")
61
 
62
  #smolagents tools
63
- visit_webpage_tool = VisitWebpageTool()
64
  tavily_search_tool = Tool.from_langchain(TavilySearchResults(k=3))
65
 
66
 
 
60
  return sorted(my_list, reverse=how[order] == "desc")
61
 
62
  #smolagents tools
63
+ # visit_webpage_tool = VisitWebpageTool()
64
  tavily_search_tool = Tool.from_langchain(TavilySearchResults(k=3))
65
 
66