AI agent 大模型实战之 基于高德MCP的复杂路径规划+可视化展示
AI

async def create_and_run_agent():
client, tools = await create_amap_mcp_client()
agent = create_agent(
model=llm,
tools=tools+file_tools,
debug=True,
response_format = ToolStrategy(ResponseFormat),
#system_prompt="你是一个数学计算专家 直接给出函数计算的结果"
# response_format=ToolStrategy(CountReview)
)
prompt_template = PromptTemplate.from_template("你是一个智能助手,可以调用高德MCP工具\n问题:{input}")
prompt = prompt_template.format(input="""
##我五一计划去昆明游玩4天的旅行攻略。
#帮制作旅行攻略,考虑出行时间和路线,以及天气状况路线规划。
#制作网页地图自定义绘制旅游路线和位置。
##网页使用简约美观页面风格,景区图片以卡片展示。
#行程规划结果在高德地图app展示,并集成到h5页面中。
##同一天行程景区之间我想打车前往。
#在 /Users/shenfei/Downloads/ideamac20231016 目录下生成文件名 map.html。
""")
#异步调用
resp = await agent.ainvoke({"messages": [{"role": "user", "content":prompt}]})
print(resp)
return resp![[衡天云]爆款云服务器 低至12元/月](/hty.png)