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