当前位置: 首页 > news >正文

SpringAi-mcp高德

1.创建key

进入高德官网注册,创建key

https://console.amap.com/dev/id/phone(官网)

2.编写yml文件

引入自己的key

#高德的key AMAP-KEY: #自己的key,复制上

3.创建工具类

3.1AmapService

package com.jiazhong.mingxing.ai.siliconflow.mcp.glm.service; import org.springframework.stereotype.Service; @Service public interface AmapSrvice { String weatherAmap(String city); }

3.2Impl类

package com.jiazhong.mingxing.ai.siliconflow.mcp.glm.service.impl; import com.jiazhong.mingxing.ai.siliconflow.mcp.glm.service.AmapSrvice; import jakarta.annotation.Resource; import org.springframework.ai.tool.annotation.Tool; import org.springframework.ai.tool.annotation.ToolParam; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; @Service public class AmapServiceImpl implements AmapSrvice { @Resource private RestTemplate restTemplate; @Value("${AMAP-KEY}") private String key; @Tool(description = "根据城市获取到具体天气情况") public String weatherAmap(@ToolParam(description = "具体的城市名称") String city) { String url="https://restapi.amap.com/v3/weather/weatherInfo?key="+ key + "&city=" + city + "&extensions=all"; return restTemplate.getForObject(url,String.class); } }

4.注册工具类

@Configuration public class ChatClientConfig { /*@Resource private OpenAiChatModel openAiChatModel; @Resource private NowDateToolService nowDateToolService; @Resource private WeatherJiaService weatherJiaService;*/ @Resource private AmapSrvice amapService; @Bean("openAiChatClient") public ChatClient openAiChatClient(OpenAiChatModel openAiChatModel){ /* FunctionToolCallback<Weather.WeatherRequest,Weather.WeatherResponse> toolCallback =FunctionToolCallback.builder("weatherJiaServiceImpl",weatherJiaService) .description("获取到执行位置的天气").inputType(Weather.WeatherRequest.class).build();*/ return ChatClient.builder(openAiChatModel) /*.defaultTools(currentWeather)*/ /*.defaultToolNames("currentWeather","currentDressing")*/ .defaultTools(amapService) .build(); } }
http://www.jsqmd.com/news/288970/

相关文章:

  • 基于YOLOv5s模型与STM32的嵌入式实时检测系统(设计源文件+万字报告+讲解)(支持资料、图片参考_相关定制)_文章底部可以扫码
  • 基于MATLAB的随机振动仿真与分析完整实现
  • Java高级特性:异常处理与集合框架,零基础入门到精通,收藏这篇就够了
  • 天津金盛昱的管理水平怎么样,和同行对比谁更强
  • 2026钣金加工品牌口碑调查:优质品牌大盘点,评价好的钣金加工品牌推荐排行榜优选实力品牌
  • 七自由度车辆动力学(设计源文件+万字报告+讲解)(支持资料、图片参考_相关定制)_文章底部可以扫码
  • 2026推杆/电动推杆/液压推杆/工业推杆厂家推荐无锡东宇翔,专业可靠,精准耐用
  • 山西鑫瑞泽的长城重载齿轮油、优质齿轮油,口碑如何
  • 【Vue】脚手架 v-html v-text v-bind v-on v-show v-if v-for v-model
  • 解读银川职校特色:银川万通职业技术学校社团多吗,体验好不好?
  • 什么是随机变量
  • 2026上海A-Level培训机构排名及教学质量评估
  • 621-2150输出模块
  • 探讨无锡双瑞机械可靠吗,企业实力为你揭秘
  • 导师推荐8个AI论文工具,助你轻松搞定本科毕业论文!
  • 幂律分布:为什么这个世界总是“赢家通吃“?
  • 621-6550电源输出模块
  • 2026路桥交通/工业园区/地形地貌/建筑规划沙盘模型厂家推荐常州海波模型设计,专业定制,精准呈现
  • 621-6575控制器输出模块
  • 621-6575RC输出模块
  • 上海超级学长怎么样?2026年真实评价与课程体验分享
  • 621-9000逻辑控制器模块
  • 分析大连高精度管道喷涂机设备批发厂家排名,选哪家好?
  • 多项式板子合集
  • 吐血推荐!9款AI论文写作软件测评:本科生毕业论文必备
  • 边缘计算与工业AI:引领企业数字化新潮流 - 教程
  • 2026年(最新)抖音代运营公司TOP榜单权威测评推荐
  • Sona Systems查看发件箱:浏览与使用群发邮件报告日志
  • 佛山职场人配镜攻略:渐进多焦点镜片,哪家验得最舒服?
  • UVA10603 倒水问题