news 2026/4/28 21:40:20

SpringAi-mcp高德

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
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(); } }
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/25 21:34:32

二手闲置交易平台商业开源版 带完整的搭建部署教程以及源代码包

温馨提示&#xff1a;文末有资源获取方式 当交易遇见社交&#xff0c;闲置物品流转便拥有了温度与活力。我们推荐一款深度融合社区互动功能的二手交易商城系统&#xff0c;旨在帮助您打造一个以兴趣和信任为纽带的新型交易平台&#xff0c;让买卖不再是冰冷的操作&#xff0c;而…

作者头像 李华
网站建设 2026/4/27 17:27:15

vue3基于python的流浪猫爱心救助系统

目录 Vue3与Python结合的流浪猫爱心救助系统摘要 项目技术支持可定制开发之功能亮点源码获取详细视频演示 &#xff1a;文章底部获取博主联系方式&#xff01;同行可合作 Vue3与Python结合的流浪猫爱心救助系统摘要 技术架构 前端采用Vue3框架实现响应式用户界面&#xff0c;搭…

作者头像 李华
网站建设 2026/4/25 22:28:50

基于Docker部署M3U8流媒体

本方案基于 Docker Nginx-RTMP Nginx&#xff0c;实现将本地 MP4 文件转换为 24/7 循环播放的 HLS (M3U8) 直播流。 一、 环境准备 1、操作系统&#xff1a; 已安装宝塔面板的 Linux 服务器&#xff08;推荐 CentOS 7 或 Ubuntu 20.04&#xff09;。 2、基础软件&#xf…

作者头像 李华