MCPcopy Create free account
hub / github.com/OpenBMB/BMTools / build_tool

Function build_tool

bmtools/tools/map/baidu_map/baidu_api.py:139–209  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

137 return None
138
139def build_tool(config) -> Tool:
140 tool = Tool(
141 "Map Info",
142 "Look up map information in China",
143 name_for_model="Baidu_Map",
144 description_for_model="Plugin for look up map information in China",
145 logo_url="https://your-app-url.com/.well-known/logo.png",
146 contact_email="hello@contact.com",
147 legal_info_url="hello@legal.com"
148 )
149
150 KEY = config["subscription_key"]
151 SK = config["baidu_secret_key"]
152 baidu_map = BaiduMapAPI(KEY, SK)
153
154 @tool.get("/get_location")
155 def get_location(address: str) -> Optional[Tuple[float, float]]:
156 """
157 该函数仅适用于中国境内地图(内陆),this function only suitable for locations in Mainland China
158 根据地址获取地点经纬度, return the coordinates
159 :param address: 地址
160 :return: 地点经纬度 (纬度, 经度),若无法获取则返回None; return (latitute, longitute)
161 """
162 return baidu_map.get_location(address)
163
164 @tool.get("/get_address_by_coordinates")
165 def get_address_by_coordinates(lat: float, lng: float) -> Optional[str]:
166 """
167 该函数仅适用于中国境内地图(内陆),this function only suitable for locations in Mainland China
168 根据经纬度获取地点名称
169 :param lat: 纬度
170 :param lng: 经度
171 :return: 地点名称列表,包含经纬度,具体地址等信息,若无法获取则返回None
172 """
173 return baidu_map.get_address_by_coordinates(lat, lng)
174
175 @tool.get("/get_nearby_places")
176 def get_nearby_places(location: Tuple[float, float], radius: int, keyword: Optional[str] = '餐厅') -> List[str]:
177 """
178 该函数仅适用于中国境内地图(内陆),this function only suitable for locations in Mainland China
179 查询某位置附近的地点
180 :param location: 地点的经纬度 (纬度, 经度)
181 :param radius: 查询半径(单位:米)
182 :param keyword: 查询关键词(必选)
183 :return: 地点名称列表
184 """
185 return baidu_map.get_nearby_places(location, radius, keyword)
186
187 @tool.get("/get_route")
188 def get_route(self, origin: str, destination: str) -> Optional[List[str]]:
189 """
190 该函数仅适用于中国境内地图(内陆),this function only suitable for locations in Mainland China
191 查询两地之间的路线
192 :param origin: 起点地址
193 :param destination: 终点地址
194 :return: 路线描述列表,若无法获取则返回None
195 """
196 return baidu_map.get_route(origin, destination)

Callers

nothing calls this directly

Calls 2

BaiduMapAPIClass · 0.70
ToolClass · 0.50

Tested by

no test coverage detected