flashdata-dev's picture
Clarify capability names and simplify documentation
51551f6 verified
Raw History Blame Contribute Delete
1.63 kB
from smolagents import Tool
class FlashDataTool(Tool):
name = 'youtube_search_extended'
description = 'Search YouTube for larger result sets, requesting up to 700 videos per query. Retrieve video IDs and available titles, channels, dates and durations. Default 20, maximum 700 requested results; fewer may be available. Extended Search has separate pricing and is not standard-search pagination. 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 result limit, up to 700. minimum: 1. maximum: 700. '
'Default: 20.',
'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 = 20, filters: dict | None = None) -> dict:
from langchain_flashdata import FlashDataYouTubeExtendedSearch
values = {'query': query, 'max_results': max_results, 'filters': filters}
return FlashDataYouTubeExtendedSearch().invoke({key: value for key, value in values.items() if value is not None})