MCPcopy
hub / github.com/LazyAGI/LazyLLM / get_city2code

Function get_city2code

lazyllm/tools/tools/weather.py:9–21  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7# assumes the city name is unique
8@lru_cache(maxsize=None)
9def get_city2code():
10 city2code = {}
11
12 res = httpx.get('http://nmc.cn/rest/province')
13 provinces = json.loads(res.text)
14 for prov in provinces:
15 url = f'http://nmc.cn/rest/province/{prov["code"]}'
16 res = httpx.get(url)
17 cities = json.loads(res.text)
18 for c in cities:
19 city2code[c['city']] = c['code']
20
21 return city2code
22
23
24class Weather(HttpTool):

Callers 1

__init__Method · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected