Spaces:
Sleeping
Sleeping
| from langchain_community.document_loaders import YoutubeLoader | |
| from smolagents import Tool | |
| class YoutubeTranscriptTool(Tool): | |
| name = "YouTubeTransciptTool" | |
| description = "This tool extracts transcripts from YouTube videos." | |
| inputs = { | |
| "url": { | |
| "type": "string", | |
| "description": "the URL for the YouTube video, like https://www.youtube.com/watch?v=1htKBjuUWec", | |
| } | |
| } | |
| output_type = "string" | |
| def forward(self, url: str) -> str: | |
| """ | |
| Extracts the transcript from the YouTube video. | |
| https://python.langchain.com/docs/integrations/document_loaders/youtube_transcript/ | |
| """ | |
| loader = YoutubeLoader.from_youtube_url(url, add_video_info=False) | |
| document = loader.load() | |
| return document[0].page_content |