Download tool.py from flashdata-dev/google-places-shortlist-flashdata: direct link, hf CLI and curl.
- Browser
- Download file 2.31 kB
-
https://huggingface.co/spaces/flashdata-dev/google-places-shortlist-flashdata/resolve/main/tool.py
- Command line
-
hf download hf://spaces/flashdata-dev/google-places-shortlist-flashdata/tool.py
-
curl -L -o tool.py https://huggingface.co/spaces/flashdata-dev/google-places-shortlist-flashdata/resolve/main/tool.py
2.31 kB
| from smolagents import Tool | |
| class FlashDataTool(Tool): | |
| name = 'google_places' | |
| description = 'Find local businesses and places by query and location. Get names, addresses, ratings and available website or contact details. Available fields vary by place; results are not an exhaustive business directory. Uses paid FlashData API credits. Never automatically retry an uncertain submission; check Jobs first.' | |
| inputs = {'autocorrect': {'description': 'Enable spelling autocorrection. Default: None.', | |
| 'nullable': True, | |
| 'type': 'boolean'}, | |
| 'gl': {'description': 'Two-letter country code, for example us. pattern: ^[A-Za-z]{2}$. Default: ' | |
| 'None.', | |
| 'nullable': True, | |
| 'type': 'string'}, | |
| 'hl': {'description': 'Interface language code, for example en. pattern: ^[A-Za-z0-9-]{1,35}$. ' | |
| 'Default: None.', | |
| 'nullable': True, | |
| 'type': 'string'}, | |
| 'location': {'description': 'Optional geographic search location. Default: None.', | |
| 'nullable': True, | |
| 'type': 'string'}, | |
| 'num': {'description': 'Requested result count. minimum: 1. maximum: 100. Default: None.', | |
| 'nullable': True, | |
| 'type': 'integer'}, | |
| 'page': {'description': 'Search result page. minimum: 1. maximum: 100. Default: None.', | |
| 'nullable': True, | |
| 'type': 'integer'}, | |
| 'query': {'description': 'Search query, between 1 and 2,000 characters.', 'type': 'string'}, | |
| 'tbs': {'description': 'Optional Google time filter, for example qdr:w. Default: None.', | |
| 'nullable': True, | |
| 'type': 'string'}} | |
| output_type = 'object' | |
| def forward(self, query: str, num: int | None = None, page: int | None = None, autocorrect: bool | None = None, gl: str | None = None, hl: str | None = None, location: str | None = None, tbs: str | None = None) -> dict: | |
| from langchain_flashdata import FlashDataGooglePlaces | |
| values = {'query': query, 'num': num, 'page': page, 'autocorrect': autocorrect, 'gl': gl, 'hl': hl, 'location': location, 'tbs': tbs} | |
| return FlashDataGooglePlaces().invoke({key: value for key, value in values.items() if value is not None}) | |