Download tool.py from CyberMax-tools/geocode-address-tool: direct link, hf CLI and curl.
- Browser
- Download file 932 Bytes
-
https://huggingface.co/spaces/CyberMax-tools/geocode-address-tool/resolve/main/tool.py
- Command line
-
hf download hf://spaces/CyberMax-tools/geocode-address-tool/tool.py
-
curl -L -o tool.py https://huggingface.co/spaces/CyberMax-tools/geocode-address-tool/resolve/main/tool.py
932 Bytes
| from typing import Any, Optional | |
| from smolagents.tools import Tool | |
| import requests | |
| class GeocodeTool(Tool): | |
| name = "geocode_address" | |
| description = "Pinloft by CyberMax: geocode up to 5 addresses (US Census geocoder first, OpenStreetMap worldwide) to latitude, longitude, formatted address and, for US addresses, county and Census FIPS codes. Separate addresses with '|'. Free tier, no key; paid keys at https://pinloft.cybermax-tools.workers.dev/docs" | |
| inputs = {'addresses': {'type': 'string', 'description': "One address, or several separated by '|'"}} | |
| output_type = "object" | |
| def forward(self, addresses: str): | |
| import requests | |
| r = requests.get("https://pinloft.cybermax-tools.workers.dev/api/geocode", | |
| params={"address": addresses, "via": "smolagents"}, timeout=30) | |
| return r.json() | |
| def __init__(self, *args, **kwargs): | |
| self.is_initialized = False | |