Commit 369ca68a35469730a8d071f149aa7b6254ca9f0b
1 parent
5b31f27b
feat:【ai 大模型】增加 MCP Server Client Starter 示例
Showing
3 changed files
with
16 additions
and
1 deletions
yudao-module-ai/pom.xml
| @@ -193,6 +193,12 @@ | @@ -193,6 +193,12 @@ | ||
| 193 | <version>${spring-ai.version}</version> | 193 | <version>${spring-ai.version}</version> |
| 194 | </dependency> | 194 | </dependency> |
| 195 | 195 | ||
| 196 | + <dependency> | ||
| 197 | + <groupId>org.springframework.ai</groupId> | ||
| 198 | + <artifactId>spring-ai-starter-mcp-client-webflux</artifactId> | ||
| 199 | + <version>${spring-ai.version}</version> | ||
| 200 | + </dependency> | ||
| 201 | + | ||
| 196 | <!-- TinyFlow:AI 工作流 --> | 202 | <!-- TinyFlow:AI 工作流 --> |
| 197 | <dependency> | 203 | <dependency> |
| 198 | <groupId>dev.tinyflow</groupId> | 204 | <groupId>dev.tinyflow</groupId> |
yudao-module-ai/src/main/java/cn/iocoder/yudao/module/ai/service/chat/AiChatMessageServiceImpl.java
| @@ -346,7 +346,8 @@ public class AiChatMessageServiceImpl implements AiChatMessageService { | @@ -346,7 +346,8 @@ public class AiChatMessageServiceImpl implements AiChatMessageService { | ||
| 346 | // 2.2 构建 ChatOptions 对象 | 346 | // 2.2 构建 ChatOptions 对象 |
| 347 | AiPlatformEnum platform = AiPlatformEnum.validatePlatform(model.getPlatform()); | 347 | AiPlatformEnum platform = AiPlatformEnum.validatePlatform(model.getPlatform()); |
| 348 | ChatOptions chatOptions = AiUtils.buildChatOptions(platform, model.getModel(), | 348 | ChatOptions chatOptions = AiUtils.buildChatOptions(platform, model.getModel(), |
| 349 | - conversation.getTemperature(), conversation.getMaxTokens(), toolNames, toolContext); | 349 | + conversation.getTemperature(), conversation.getMaxTokens(), |
| 350 | + toolNames, toolContext); | ||
| 350 | return new Prompt(chatMessages, chatOptions); | 351 | return new Prompt(chatMessages, chatOptions); |
| 351 | } | 352 | } |
| 352 | 353 |
yudao-server/src/main/resources/application.yaml
| @@ -203,6 +203,14 @@ spring: | @@ -203,6 +203,14 @@ spring: | ||
| 203 | version: 1.0.0 | 203 | version: 1.0.0 |
| 204 | instructions: 一个 MCP 示例服务 | 204 | instructions: 一个 MCP 示例服务 |
| 205 | sse-endpoint: /sse | 205 | sse-endpoint: /sse |
| 206 | + client: | ||
| 207 | + enabled: true | ||
| 208 | + name: mcp | ||
| 209 | + sse: | ||
| 210 | + connections: | ||
| 211 | + filesystem: | ||
| 212 | + url: http://127.0.0.1:8089 | ||
| 213 | + sse-endpoint: /sse | ||
| 206 | 214 | ||
| 207 | yudao: | 215 | yudao: |
| 208 | ai: | 216 | ai: |