Spaces:
Sleeping
Sleeping
File size: 811 Bytes
3deb166 528f6c4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
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 |