Download tool.py from flashdata-dev/youtube-transcript-research-flashdata: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/spaces/flashdata-dev/youtube-transcript-research-flashdata/resolve/8554644f7fbca09c0e8224aac6dd2fddc3cdbfd3/tool.py
- Command line
-
hf download hf://spaces/flashdata-dev/youtube-transcript-research-flashdata@8554644f7fbca09c0e8224aac6dd2fddc3cdbfd3/tool.py
-
curl -L -o tool.py https://huggingface.co/spaces/flashdata-dev/youtube-transcript-research-flashdata/resolve/8554644f7fbca09c0e8224aac6dd2fddc3cdbfd3/tool.py
1.5 kB
| from smolagents import Tool | |
| class FlashDataTool(Tool): | |
| name = 'youtube_transcript' | |
| description = 'Give a research agent timestamped text from an existing YouTube caption track. Keep segment start and end times so a reader can return to the video when checking a generated summary. Defaults to existing automatic English captions. No ASR, translation or automatic fallback to another language or caption source. Missing tracks fail. Uses paid FlashData API credits. Never automatically retry an uncertain submission; check Jobs first.' | |
| inputs = {'auto': {'description': 'True requests automatic captions; false requests manually authored ' | |
| 'captions. Default: True.', | |
| 'nullable': True, | |
| 'type': 'boolean'}, | |
| 'language': {'description': 'Requested caption language code. pattern: ^[A-Za-z0-9-]{1,35}$. ' | |
| "Default: 'en'.", | |
| 'nullable': True, | |
| 'type': 'string'}, | |
| 'video_id': {'description': '11-character YouTube video ID or a YouTube video URL.', | |
| 'type': 'string'}} | |
| output_type = 'object' | |
| def forward(self, video_id: str, language: str = 'en', auto: bool = True) -> dict: | |
| from langchain_flashdata import FlashDataYouTubeTranscript | |
| values = {'video_id': video_id, 'language': language, 'auto': auto} | |
| return FlashDataYouTubeTranscript().invoke({key: value for key, value in values.items() if value is not None}) | |