集成MCP -> 小艾智能体项目
This commit is contained in:
2
.idea/encodings.xml
generated
2
.idea/encodings.xml
generated
@@ -7,6 +7,8 @@
|
|||||||
<file url="file://$PROJECT_DIR$/langchain4j-ai-image/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/langchain4j-ai-image/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/langchain4j-ai-low-high-api/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/langchain4j-ai-low-high-api/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/langchain4j-ai-low-high-api/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/langchain4j-ai-low-high-api/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/langchain4j-ai-mcp/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/langchain4j-ai-mcp/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/langchain4j-ai-memory/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/langchain4j-ai-memory/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/langchain4j-ai-memory/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/langchain4j-ai-memory/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/langchain4j-ai-model-params/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/langchain4j-ai-model-params/src/main/java" charset="UTF-8" />
|
||||||
|
|||||||
73
langchain4j-ai-mcp/pom.xml
Normal file
73
langchain4j-ai-mcp/pom.xml
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.iwe3</groupId>
|
||||||
|
<artifactId>langchain4j-ai-java</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>langchain4j-ai-mcp</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- MCP Client 依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.langchain4j</groupId>
|
||||||
|
<artifactId>langchain4j-mcp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 接入阿里云百炼平台 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.langchain4j</groupId>
|
||||||
|
<artifactId>langchain4j-community-dashscope-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- Spring Boot Starter Data MongoDB -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!--流式输出-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.langchain4j</groupId>
|
||||||
|
<artifactId>langchain4j-reactor</artifactId>
|
||||||
|
<version>1.9.1-beta17</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!--导入低阶依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.langchain4j</groupId>
|
||||||
|
<artifactId>langchain4j-open-ai-spring-boot-starter</artifactId>
|
||||||
|
<version>1.9.1-beta17</version>
|
||||||
|
</dependency>
|
||||||
|
<!--导入高阶依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.langchain4j</groupId>
|
||||||
|
<artifactId>langchain4j-spring-boot-starter</artifactId>
|
||||||
|
<version>1.9.1-beta17</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.iwe3.langchain4j;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class McpApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(McpApplication.class,args);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package com.iwe3.langchain4j.config;
|
||||||
|
|
||||||
|
import com.iwe3.langchain4j.service.McpService;
|
||||||
|
import dev.langchain4j.mcp.McpToolProvider;
|
||||||
|
import dev.langchain4j.mcp.client.DefaultMcpClient;
|
||||||
|
import dev.langchain4j.mcp.client.McpClient;
|
||||||
|
import dev.langchain4j.mcp.client.transport.McpTransport;
|
||||||
|
import dev.langchain4j.mcp.client.transport.stdio.StdioMcpTransport;
|
||||||
|
import dev.langchain4j.model.chat.StreamingChatModel;
|
||||||
|
import dev.langchain4j.service.AiServices;
|
||||||
|
import dev.langchain4j.service.tool.ToolProvider;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class BaiduMcpConfig {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StreamingChatModel streamingChatModel;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public McpService mcpService(){
|
||||||
|
/**1.构建McpTransport协议
|
||||||
|
*
|
||||||
|
* 1.1 cmd:启动 Windows 命令行解释器。
|
||||||
|
* 1.2 /c:告诉 cmd 执行完后面的命令后关闭自身。
|
||||||
|
* 1.3 npx:npx = npm execute package,Node.js 的一个工具,用于执行 npm 包中的可执行文件。
|
||||||
|
* 1.4 -y 或 --yes:自动确认操作(类似于默认接受所有提示)。
|
||||||
|
* 1.5 @baidumap/mcp-server-baidu-map:要通过 npx 执行的 npm 包名
|
||||||
|
* 1.6 BAIDU_MAP_API_KEY 是访问百度地图开放平台API的AK
|
||||||
|
*/
|
||||||
|
McpTransport transport = new StdioMcpTransport.Builder()
|
||||||
|
.command(List.of("cmd", "/c", "npx", "-y", "@baidumap/mcp-server-baidu-map"))
|
||||||
|
.environment(Map.of("BAIDU_MAP_API_KEY", System.getenv("BAIDU_MAP_API_KEY")))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 2.构建McpClient客户端
|
||||||
|
McpClient mcpClient = new DefaultMcpClient.Builder()
|
||||||
|
.transport(transport)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 3.创建工具集和原生的FunctionCalling类似
|
||||||
|
ToolProvider toolProvider = McpToolProvider.builder()
|
||||||
|
.mcpClients(mcpClient)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 4.通过AiServivces给我们自定义接口McpService构建实现类并将工具集和大模型赋值给AiService
|
||||||
|
return AiServices.builder(McpService.class)
|
||||||
|
.streamingChatModel(streamingChatModel)
|
||||||
|
.toolProvider(toolProvider)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.iwe3.langchain4j.controller;
|
||||||
|
|
||||||
|
import com.iwe3.langchain4j.service.McpService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 知识出处
|
||||||
|
* 第1步,如何进行mcp编码
|
||||||
|
* https://docs.langchain4j.dev/tutorials/mcp#creating-an-mcp-tool-provider
|
||||||
|
*
|
||||||
|
* 第2步,如何使用baidu map mcp,它提供了哪些功能对外服务
|
||||||
|
* https://mcp.so/zh/server/baidu-map/baidu-maps?tab=tools
|
||||||
|
*
|
||||||
|
* http://localhost:9012/lc4j/mcp/chat?question=查询117.173.150.122归属地
|
||||||
|
* http://localhost:9012/lc4j/mcp/chat?question=查询都江堰天气
|
||||||
|
* http://localhost:9012/lc4j/mcp/chat?question=查询成都成华区到都江堰路线规划
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
public class McpCallServerController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private McpService mcpService;
|
||||||
|
|
||||||
|
@GetMapping("/lc4j/mcp/chat")
|
||||||
|
public Flux<String> chat(@RequestParam("question") String question) throws Exception
|
||||||
|
{
|
||||||
|
// 调用我们定义的HighApi接口,通过大模型对百度mcpserver调用
|
||||||
|
return mcpService.chat(question);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.iwe3.langchain4j.service;
|
||||||
|
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
|
||||||
|
public interface McpService
|
||||||
|
{
|
||||||
|
Flux<String> chat(String question);
|
||||||
|
}
|
||||||
27
langchain4j-ai-mcp/src/main/resources/application.yml
Normal file
27
langchain4j-ai-mcp/src/main/resources/application.yml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
server:
|
||||||
|
port: 9012
|
||||||
|
servlet:
|
||||||
|
encoding:
|
||||||
|
charset: UTF-8
|
||||||
|
enabled: true
|
||||||
|
force: true
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: langchain4j-ai-mcp
|
||||||
|
|
||||||
|
langchain4j:
|
||||||
|
community:
|
||||||
|
dashscope:
|
||||||
|
streaming-chat-model:
|
||||||
|
api-key: ${DASH_SCOPE_API_KEY}
|
||||||
|
model-name: qwen-plus
|
||||||
|
chat-model:
|
||||||
|
api-key: ${DASH_SCOPE_API_KEY}
|
||||||
|
model-name: qwen-plus
|
||||||
|
|
||||||
|
# 只有日志级别调整为debug级别,同时配置以上 langchain 日志输出开关才有效
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
dev:
|
||||||
|
langchain4j: DEBUG
|
||||||
@@ -18,6 +18,19 @@
|
|||||||
<knife4j.version>4.3.0</knife4j.version>
|
<knife4j.version>4.3.0</knife4j.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- MCP Client 依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.langchain4j</groupId>
|
||||||
|
<artifactId>langchain4j-mcp</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<!--提出JDK的访问远程模式-->
|
||||||
|
<exclusion>
|
||||||
|
<groupId>dev.langchain4j</groupId>
|
||||||
|
<artifactId>langchain4j-http-client-jdk</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
<!-- 接入阿里云百炼平台 -->
|
<!-- 接入阿里云百炼平台 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.langchain4j</groupId>
|
<groupId>dev.langchain4j</groupId>
|
||||||
|
|||||||
@@ -3,10 +3,13 @@ package com.iwe3.langchain4j;
|
|||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
@MapperScan("com.iwe3.langchain4j.mapper")
|
@MapperScan("com.iwe3.langchain4j.mapper")
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class XiaoAIAgentApplication {
|
public class XiaoAIAgentApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(XiaoAIAgentApplication.class,args);
|
SpringApplication.run(XiaoAIAgentApplication.class,args);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package com.iwe3.langchain4j.config;
|
||||||
|
|
||||||
|
import com.iwe3.langchain4j.mcp.BaiduMcpService;
|
||||||
|
import dev.langchain4j.mcp.McpToolProvider;
|
||||||
|
import dev.langchain4j.mcp.client.DefaultMcpClient;
|
||||||
|
import dev.langchain4j.mcp.client.McpClient;
|
||||||
|
import dev.langchain4j.mcp.client.transport.McpTransport;
|
||||||
|
import dev.langchain4j.mcp.client.transport.stdio.StdioMcpTransport;
|
||||||
|
import dev.langchain4j.model.chat.ChatModel;
|
||||||
|
import dev.langchain4j.model.chat.StreamingChatModel;
|
||||||
|
import dev.langchain4j.service.AiServices;
|
||||||
|
import dev.langchain4j.service.tool.ToolProvider;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class BaiduMcpConfig {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ChatModel chatModelQwen;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public BaiduMcpService baiduMcpService(){
|
||||||
|
|
||||||
|
/**1.构建McpTransport协议
|
||||||
|
*
|
||||||
|
* 1.1 cmd:启动 Windows 命令行解释器。
|
||||||
|
* 1.2 /c:告诉 cmd 执行完后面的命令后关闭自身。
|
||||||
|
* 1.3 npx:npx = npm execute package,Node.js 的一个工具,用于执行 npm 包中的可执行文件。
|
||||||
|
* 1.4 -y 或 --yes:自动确认操作(类似于默认接受所有提示)。
|
||||||
|
* 1.5 @baidumap/mcp-server-baidu-map:要通过 npx 执行的 npm 包名
|
||||||
|
* 1.6 BAIDU_MAP_API_KEY 是访问百度地图开放平台API的AK
|
||||||
|
*/
|
||||||
|
var transport = new StdioMcpTransport.Builder()
|
||||||
|
.command(List.of("cmd", "/c", "npx", "-y", "@baidumap/mcp-server-baidu-map"))
|
||||||
|
.environment(Map.of("BAIDU_MAP_API_KEY", System.getenv("BAIDU_MAP_API_KEY")))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 2.构建McpClient客户端
|
||||||
|
var mcpClient = new DefaultMcpClient.Builder()
|
||||||
|
.transport(transport)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 3.创建工具集和原生的FunctionCalling类似
|
||||||
|
var toolProvider = McpToolProvider.builder()
|
||||||
|
.mcpClients(mcpClient)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 4.通过AiServivces给我们自定义接口McpService构建实现类并将工具集和大模型赋值给AiService
|
||||||
|
return AiServices.builder(BaiduMcpService.class)
|
||||||
|
.chatModel(chatModelQwen)
|
||||||
|
.toolProvider(toolProvider)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.iwe3.langchain4j.config;
|
package com.iwe3.langchain4j.config;
|
||||||
|
|
||||||
|
import dev.langchain4j.model.chat.ChatModel;
|
||||||
import dev.langchain4j.model.chat.StreamingChatModel;
|
import dev.langchain4j.model.chat.StreamingChatModel;
|
||||||
|
import dev.langchain4j.model.openai.OpenAiChatModel;
|
||||||
import dev.langchain4j.model.openai.OpenAiStreamingChatModel;
|
import dev.langchain4j.model.openai.OpenAiStreamingChatModel;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -20,4 +22,19 @@ public class LLMConfig {
|
|||||||
.baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
|
.baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 普通对话接口 chatModelQwen
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public ChatModel chatModelQwen(){
|
||||||
|
/*大模型3件套:apikey ,model-name,base-url */
|
||||||
|
return OpenAiChatModel.builder()
|
||||||
|
.apiKey(System.getenv("DASH_SCOPE_API_KEY"))
|
||||||
|
.modelName("qwen-plus")
|
||||||
|
.baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.iwe3.langchain4j.mcp;
|
||||||
|
|
||||||
|
public interface BaiduMcpService
|
||||||
|
{
|
||||||
|
String chat(String question);
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ import reactor.core.publisher.Flux;
|
|||||||
@AiService(wiringMode = AiServiceWiringMode.EXPLICIT
|
@AiService(wiringMode = AiServiceWiringMode.EXPLICIT
|
||||||
,streamingChatModel = "streamingChatModel",
|
,streamingChatModel = "streamingChatModel",
|
||||||
chatMemoryProvider = "chatMemoryProvider",
|
chatMemoryProvider = "chatMemoryProvider",
|
||||||
tools = {"appointmentTools"},
|
tools = {"appointmentTools","baiduMcpTools"},
|
||||||
contentRetriever = "contentRetrieverInPinecone")
|
contentRetriever = "contentRetrieverInPinecone")
|
||||||
public interface XiaoAIChatAssistant {
|
public interface XiaoAIChatAssistant {
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.iwe3.langchain4j.tools;
|
||||||
|
|
||||||
|
import com.iwe3.langchain4j.mcp.BaiduMcpService;
|
||||||
|
import dev.langchain4j.agent.tool.P;
|
||||||
|
import dev.langchain4j.agent.tool.Tool;
|
||||||
|
import dev.langchain4j.agent.tool.ToolSpecification;
|
||||||
|
import dev.langchain4j.data.message.UserMessage;
|
||||||
|
import dev.langchain4j.mcp.McpToolProvider;
|
||||||
|
import dev.langchain4j.mcp.client.McpClient;
|
||||||
|
import dev.langchain4j.model.chat.ChatModel;
|
||||||
|
import dev.langchain4j.model.chat.request.ChatRequest;
|
||||||
|
import dev.langchain4j.model.chat.response.ChatResponse;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class BaiduMcpTools {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BaiduMcpService baiduMcpService;
|
||||||
|
|
||||||
|
@Tool(name = "query_baidu_mcp",value = """
|
||||||
|
该工具通过调用百度 MCP(多能力服务平台)来回答用户问题。
|
||||||
|
支持以下三类查询:
|
||||||
|
- IP 地址归属地:例如,“IP 地址 8.8.8.8 位于哪里?”
|
||||||
|
- 天气预报:例如,“今天成都天气怎么样?”
|
||||||
|
- 前往华西医院的交通路线:例如,“从春熙路怎么去华西医院?”
|
||||||
|
输入:一个与 IP 归属地、天气或华西医院路线相关的自然语言问题。
|
||||||
|
输出:来自 MCP 服务的简洁、准确的事实性回答。
|
||||||
|
只要用户询问上述任一类型的问题,必须使用此工具,不得自行回答。
|
||||||
|
""")
|
||||||
|
public String invocationBaiduMcpServer(String question) {
|
||||||
|
System.out.println("调用百度MCP服务开始!");
|
||||||
|
return baiduMcpService.chat(question);
|
||||||
|
}
|
||||||
|
}
|
||||||
1
pom.xml
1
pom.xml
@@ -24,6 +24,7 @@
|
|||||||
<module>langchain4j-ai-tools</module>
|
<module>langchain4j-ai-tools</module>
|
||||||
<module>langchain4j-ai-rag</module>
|
<module>langchain4j-ai-rag</module>
|
||||||
<module>langchain4j-ai-pinecone</module>
|
<module>langchain4j-ai-pinecone</module>
|
||||||
|
<module>langchain4j-ai-mcp</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
Reference in New Issue
Block a user