File size: 1,388 Bytes
c0bd27b 50fe588 c0bd27b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | from smolagents import Tool
class FlashDataTool(Tool):
name = 'youtube_metadata'
description = 'Get details for a YouTube video ID: title, description, channel, statistics and available chapters or media-format information. Chapters, statistics and formats depend on availability. Metadata retrieval does not download video or transcript text. Uses paid FlashData API credits. Never automatically retry an uncertain submission; check Jobs first.'
inputs = {'include_chapters': {'description': 'Include available video chapters. Default: True.',
'nullable': True,
'type': 'boolean'},
'include_formats': {'description': 'Include available format metadata. Default: True.',
'nullable': True,
'type': 'boolean'},
'video_id': {'description': '11-character YouTube video ID or a YouTube video URL.',
'type': 'string'}}
output_type = 'object'
def forward(self, video_id: str, include_chapters: bool = True, include_formats: bool = True) -> dict:
from langchain_flashdata import FlashDataYouTubeMetadata
values = {'video_id': video_id, 'include_chapters': include_chapters, 'include_formats': include_formats}
return FlashDataYouTubeMetadata().invoke({key: value for key, value in values.items() if value is not None})
|