Spaces:
Sleeping
Sleeping
Add youtube tool
Browse files- community_tools.py +18 -1
- mini_agents.py +2 -2
- requirements.txt +3 -0
community_tools.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
from langchain_google_community import GooglePlacesTool
|
2 |
from langchain_community.agent_toolkits.load_tools import load_tools
|
3 |
-
from
|
|
|
4 |
|
5 |
google_map_tool = Tool.from_langchain(GooglePlacesTool())
|
6 |
|
@@ -12,3 +13,19 @@ wikipedia_tool = Tool.from_langchain(WikipediaQueryRun(api_wrapper=WikipediaAPIW
|
|
12 |
arxiv_tools = [Tool.from_langchain(tool) for tool in load_tools(["arxiv"])]
|
13 |
|
14 |
community_tools = [google_map_tool, wikipedia_tool, *arxiv_tools]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from langchain_google_community import GooglePlacesTool
|
2 |
from langchain_community.agent_toolkits.load_tools import load_tools
|
3 |
+
from langchain_community.document_loaders import YoutubeLoader
|
4 |
+
from smolagents.tools import Tool, tool
|
5 |
|
6 |
google_map_tool = Tool.from_langchain(GooglePlacesTool())
|
7 |
|
|
|
13 |
arxiv_tools = [Tool.from_langchain(tool) for tool in load_tools(["arxiv"])]
|
14 |
|
15 |
community_tools = [google_map_tool, wikipedia_tool, *arxiv_tools]
|
16 |
+
|
17 |
+
@tool
|
18 |
+
def get_youtube_transcript_from_url(video_url: str = None):
|
19 |
+
"""
|
20 |
+
Get the transcript of a YouTube video
|
21 |
+
Args:
|
22 |
+
video_url: The URL of the YouTube video
|
23 |
+
Returns:
|
24 |
+
The transcript of the YouTube video
|
25 |
+
"""
|
26 |
+
youtube_loader = YoutubeLoader(video_url=video_url)
|
27 |
+
docs = youtube_loader.load()
|
28 |
+
transcript = docs[0].page_content
|
29 |
+
return transcript
|
30 |
+
|
31 |
+
get_youtube_transcript_from_url_tool = get_youtube_transcript_from_url()
|
mini_agents.py
CHANGED
@@ -4,7 +4,7 @@ from tools import tavily_search_tool, visit_webpage_tool
|
|
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 download_image, image_processing, object_detection_tool, ocr_scan_tool, extract_frames_from_video
|
6 |
from audio_tools import transcribe_audio_tool, audio_to_base64, noise_reduction, audio_segmentation, speaker_diarization
|
7 |
-
from community_tools import community_tools
|
8 |
import os
|
9 |
import logging
|
10 |
import yaml
|
@@ -124,7 +124,7 @@ master_model = InferenceClientModel(
|
|
124 |
master_agent = CodeAgent(
|
125 |
model=master_model,
|
126 |
managed_agents=[audio_agent, vlm_agent, arithmetic_agent, pandas_agent],
|
127 |
-
tools=[sort_list, *community_tools, tavily_search_tool, visit_webpage_tool],
|
128 |
add_base_tools=True,
|
129 |
max_steps=20,
|
130 |
additional_authorized_imports=["math", "pandas", "json", "numpy", "io", "os", "logging", "yaml", "pyplot", "matplotlib", 'hmmlearn', 'pickle', 'sklearn', 'scipy', 'datetime', 'typing'],
|
|
|
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 download_image, image_processing, object_detection_tool, ocr_scan_tool, extract_frames_from_video
|
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_tool
|
8 |
import os
|
9 |
import logging
|
10 |
import yaml
|
|
|
124 |
master_agent = CodeAgent(
|
125 |
model=master_model,
|
126 |
managed_agents=[audio_agent, vlm_agent, arithmetic_agent, pandas_agent],
|
127 |
+
tools=[sort_list, *community_tools, tavily_search_tool, visit_webpage_tool, get_youtube_transcript_from_url_tool],
|
128 |
add_base_tools=True,
|
129 |
max_steps=20,
|
130 |
additional_authorized_imports=["math", "pandas", "json", "numpy", "io", "os", "logging", "yaml", "pyplot", "matplotlib", 'hmmlearn', 'pickle', 'sklearn', 'scipy', 'datetime', 'typing'],
|
requirements.txt
CHANGED
@@ -16,6 +16,7 @@ coloredlogs==15.0.1
|
|
16 |
contourpy==1.3.2
|
17 |
cycler==0.12.1
|
18 |
dataclasses-json==0.6.7
|
|
|
19 |
deprecation==2.1.0
|
20 |
duckduckgo_search==8.0.2
|
21 |
eyeD3==0.9.8
|
@@ -98,6 +99,7 @@ pytesseract==0.3.13
|
|
98 |
python-dateutil==2.9.0.post0
|
99 |
python-dotenv==1.1.0
|
100 |
python-multipart==0.0.20
|
|
|
101 |
pytz==2025.2
|
102 |
PyYAML==6.0.2
|
103 |
requests==2.32.3
|
@@ -135,4 +137,5 @@ websockets==15.0.1
|
|
135 |
wikipedia==1.4.0
|
136 |
Wikipedia-API==0.8.1
|
137 |
yarl==1.20.0
|
|
|
138 |
zstandard==0.23.0
|
|
|
16 |
contourpy==1.3.2
|
17 |
cycler==0.12.1
|
18 |
dataclasses-json==0.6.7
|
19 |
+
defusedxml==0.7.1
|
20 |
deprecation==2.1.0
|
21 |
duckduckgo_search==8.0.2
|
22 |
eyeD3==0.9.8
|
|
|
99 |
python-dateutil==2.9.0.post0
|
100 |
python-dotenv==1.1.0
|
101 |
python-multipart==0.0.20
|
102 |
+
pytube==15.0.0
|
103 |
pytz==2025.2
|
104 |
PyYAML==6.0.2
|
105 |
requests==2.32.3
|
|
|
137 |
wikipedia==1.4.0
|
138 |
Wikipedia-API==0.8.1
|
139 |
yarl==1.20.0
|
140 |
+
youtube-transcript-api==1.0.3
|
141 |
zstandard==0.23.0
|