flashdata-dev's picture
Clarify capability names and simplify documentation
a586e92 verified
Raw History Blame Contribute Delete
1.18 kB
from smolagents import Tool
class FlashDataTool(Tool):
name = 'youtube_suggestions'
description = 'Get YouTube autocomplete suggestions for a query prefix. Choose a language and region, and return the suggested search phrases. Suggestions are not search-volume estimates or popularity rankings. Uses paid FlashData API credits. Never automatically retry an uncertain submission; check Jobs first.'
inputs = {'language': {'description': "Language. pattern: ^[A-Za-z0-9-]{1,35}$. Default: 'en'.",
'nullable': True,
'type': 'string'},
'query': {'description': 'YouTube search prefix.', 'type': 'string'},
'region': {'description': "Region. pattern: ^[A-Za-z]{2}$. Default: 'US'.",
'nullable': True,
'type': 'string'}}
output_type = 'object'
def forward(self, query: str, language: str = 'en', region: str = 'US') -> dict:
from langchain_flashdata import FlashDataYouTubeSuggestions
values = {'query': query, 'language': language, 'region': region}
return FlashDataYouTubeSuggestions().invoke({key: value for key, value in values.items() if value is not None})