1. 系统角色定义
定义一个地图工具Agent,负责将用户的地图请求转为地图工具的调用代码。
#系统角色#
#你是一个非常有用的地图工具agent,负责将用户的地图请求转为地图工具的调用代码、返回poplang代码块。
#地图工具清单
##tool_name:maps_regeocode
工具描述:将一个高德经纬度坐标转换为行政区划地址信息
参数描述:{"type":"object","properties":{"location":{"type":"string","description":"经纬度"}},"required":["location"]}
##tool_name:maps_geo
工具描述:将详细的结构化地址转换为经纬度坐标。支持对地标性名胜景区、建筑物名称解析为经纬度坐标
参数描述:{"type":"object","properties":{"address":{"type":"string","description":"待解析的结构化地址信息"},"city":{"type":"string","description":"指定查询的城市"}},"required":["address"]}
##tool_name:maps_ip_location
工具描述:IP 定位根据用户输入的 IP 地址,定位 IP 的所在位置
参数描述:{"type":"object","properties":{"ip":{"type":"string","description":"IP地址"}},"required":["ip"]}
##tool_name:maps_weather
工具描述:根据城市名称或者标准adcode查询指定城市的天气
参数描述:{"type":"object","properties":{"city":{"type":"string","description":"城市名称或者adcode"}},"required":["city"]}
##tool_name:maps_search_detail
工具描述:查询关键词搜或者周边搜获取到的POI ID的详细信息
参数描述:{"type":"object","properties":{"id":{"type":"string","description":"关键词搜或者周边搜获取到的POI ID"}},"required":["id"]}
##tool_name:maps_bicycling
工具描述:骑行路径规划用于规划骑行通勤方案,规划时会考虑天桥、单行线、封路等情况。最大支持 500km 的骑行路线规划
参数描述:{"type":"object","properties":{"origin":{"type":"string","description":"出发点经纬度,坐标格式为:经度,纬度"},"destination":{"type":"string","description":"目的地经纬度,坐标格式为:经度,纬度"}},"required":["origin","destination"]}
##tool_name:maps_direction_walking
工具描述:步行路径规划 API 可以根据输入起点终点经纬度坐标规划100km 以内的步行通勤方案,并且返回通勤方案的数据
参数描述:{"type":"object","properties":{"origin":{"type":"string","description":"出发点经度,纬度,坐标格式为:经度,纬度"},"destination":{"type":"string","description":"目的地经度,纬度,坐标格式为:经度,纬度"}},"required":["origin","destination"]}
##tool_name:maps_direction_driving
工具描述:驾车路径规划 API 可以根据用户起终点经纬度坐标规划以小客车、轿车通勤出行的方案,并且返回通勤方案的数据。
参数描述:{"type":"object","properties":{"origin":{"type":"string","description":"出发点经度,纬度,坐标格式为:经度,纬度"},"destination":{"type":"string","description":"目的地经度,纬度,坐标格式为:经度,纬度"}},"required":["origin","destination"]}
##tool_name:maps_direction_transit_integrated
工具描述:公交路径规划 API 可以根据用户起终点经纬度坐标规划综合各类公共(火车、公交、地铁)交通方式的通勤方案,并且返回通勤方案的数据,跨城场景下必须传起点城市与终点城市
参数描述:{"type":"object","properties":{"origin":{"type":"string","description":"出发点经度,纬度,坐标格式为:经度,纬度"},"destination":{"type":"string","description":"目的地经度,纬度,坐标格式为:经度,纬度"},"city":{"type":"string","description":"公共交通规划起点城市"},"cityd":{"type":"string","description":"公共交通规划终点城市"}},"required":["origin","destination","city","cityd"]}
##tool_name:maps_distance
工具描述:距离测量 API 可以测量两个经纬度坐标之间的距离,支持驾车、步行以及球面距离测量
参数描述:{"type":"object","properties":{"origins":{"type":"string","description":"起点经度,纬度,可以传多个坐标,使用分号隔离,比如120,30;120,31,坐标格式为:经度,纬度"},"destination":{"type":"string","description":"终点经度,纬度,坐标格式为:经度,纬度"},"type":{"type":"string","description":"距离测量类型,1代表驾车距离测量,0代表直线距离测量,3步行距离测量"}},"required":["origins","destination"]}
##tool_name:maps_text_search
工具描述:关键词搜,根据用户传入关键词,搜索出相关的POI
参数描述:{"type":"object","properties":{"keywords":{"type":"string","description":"搜索关键词"},"city":{"type":"string","description":"查询城市"},"types":{"type":"string","description":"POI类型,比如加油站"}},"required":["keywords"]}
##tool_name:maps_around_search
工具描述:周边搜,根据用户传入关键词以及坐标location,搜索出radius半径范围的POI
参数描述:{"type":"object","properties":{"keywords":{"type":"string","description":"搜索关键词"},"location":{"type":"string","description":"中心点经度纬度"},"radius":{"type":"string","description":"搜索半径"}},"required":["location"]}
2. Poplang智能体定义
使用Poplang代码定义地图工具智能体的核心功能。
#本智能体agent由poplang代码编程,功能为是地图工具agent提供功能代码
#定义智能体的prompt
pop.func.define map_tool_prompt
set prompt **dtns.rtmap地图工具agent支持操作LLM大语言模型通过对话查询地图
pop.func.end
#定义智能体的结果result-prompt函数------将每次api-tool调用完成之后,调用本result函数,以便为LLM提供提示语。
pop.func.define map_result
object.get call_result.ret flag
set tips **经过地图工具查询成功,JSON结果为:
set failed **经过地图工具查询失败,JSON结果为:
?= flag tips failed result_tips
object.get call_result.data data
$.JSON.stringify data
= data $ret
+ result_tips data result_tips
set tips **,请将结果描述为中文
+ result_tips tips result
pop.func.end
# agent全局变量,方便得到调用入口和结果prompt等。
set agent_name dtns.rtmap
#当拿到api-tools的调用结果后,使用这个来拼接结果,返回给llm查看并解析结果。
set agent_callback map_result
#声明描述(方便在后端使用?)
set agent_promt map_tool_prompt
3. 地点坐标查询
查询广州天河区方圆E时光的经纬度坐标。
用户Prompt提示语
查询广州天河区方圆E时光
智体返回的Poplang代码块
set params **{"tool_name":"maps_geo","address":"广州天河区方圆E时光","city":"广州市"}
/rtmap/tool/call params
= call_result $ret
运行结果
经过地图工具查询成功,JSON结果为:{"content":[{"type":"text","text":"{\n \"return\": [\n {\n \"country\": \"中国\",\n \"province\": \"广东省\",\n \"city\": \"广州市\",\n \"citycode\": \"020\",\n \"district\": \"天河区\",\n \"street\": [],\n \"number\": [],\n \"adcode\": \"440106\",\n \"location\": \"113.372514,23.126119\",\n \"level\": \"兴趣点\"\n }\n ]\n}"}],"isError":false},请将结果描述为中文
解析结果
广州天河区方圆E时光的经纬度坐标是:113.372514,23.126119。该地点位于中国广东省广州市天河区,行政区划代码为440106。
4. 驾车导航实现
从佛山民间金融街到广州方圆E时光的驾车导航。
用户Prompt提示语
使用驾车导航
智体返回的Poplang代码块
// 驾车路线规划(佛山民间金融街 → 广州方圆E时光)
set params **{"tool_name":"maps_direction_driving","origin":"113.162019,23.048749","destination":"113.372514,23.126119"}
/rtmap/tool/call params
= call_result $ret
// 说明:
// 1. 起点坐标:佛山民间金融街(113.162019,23.048749)
// 2. 终点坐标:广州方圆E时光(113.372514,23.126119)
// 2. 终点坐标:广州方圆E时光(113.372514,23.126119)
// 3. 返回结果包含:路线距离、耗时、详细导航步骤等信息
运行结果
经过地图工具查询成功,JSON结果为:{"content":[{"type":"text","text":"{\n \"route\": {\n \"origin\": \"113.162019,23.048749\",\n \"destination\": \"113.372514,23.126119\",\n \"paths\": [\n {\n \"distance\": \"32116\",\n \"duration\": \"2847\",\n \"steps\": [\n {\n \"instruction\": \"向南行驶131米右转\",\n \"distance\": \"131\",\n \"orientation\": \"南\",\n \"duration\": \"42\"\n },\n {\n \"instruction\": \"沿南平西路向西行驶61米左转调头\",\n \"road\": \"南平西路\",\n \"distance\": \"61\",\n \"orientation\": \"西\",\n \"duration\": \"42\"\n },\n {\n \"instruction\": \"沿南平西路向东行驶287米左转\",\n \"road\": \"南平西路\",\n \"distance\": \"287\",\n \"orientation\": \"东\",\n \"duration\": \"82\"\n },\n {\n \"instruction\": \"沿华翠北路向北行驶597米向右前方行驶进入右转专用道\",\n \"road\": \"华翠北路\",\n \"distance\": \"597\",\n \"orientation\": \"北\",\n \"duration\": \"67\"\n },\n {\n \"instruction\": \"沿清风路向东北行驶56米右转\",\n \"road\": \"清风路\",\n \"distance\": \"56\",\n \"orientation\": \"东北\",\n \"duration\": \"12\"\n },\n {\n \"instruction\": \"沿清风路向东行驶411米靠左沿主路行驶\",\n \"road\": \"清风路\",\n \"distance\": \"411\",\n \"orientation\": \"东\",\n \"duration\": \"36\"\n },\n {\n \"instruction\": \"沿清风路途径新胜路向东南行驶4.7千米左转\",\n \"road\": \"清风路\",\n \"distance\": \"4741\",\n \"orientation\": \"东南\",\n \"duration\": \"750\"\n },\n {\n \"instruction\": \"沿南港路向东行驶929米向右前方行驶进入匝道\",\n \"road\": \"南港路\",\n \"distance\": \"929\",\n \"orientation\": \"东\",\n \"duration\": \"133\"\n },\n {\n \"instruction\": \"沿花地大道南途径沙尾大桥向东北行驶1.3千米向右前方行驶进入匝道\",\n \"road\": \"花地大道南\",\n \"distance\": \"1293\",\n \"orientation\": \"东北\",\n \"duration\": \"105\"\n },\n {\n \"instruction\": \"沿海南立交桥向东北行驶593米靠右\",\n \"road\": \"海南立交桥\",\n \"distance\": \"593\",\n \"orientation\": \"东北\",\n \"duration\": \"47\"\n },\n {\n \"instruction\": \"沿海南立交桥途径S81广州环城高速、丫髻沙大桥向东行驶15.5千米向右前方行驶进入中间岔道\",\n \"road\": \"海南立交桥\",\n \"distance\": \"15526\",\n \"orientation\": \"东\",\n \"duration\": \"852\"\n },\n {\n \"instruction\": \"沿仑头立交途径S73南沙港快速、科韵南路向东北行驶2.3千米靠左进入左岔路\",\n \"road\": \"仑头立交\",\n \"distance\": \"2345\",\n \"orientation\": \"东北\",\n \"duration\": \"157\"\n },\n {\n \"instruction\": \"沿科韵南路向北行驶295米直行进入隧道\",\n \"road\": \"科韵南路\",\n \"distance\": \"295\",\n \"orientation\": \"北\",\n \"duration\": \"12\"\n },\n {\n \"instruction\": \"沿科韵路新滘东路隧道途径科韵南路、黄埔涌大桥向北行驶1.6千米靠左沿主路行驶\",\n \"road\": \"科韵路新滘东路隧道\",\n \"distance\": \"1613\",\n \"orientation\": \"北\",\n \"duration\": \"93\"\n },\n {\n \"instruction\": \"沿科韵南路途径琶洲大桥向北行驶1.7千米靠左沿主路行驶\",\n \"road\": \"科韵南路\",\n \"distance\": \"1717\",\n \"orientation\": \"北\",\n \"duration\": \"128\"\n },\n {\n \"instruction\": \"沿科韵中路向北行驶824米向右前方行驶进入辅路\",\n \"road\": \"科韵中路\",\n \"distance\": \"824\",\n \"orientation\": \"北\",\n \"duration\": \"70\"\n },\n {\n \"instruction\": \"沿科韵中路辅路向北行驶261米左转调头进入匝道\",\n \"road\": \"科韵中路辅路\",\n \"distance\": \"261\",\n \"orientation\": \"北\",\n \"duration\": \"92\"\n },\n {\n \"instruction\": \"沿科韵路中山大道立交向西南行驶204米右转\",\n \"road\": \"科韵路中山大道立交\",\n \"distance\": \"204\",\n \"orientation\": \"西南\",\n \"duration\": \"38\"\n },\n {\n \"instruction\": \"向西行驶147米左转\",\n \"distance\": \"147\",\n \"orientation\": \"西\",\n \"duration\": \"49\"\n },\n {\n \"instruction\": \"向南行驶52米右转\",\n \"distance\": \"52\",\n \"orientation\": \"南\",\n \"duration\": \"28\"\n },\n {\n \"instruction\": \"向西行驶33米到达目的地\",\n \"distance\": \"33\",\n \"orientation\": \"西\",\n \"duration\": \"12\"\n }\n ]\n }\n ]\n }\n}"}],"isError":false},请将结果描述为中文
导航结果解析
驾车导航路线详情(佛山民间金融街 → 广州方圆E时光)
基础信息
全程距离:32.1公里
预计耗时:约47分钟(2847秒)
详细导航步骤:
起点出发(佛山南海区)
向南行驶131米右转
沿南平西路向西61米后调头
沿南平西路向东287米左转
进入主干道
沿华翠北路向北行驶597米
转入清风路向东北方向行驶(共5.2公里)
途径新胜路、南港路
进入花地大道南,过沙尾大桥(1.3公里)
高速路段(约18公里)
经海南立交桥进入S81广州环城高速
过丫髻沙大桥向东行驶15.5公里
转入S73南沙港快速路向东北行驶
进入广州城区
沿科韵南路/中路行驶(共4.4公里)
途经琶洲大桥、黄埔涌大桥
在科韵中路辅路调头(824米)
到达终点
最后500米通过多次转向进入目的地周边
最终向西行驶33米到达方圆E时光
重要提示
高速路段占比约56%(18公里/32公里)
途径沙尾大桥、丫髻沙大桥等关键节点
终点区域需注意多次转向(最后200米有3次转向)