Commit bd2301eb0713203cbe4a1a0f5019bec2709ec2ae

Authored by YunaiV
1 parent 30c4be14

fix:【ai】单测在 spring-ai 1.1.0 版本下的报错

yudao-module-ai/src/test/java/cn/iocoder/yudao/module/ai/framework/ai/core/model/chat/AnthropicChatModelTest.java
@@ -28,7 +28,7 @@ public class AnthropicChatModelTest { @@ -28,7 +28,7 @@ public class AnthropicChatModelTest {
28 .baseUrl("https://aihubmix.com") 28 .baseUrl("https://aihubmix.com")
29 .build()) 29 .build())
30 .defaultOptions(AnthropicChatOptions.builder() 30 .defaultOptions(AnthropicChatOptions.builder()
31 - .model(AnthropicApi.ChatModel.CLAUDE_SONNET_4) 31 + .model(AnthropicApi.ChatModel.CLAUDE_SONNET_4_5)
32 .temperature(0.7) 32 .temperature(0.7)
33 .maxTokens(4096) 33 .maxTokens(4096)
34 .build()) 34 .build())
@@ -70,7 +70,7 @@ public class AnthropicChatModelTest { @@ -70,7 +70,7 @@ public class AnthropicChatModelTest {
70 List<Message> messages = new ArrayList<>(); 70 List<Message> messages = new ArrayList<>();
71 messages.add(new UserMessage("thkinking 下,1+1 为什么等于 2 ")); 71 messages.add(new UserMessage("thkinking 下,1+1 为什么等于 2 "));
72 AnthropicChatOptions options = AnthropicChatOptions.builder() 72 AnthropicChatOptions options = AnthropicChatOptions.builder()
73 - .model(AnthropicApi.ChatModel.CLAUDE_SONNET_4) 73 + .model(AnthropicApi.ChatModel.CLAUDE_SONNET_4_5)
74 .thinking(AnthropicApi.ThinkingType.ENABLED, 3096) 74 .thinking(AnthropicApi.ThinkingType.ENABLED, 3096)
75 .temperature(1D) 75 .temperature(1D)
76 .build(); 76 .build();
yudao-module-ai/src/test/java/cn/iocoder/yudao/module/ai/framework/ai/core/model/chat/LlamaChatModelTests.java
@@ -9,8 +9,8 @@ import org.springframework.ai.chat.model.ChatResponse; @@ -9,8 +9,8 @@ import org.springframework.ai.chat.model.ChatResponse;
9 import org.springframework.ai.chat.prompt.Prompt; 9 import org.springframework.ai.chat.prompt.Prompt;
10 import org.springframework.ai.ollama.OllamaChatModel; 10 import org.springframework.ai.ollama.OllamaChatModel;
11 import org.springframework.ai.ollama.api.OllamaApi; 11 import org.springframework.ai.ollama.api.OllamaApi;
  12 +import org.springframework.ai.ollama.api.OllamaChatOptions;
12 import org.springframework.ai.ollama.api.OllamaModel; 13 import org.springframework.ai.ollama.api.OllamaModel;
13 -import org.springframework.ai.ollama.api.OllamaOptions;  
14 import reactor.core.publisher.Flux; 14 import reactor.core.publisher.Flux;
15 15
16 import java.util.ArrayList; 16 import java.util.ArrayList;
@@ -27,7 +27,7 @@ public class LlamaChatModelTests { @@ -27,7 +27,7 @@ public class LlamaChatModelTests {
27 .ollamaApi(OllamaApi.builder() 27 .ollamaApi(OllamaApi.builder()
28 .baseUrl("http://127.0.0.1:11434") // Ollama 服务地址 28 .baseUrl("http://127.0.0.1:11434") // Ollama 服务地址
29 .build()) 29 .build())
30 - .defaultOptions(OllamaOptions.builder() 30 + .defaultOptions(OllamaChatOptions.builder()
31 .model(OllamaModel.LLAMA3.getName()) // 模型 31 .model(OllamaModel.LLAMA3.getName()) // 模型
32 .build()) 32 .build())
33 .build(); 33 .build();
@@ -70,7 +70,7 @@ public class LlamaChatModelTests { @@ -70,7 +70,7 @@ public class LlamaChatModelTests {
70 // 准备参数 70 // 准备参数
71 List<Message> messages = new ArrayList<>(); 71 List<Message> messages = new ArrayList<>();
72 messages.add(new UserMessage("详细分析下,如何设计一个电商系统?")); 72 messages.add(new UserMessage("详细分析下,如何设计一个电商系统?"));
73 - OllamaOptions options = OllamaOptions.builder() 73 + OllamaChatOptions options = OllamaChatOptions.builder()
74 .model("qwen3") 74 .model("qwen3")
75 .build(); 75 .build();
76 76
@@ -83,5 +83,4 @@ public class LlamaChatModelTests { @@ -83,5 +83,4 @@ public class LlamaChatModelTests {
83 }).then().block(); 83 }).then().block();
84 } 84 }
85 85
86 -  
87 } 86 }
yudao-module-ai/src/test/java/cn/iocoder/yudao/module/ai/framework/ai/core/model/chat/OllamaChatModelTests.java
@@ -9,7 +9,7 @@ import org.springframework.ai.chat.model.ChatResponse; @@ -9,7 +9,7 @@ import org.springframework.ai.chat.model.ChatResponse;
9 import org.springframework.ai.chat.prompt.Prompt; 9 import org.springframework.ai.chat.prompt.Prompt;
10 import org.springframework.ai.ollama.OllamaChatModel; 10 import org.springframework.ai.ollama.OllamaChatModel;
11 import org.springframework.ai.ollama.api.OllamaApi; 11 import org.springframework.ai.ollama.api.OllamaApi;
12 -import org.springframework.ai.ollama.api.OllamaOptions; 12 +import org.springframework.ai.ollama.api.OllamaChatOptions;
13 import reactor.core.publisher.Flux; 13 import reactor.core.publisher.Flux;
14 14
15 import java.util.ArrayList; 15 import java.util.ArrayList;
@@ -26,7 +26,7 @@ public class OllamaChatModelTests { @@ -26,7 +26,7 @@ public class OllamaChatModelTests {
26 .ollamaApi(OllamaApi.builder() 26 .ollamaApi(OllamaApi.builder()
27 .baseUrl("http://127.0.0.1:11434") // Ollama 服务地址 27 .baseUrl("http://127.0.0.1:11434") // Ollama 服务地址
28 .build()) 28 .build())
29 - .defaultOptions(OllamaOptions.builder() 29 + .defaultOptions(OllamaChatOptions.builder()
30 // .model("qwen") // 模型(https://ollama.com/library/qwen) 30 // .model("qwen") // 模型(https://ollama.com/library/qwen)
31 .model("deepseek-r1") // 模型(https://ollama.com/library/deepseek-r1) 31 .model("deepseek-r1") // 模型(https://ollama.com/library/deepseek-r1)
32 .build()) 32 .build())
yudao-module-ai/src/test/java/cn/iocoder/yudao/module/ai/framework/ai/core/model/chat/ZhiPuAiChatModelTests.java
@@ -23,7 +23,7 @@ import java.util.List; @@ -23,7 +23,7 @@ import java.util.List;
23 public class ZhiPuAiChatModelTests { 23 public class ZhiPuAiChatModelTests {
24 24
25 private final ZhiPuAiChatModel chatModel = new ZhiPuAiChatModel( 25 private final ZhiPuAiChatModel chatModel = new ZhiPuAiChatModel(
26 - new ZhiPuAiApi("2f35fb6ca4ea41fab898729b7fac086c.6ESSfPcCkxaKEUlR"), // 密钥 26 + ZhiPuAiApi.builder().apiKey("2f35fb6ca4ea41fab898729b7fac086c.6ESSfPcCkxaKEUlR").build(), // 密钥
27 ZhiPuAiChatOptions.builder() 27 ZhiPuAiChatOptions.builder()
28 .model(ZhiPuAiApi.ChatModel.GLM_4.getName()) // 模型 28 .model(ZhiPuAiApi.ChatModel.GLM_4.getName()) // 模型
29 .build() 29 .build()
yudao-module-ai/src/test/java/cn/iocoder/yudao/module/ai/framework/ai/core/websearch/AiBoChaWebSearchClientTest.java
@@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.util.json.JsonUtils; @@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
4 import cn.iocoder.yudao.module.ai.framework.ai.core.webserch.AiWebSearchRequest; 4 import cn.iocoder.yudao.module.ai.framework.ai.core.webserch.AiWebSearchRequest;
5 import cn.iocoder.yudao.module.ai.framework.ai.core.webserch.AiWebSearchResponse; 5 import cn.iocoder.yudao.module.ai.framework.ai.core.webserch.AiWebSearchResponse;
6 import cn.iocoder.yudao.module.ai.framework.ai.core.webserch.bocha.AiBoChaWebSearchClient; 6 import cn.iocoder.yudao.module.ai.framework.ai.core.webserch.bocha.AiBoChaWebSearchClient;
  7 +import org.junit.jupiter.api.Disabled;
7 import org.junit.jupiter.api.Test; 8 import org.junit.jupiter.api.Test;
8 9
9 /** 10 /**
@@ -17,6 +18,7 @@ public class AiBoChaWebSearchClientTest { @@ -17,6 +18,7 @@ public class AiBoChaWebSearchClientTest {
17 "sk-40500e52840f4d24b956d0b1d80d9abe"); 18 "sk-40500e52840f4d24b956d0b1d80d9abe");
18 19
19 @Test 20 @Test
  21 + @Disabled
20 public void testSearch() { 22 public void testSearch() {
21 AiWebSearchRequest request = new AiWebSearchRequest() 23 AiWebSearchRequest request = new AiWebSearchRequest()
22 .setQuery("阿里巴巴") 24 .setQuery("阿里巴巴")