Download tool.py from flashdata-dev/youtube-video-search-flashdata: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/spaces/flashdata-dev/youtube-video-search-flashdata/resolve/main/tool.py
- Command line
-
hf download hf://spaces/flashdata-dev/youtube-video-search-flashdata/tool.py
-
curl -L -o tool.py https://huggingface.co/spaces/flashdata-dev/youtube-video-search-flashdata/resolve/main/tool.py
1.51 kB
| from smolagents import Tool | |
| class FlashDataTool(Tool): | |
| name = 'youtube_search' | |
| description = 'Search YouTube by keyword, upload date, duration and other filters. Return video IDs, titles, channels and available video statistics. Request 1–20 results; this adapter defaults to 10. Actual results may be fewer. Transcript retrieval is separate. Uses paid FlashData API credits. Never automatically retry an uncertain submission; check Jobs first.' | |
| inputs = {'filters': {'description': 'Optional YouTube filters: duration, sort_by, type, upload_date and ' | |
| 'boolean feature flags. See the input validation schema in the ' | |
| 'documentation for supported values. Default: None.', | |
| 'nullable': True, | |
| 'type': 'object'}, | |
| 'max_results': {'description': 'Requested number of videos. minimum: 1. maximum: 20. Default: 10.', | |
| 'nullable': True, | |
| 'type': 'integer'}, | |
| 'query': {'description': 'YouTube search query, between 1 and 2,000 characters.', | |
| 'type': 'string'}} | |
| output_type = 'object' | |
| def forward(self, query: str, max_results: int = 10, filters: dict | None = None) -> dict: | |
| from langchain_flashdata import FlashDataYouTubeSearch | |
| values = {'query': query, 'max_results': max_results, 'filters': filters} | |
| return FlashDataYouTubeSearch().invoke({key: value for key, value in values.items() if value is not None}) | |