diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/AnthropicChatModelTest.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/AnthropicChatModelTest.java deleted file mode 100644 index 4b3dd11..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/AnthropicChatModelTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.anthropic.AnthropicChatModel; -import org.springframework.ai.anthropic.AnthropicChatOptions; -import org.springframework.ai.anthropic.api.AnthropicApi; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.SystemMessage; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link AnthropicChatModel} 集成测试类 - * - * @author 研筑科技 - */ -public class AnthropicChatModelTest { - - private final AnthropicChatModel chatModel = AnthropicChatModel.builder() - .anthropicApi(AnthropicApi.builder() - .apiKey("sk-muubv7cXeLw0Etgs743f365cD5Ea44429946Fa7e672d8942") - .baseUrl("https://aihubmix.com") - .build()) - .defaultOptions(AnthropicChatOptions.builder() - .model(AnthropicApi.ChatModel.CLAUDE_SONNET_4_5) - .temperature(0.7) - .maxTokens(4096) - .build()) - .build(); - - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(System.out::println).then().block(); - } - - // TODO @芋艿:需要等 spring ai 升级:https://github.com/spring-projects/spring-ai/pull/2800 - @Test - @Disabled - public void testStream_thinking() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new UserMessage("thkinking 下,1+1 为什么等于 2 ")); - AnthropicChatOptions options = AnthropicChatOptions.builder() - .model(AnthropicApi.ChatModel.CLAUDE_SONNET_4_5) - .thinking(AnthropicApi.ThinkingType.ENABLED, 3096) - .temperature(1D) - .build(); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages, options)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult()); - }).then().block(); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/AzureOpenAIChatModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/AzureOpenAIChatModelTests.java deleted file mode 100644 index 390d1d4..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/AzureOpenAIChatModelTests.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import com.azure.ai.openai.OpenAIClientBuilder; -import com.azure.core.credential.AzureKeyCredential; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.azure.openai.AzureOpenAiChatModel; -import org.springframework.ai.azure.openai.AzureOpenAiChatOptions; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.SystemMessage; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -import static org.springframework.ai.model.azure.openai.autoconfigure.AzureOpenAiChatProperties.DEFAULT_DEPLOYMENT_NAME; - -/** - * {@link AzureOpenAiChatModel} 集成测试 - * - * @author 研筑科技 - */ -public class AzureOpenAIChatModelTests { - - // TODO @芋艿:晚点在调整 - private final OpenAIClientBuilder openAiApi = new OpenAIClientBuilder() - .endpoint("https://eastusprejade.openai.azure.com") - .credential(new AzureKeyCredential("xxx")); - private final AzureOpenAiChatModel chatModel = AzureOpenAiChatModel.builder() - .openAIClientBuilder(openAiApi) - .defaultOptions(AzureOpenAiChatOptions.builder() - .deploymentName(DEFAULT_DEPLOYMENT_NAME) - .build()) - .build(); - - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - System.out.println(response.getResult().getOutput()); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/BaiChuanChatModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/BaiChuanChatModelTests.java deleted file mode 100644 index c69adc1..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/BaiChuanChatModelTests.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import com.yanzhu.module.ai.framework.ai.core.model.baichuan.BaiChuanChatModel; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.SystemMessage; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.openai.OpenAiChatModel; -import org.springframework.ai.openai.OpenAiChatOptions; -import org.springframework.ai.openai.api.OpenAiApi; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link BaiChuanChatModel} 集成测试 - * - * @author 研筑科技 - */ -public class BaiChuanChatModelTests { - - private final OpenAiChatModel openAiChatModel = OpenAiChatModel.builder() - .openAiApi(OpenAiApi.builder() - .baseUrl(BaiChuanChatModel.BASE_URL) - .apiKey("sk-61b6766a94c70786ed02673f5e16af3c") // apiKey - .build()) - .defaultOptions(OpenAiChatOptions.builder() - .model("Baichuan4-Turbo") // 模型(https://platform.baichuan-ai.com/docs/api) - .temperature(0.7) - .build()) - .build(); - - private final BaiChuanChatModel chatModel = new BaiChuanChatModel(openAiChatModel); - - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(System.out::println).then().block(); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/CozeChatModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/CozeChatModelTests.java deleted file mode 100644 index adb7906..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/CozeChatModelTests.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.SystemMessage; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.openai.OpenAiChatModel; -import org.springframework.ai.openai.api.OpenAiApi; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -/** - * 基于 {@link OpenAiChatModel} 集成 Coze 测试 - * - * @author 研筑科技 - */ -public class CozeChatModelTests { - - private final OpenAiChatModel chatModel = OpenAiChatModel.builder() - .openAiApi(OpenAiApi.builder() - .baseUrl("http://127.0.0.1:3000") - .apiKey("app-4hy2d7fJauSbrKbzTKX1afuP") // apiKey - .build()) - .build(); - - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - System.out.println(response.getResult().getOutput()); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/DeepSeekChatModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/DeepSeekChatModelTests.java deleted file mode 100644 index ec0501b..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/DeepSeekChatModelTests.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.SystemMessage; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.deepseek.DeepSeekChatModel; -import org.springframework.ai.deepseek.DeepSeekChatOptions; -import org.springframework.ai.deepseek.api.DeepSeekApi; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link DeepSeekChatModel} 集成测试 - * - * @author 研筑科技 - */ -public class DeepSeekChatModelTests { - - private final DeepSeekChatModel chatModel = DeepSeekChatModel.builder() - .deepSeekApi(DeepSeekApi.builder() - .apiKey("sk-eaf4172a057344dd9bc64b1f806b6axx") // apiKey - .build()) - .defaultOptions(DeepSeekChatOptions.builder() - .model("deepseek-chat") // 模型 - .temperature(0.7) - .build()) - .build(); - - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(System.out::println).then().block(); - } - - @Test - @Disabled - public void testStream_thinking() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new UserMessage("详细分析下,如何设计一个电商系统?")); - DeepSeekChatOptions options = DeepSeekChatOptions.builder() - .model("deepseek-reasoner") - .build(); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages, options)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/DifyChatModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/DifyChatModelTests.java deleted file mode 100644 index 571dd73..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/DifyChatModelTests.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.SystemMessage; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.openai.OpenAiChatModel; -import org.springframework.ai.openai.api.OpenAiApi; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -/** - * 基于 {@link OpenAiChatModel} 集成 Dify 测试 - * - * @author 研筑科技 - */ -public class DifyChatModelTests { - - private final OpenAiChatModel chatModel = OpenAiChatModel.builder() - .openAiApi(OpenAiApi.builder() - .baseUrl("http://127.0.0.1:3000") - .apiKey("app-4hy2d7fJauSbrKbzTKX1afuP") // apiKey - .build()) - .build(); - - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - System.out.println(response.getResult().getOutput()); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/DouBaoChatModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/DouBaoChatModelTests.java deleted file mode 100644 index 34840aa..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/DouBaoChatModelTests.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import com.yanzhu.module.ai.framework.ai.core.model.doubao.DouBaoChatModel; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.SystemMessage; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.deepseek.DeepSeekChatModel; -import org.springframework.ai.deepseek.DeepSeekChatOptions; -import org.springframework.ai.deepseek.api.DeepSeekApi; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link DouBaoChatModel} 集成测试 - * - * @author 研筑科技 - */ -public class DouBaoChatModelTests { - - /** - * 相比 OpenAIChatModel 来说,DeepSeekChatModel 可以兼容豆包的 thinking 能力! - */ - private final DeepSeekChatModel openAiChatModel = DeepSeekChatModel.builder() - .deepSeekApi(DeepSeekApi.builder() - .baseUrl(DouBaoChatModel.BASE_URL) - .completionsPath(DouBaoChatModel.COMPLETE_PATH) - .apiKey("5c1b5747-26d2-4ebd-a4e0-dd0e8d8b4272") // apiKey - .build()) - .defaultOptions(DeepSeekChatOptions.builder() - .model("doubao-1-5-lite-32k-250115") // 模型(doubao) -// .model("doubao-seed-1-6-thinking-250715") // 模型(doubao) -// .model("deepseek-r1-250120") // 模型(deepseek) - .temperature(0.7) - .build()) - .build(); - - private final DouBaoChatModel chatModel = new DouBaoChatModel(openAiChatModel); - - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("详细推理下,帮我设计一个用户中心!")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(System.out::println).then().block(); - } - - @Test - @Disabled - public void testStream_thinking() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new UserMessage("详细分析下,如何设计一个电商系统?")); - DeepSeekChatOptions options = DeepSeekChatOptions.builder() - .model("doubao-seed-1-6-thinking-250715") - .build(); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages, options)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/FastGPTChatModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/FastGPTChatModelTests.java deleted file mode 100644 index 1f5f7ab..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/FastGPTChatModelTests.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.SystemMessage; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.openai.OpenAiChatModel; -import org.springframework.ai.openai.api.OpenAiApi; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -/** - * 基于 {@link OpenAiChatModel} 集成 FastGPT 测试 - * - * @author 研筑科技 - */ -public class FastGPTChatModelTests { - - private final OpenAiChatModel chatModel = OpenAiChatModel.builder() - .openAiApi(OpenAiApi.builder() - .baseUrl("https://cloud.fastgpt.cn/api") - .apiKey("fastgpt-aqcc61kFtF8CeaglnGAfQOCIDWwjGdJVJHv6hIlMo28otFlva2aZNK") // apiKey - .build()) - .build(); - - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - System.out.println(response.getResult().getOutput()); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/GeminiChatModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/GeminiChatModelTests.java deleted file mode 100644 index eb24fd8..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/GeminiChatModelTests.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import com.yanzhu.module.ai.framework.ai.core.model.gemini.GeminiChatModel; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.SystemMessage; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.openai.OpenAiChatModel; -import org.springframework.ai.openai.OpenAiChatOptions; -import org.springframework.ai.openai.api.OpenAiApi; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link GeminiChatModel} 集成测试 - * - * @author 研筑科技 - */ -public class GeminiChatModelTests { - - private final OpenAiChatModel openAiChatModel = OpenAiChatModel.builder() - .openAiApi(OpenAiApi.builder() - .baseUrl(GeminiChatModel.BASE_URL) - .completionsPath(GeminiChatModel.COMPLETE_PATH) - .apiKey("AIzaSyAVoBxgoFvvte820vEQMma2LKBnC98bqMQ") - .build()) - .defaultOptions(OpenAiChatOptions.builder() - .model(GeminiChatModel.MODEL_DEFAULT) // 模型 - .temperature(0.7) - .build()) - .build(); - - private final GeminiChatModel chatModel = new GeminiChatModel(openAiChatModel); - - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(System.out::println).then().block(); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/HunYuanChatModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/HunYuanChatModelTests.java deleted file mode 100644 index 2d6d00a..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/HunYuanChatModelTests.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import com.yanzhu.module.ai.framework.ai.core.model.hunyuan.HunYuanChatModel; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.SystemMessage; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.deepseek.DeepSeekChatModel; -import org.springframework.ai.deepseek.DeepSeekChatOptions; -import org.springframework.ai.deepseek.api.DeepSeekApi; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link HunYuanChatModel} 集成测试 - * - * @author 研筑科技 - */ -public class HunYuanChatModelTests { - - private final DeepSeekChatModel openAiChatModel = DeepSeekChatModel.builder() - .deepSeekApi(DeepSeekApi.builder() - .baseUrl(HunYuanChatModel.BASE_URL) - .completionsPath(HunYuanChatModel.COMPLETE_PATH) - .apiKey("sk-abc") // apiKey - .build()) - .defaultOptions(DeepSeekChatOptions.builder() - .model(HunYuanChatModel.MODEL_DEFAULT) // 模型 - .temperature(0.7) - .build()) - .build(); - - private final HunYuanChatModel chatModel = new HunYuanChatModel(openAiChatModel); - - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(System.out::println).then().block(); - } - - @Test - @Disabled - public void testStream_thinking() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new UserMessage("详细分析下,如何设计一个电商系统?")); - DeepSeekChatOptions options = DeepSeekChatOptions.builder() - .model("hunyuan-a13b") -// .model("hunyuan-turbos-latest") - .build(); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages, options)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - - private final DeepSeekChatModel deepSeekOpenAiChatModel = DeepSeekChatModel.builder() - .deepSeekApi(DeepSeekApi.builder() - .baseUrl(HunYuanChatModel.DEEP_SEEK_BASE_URL) - .completionsPath(HunYuanChatModel.COMPLETE_PATH) - .apiKey("sk-abc") // apiKey - .build()) - .defaultOptions(DeepSeekChatOptions.builder() -// .model(HunYuanChatModel.DEEP_SEEK_MODEL_DEFAULT) // 模型("deepseek-v3") - .model("deepseek-r1") // 模型("deepseek-r1") - .temperature(0.7) - .build()) - .build(); - - private final HunYuanChatModel deepSeekChatModel = new HunYuanChatModel(deepSeekOpenAiChatModel); - - @Test - @Disabled - public void testCall_deepseek() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = deepSeekChatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - } - - @Test - @Disabled - public void testStream_deepseek() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - Flux flux = deepSeekChatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(System.out::println).then().block(); - } - - @Test - @Disabled - public void testStream_deepseek_thinking() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new UserMessage("详细分析下,如何设计一个电商系统?")); - DeepSeekChatOptions options = DeepSeekChatOptions.builder() - .model("deepseek-r1") - .build(); - - // 调用 - Flux flux = deepSeekChatModel.stream(new Prompt(messages, options)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/LlamaChatModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/LlamaChatModelTests.java deleted file mode 100644 index 033f58b..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/LlamaChatModelTests.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.SystemMessage; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.ollama.OllamaChatModel; -import org.springframework.ai.ollama.api.OllamaApi; -import org.springframework.ai.ollama.api.OllamaChatOptions; -import org.springframework.ai.ollama.api.OllamaModel; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link OllamaChatModel} 集成测试 - * - * @author 研筑科技 - */ -public class LlamaChatModelTests { - - private final OllamaChatModel chatModel = OllamaChatModel.builder() - .ollamaApi(OllamaApi.builder() - .baseUrl("http://127.0.0.1:11434") // Ollama 服务地址 - .build()) - .defaultOptions(OllamaChatOptions.builder() - .model(OllamaModel.LLAMA3.getName()) // 模型 - .build()) - .build(); - - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - System.out.println(response.getResult().getOutput()); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - - @Test - @Disabled - public void testStream_thinking() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new UserMessage("详细分析下,如何设计一个电商系统?")); - OllamaChatOptions options = OllamaChatOptions.builder() - .model("qwen3") - .build(); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages, options)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/MiniMaxChatModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/MiniMaxChatModelTests.java deleted file mode 100644 index 86985b7..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/MiniMaxChatModelTests.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.SystemMessage; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.minimax.MiniMaxChatModel; -import org.springframework.ai.minimax.MiniMaxChatOptions; -import org.springframework.ai.minimax.api.MiniMaxApi; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link MiniMaxChatModel} 的集成测试 - * - * @author 研筑科技 - */ -public class MiniMaxChatModelTests { - - private final MiniMaxChatModel chatModel = new MiniMaxChatModel( - new MiniMaxApi("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJHcm91cE5hbWUiOiLnjovmlofmlowiLCJVc2VyTmFtZSI6IueOi-aWh-aWjCIsIkFjY291bnQiOiIiLCJTdWJqZWN0SUQiOiIxODk3Mjg3MjQ5NDU2ODA4MzQ2IiwiUGhvbmUiOiIxNTYwMTY5MTM5OSIsIkdyb3VwSUQiOiIxODk3Mjg3MjQ5NDQ4NDE5NzM4IiwiUGFnZU5hbWUiOiIiLCJNYWlsIjoiIiwiQ3JlYXRlVGltZSI6IjIwMjUtMDMtMTEgMTI6NTI6MDIiLCJUb2tlblR5cGUiOjEsImlzcyI6Im1pbmltYXgifQ.aAuB7gWW_oA4IYhh-CF7c9MfWWxKN49B_HK-DYjXaDwwffhiG-H1571z1WQhp9QytWG-DqgLejneeSxkiq1wQIe3FsEP2wz4BmGBct31LehbJu8ehLxg_vg75Uod1nFAHbm5mZz6JSVLNIlSo87Xr3UtSzJhAXlapEkcqlA4YOzOpKrZ8l5_OJPTORTCmHWZYgJcRS-faNiH62ZnUEHUozesTFhubJHo5GfJCw_edlnmfSUocERV1BjWvenhZ9My-aYXNktcW9WaSj9l6gayV7A0Ium_PL55T9ln1PcI8gayiVUKJGJDoqNyF1AF9_aF9NOKtTnQzwNqnZdlTYH6hw"), // 密钥 - MiniMaxChatOptions.builder() - .model(MiniMaxApi.ChatModel.ABAB_6_5_G_Chat.getValue()) // 模型 - .build()); - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - System.out.println(response.getResult().getOutput()); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - - // TODO @芋艿:暂时没解析 reasoning_content 结果,需要等官方修复 - @Test - @Disabled - public void testStream_thinking() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new UserMessage("详细分析下,如何设计一个电商系统?")); - MiniMaxChatOptions options = MiniMaxChatOptions.builder() - .model("MiniMax-M1") - .build(); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages, options)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/MoonshotChatModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/MoonshotChatModelTests.java deleted file mode 100644 index f064eda..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/MoonshotChatModelTests.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springaicommunity.moonshot.MoonshotChatModel; -import org.springaicommunity.moonshot.MoonshotChatOptions; -import org.springaicommunity.moonshot.api.MoonshotApi; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.SystemMessage; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link MoonshotChatModel} 的集成测试 - * - * @author 研筑科技 - */ -public class MoonshotChatModelTests { - - private final MoonshotChatModel chatModel = MoonshotChatModel.builder() - .moonshotApi(MoonshotApi.builder() - .apiKey("sk-aHYYV1SARscItye5QQRRNbXij4fy65Ee7pNZlC9gsSQnUKXA") // 密钥 - .build()) - .defaultOptions(MoonshotChatOptions.builder() - .model("kimi-k2-0711-preview") // 模型 - .build()) - .build(); - - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - System.out.println(response.getResult().getOutput()); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - - // TODO @芋艿:暂时没解析 reasoning_content 结果,需要等官方修复 - @Test - @Disabled - public void testStream_thinking() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new UserMessage("详细分析下,如何设计一个电商系统?")); - MoonshotChatOptions options = MoonshotChatOptions.builder() -// .model("kimi-k2-0711-preview") - .model("kimi-thinking-preview") - .build(); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages, options)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/OllamaChatModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/OllamaChatModelTests.java deleted file mode 100644 index 4f595e2..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/OllamaChatModelTests.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.SystemMessage; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.ollama.OllamaChatModel; -import org.springframework.ai.ollama.api.OllamaApi; -import org.springframework.ai.ollama.api.OllamaChatOptions; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link OllamaChatModel} 集成测试 - * - * @author 研筑科技 - */ -public class OllamaChatModelTests { - - private final OllamaChatModel chatModel = OllamaChatModel.builder() - .ollamaApi(OllamaApi.builder() - .baseUrl("http://127.0.0.1:11434") // Ollama 服务地址 - .build()) - .defaultOptions(OllamaChatOptions.builder() -// .model("qwen") // 模型(https://ollama.com/library/qwen) - .model("deepseek-r1") // 模型(https://ollama.com/library/deepseek-r1) - .build()) - .build(); - - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - System.out.println(response.getResult().getOutput()); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/OpenAIChatModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/OpenAIChatModelTests.java deleted file mode 100644 index d548bae..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/OpenAIChatModelTests.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import com.azure.ai.openai.models.ReasoningEffortValue; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.SystemMessage; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.openai.OpenAiChatModel; -import org.springframework.ai.openai.OpenAiChatOptions; -import org.springframework.ai.openai.api.OpenAiApi; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link OpenAiChatModel} 集成测试 - * - * @author 研筑科技 - */ -public class OpenAIChatModelTests { - - private final OpenAiChatModel chatModel = OpenAiChatModel.builder() - .openAiApi(OpenAiApi.builder() - .baseUrl("https://api.holdai.top") - .apiKey("sk-z5joyRoV1iFEnh2SAi8QPNrIZTXyQSyxTmD5CoNDQbFixK2l") // apiKey - .build()) - .defaultOptions(OpenAiChatOptions.builder() - .model("gpt-5-nano-2025-08-07") // 模型 -// .model(OpenAiApi.ChatModel.O1) // 模型 - .temperature(0.7) - .build()) - .build(); - - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - System.out.println(response.getResult().getOutput()); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("帮我推理下,怎么实现一个用户中心!")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - - // TODO @芋艿:无法触发思考的字段返回,需要 response api:https://github.com/spring-projects/spring-ai/issues/2962 - @Test - @Disabled - public void testStream_thinking() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new UserMessage("详细分析下,如何设计一个电商系统?")); - OpenAiChatOptions options = OpenAiChatOptions.builder() - .model("gpt-5") -// .model(OpenAiApi.ChatModel.O4_MINI) -// .model("o3-pro") - .reasoningEffort(ReasoningEffortValue.LOW.getValue()) - .build(); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages, options)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - - - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/SiliconFlowChatModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/SiliconFlowChatModelTests.java deleted file mode 100644 index b0ca9be..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/SiliconFlowChatModelTests.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import com.yanzhu.module.ai.framework.ai.core.model.siliconflow.SiliconFlowApiConstants; -import com.yanzhu.module.ai.framework.ai.core.model.siliconflow.SiliconFlowChatModel; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.SystemMessage; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.deepseek.DeepSeekChatModel; -import org.springframework.ai.deepseek.DeepSeekChatOptions; -import org.springframework.ai.deepseek.api.DeepSeekApi; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link SiliconFlowChatModel} 集成测试 - * - * @author 研筑科技 - */ -public class SiliconFlowChatModelTests { - - private final DeepSeekChatModel openAiChatModel = DeepSeekChatModel.builder() - .deepSeekApi(DeepSeekApi.builder() - .baseUrl(SiliconFlowApiConstants.DEFAULT_BASE_URL) - .apiKey("sk-epsakfenqnyzoxhmbucsxlhkdqlcbnimslqoivkshalvdozz") // apiKey - .build()) - .defaultOptions(DeepSeekChatOptions.builder() - .model(SiliconFlowApiConstants.MODEL_DEFAULT) // 模型 -// .model("deepseek-ai/DeepSeek-R1") // 模型(deepseek-ai/DeepSeek-R1)可用赠费 -// .model("Pro/deepseek-ai/DeepSeek-R1") // 模型(Pro/deepseek-ai/DeepSeek-R1)需要付费 - .temperature(0.7) - .build()) - .build(); - - private final SiliconFlowChatModel chatModel = new SiliconFlowChatModel(openAiChatModel); - - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(System.out::println).then().block(); - } - - @Test - @Disabled - public void testStream_thinking() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new UserMessage("详细分析下,如何设计一个电商系统?")); - DeepSeekChatOptions options = DeepSeekChatOptions.builder() - .model("deepseek-ai/DeepSeek-R1") - .build(); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages, options)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/TongYiChatModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/TongYiChatModelTests.java deleted file mode 100644 index df7ead1..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/TongYiChatModelTests.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import com.yanzhu.framework.common.util.json.JsonUtils; -import com.alibaba.cloud.ai.dashscope.api.DashScopeApi; -import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatModel; -import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatOptions; -import com.alibaba.cloud.ai.dashscope.rerank.DashScopeRerankModel; -import com.alibaba.cloud.ai.dashscope.rerank.DashScopeRerankOptions; -import com.alibaba.cloud.ai.model.RerankModel; -import com.alibaba.cloud.ai.model.RerankOptions; -import com.alibaba.cloud.ai.model.RerankRequest; -import com.alibaba.cloud.ai.model.RerankResponse; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.SystemMessage; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.document.Document; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -import static java.util.Arrays.asList; - -/** - * {@link DashScopeChatModel} 集成测试类 - * - * @author fansili - */ -public class TongYiChatModelTests { - - private final DashScopeChatModel chatModel = DashScopeChatModel.builder() - .dashScopeApi(DashScopeApi.builder() - .apiKey("sk-47aa124781be4bfb95244cc62f63f7d0") - .build()) - .defaultOptions(DashScopeChatOptions.builder() -// .withModel("qwen1.5-72b-chat") // 模型 - .withModel("qwen3-235b-a22b-thinking-2507") // 模型 -// .withModel("deepseek-r1") // 模型(deepseek-r1) -// .withModel("deepseek-v3") // 模型(deepseek-v3) -// .withModel("deepseek-r1-distill-qwen-1.5b") // 模型(deepseek-r1-distill-qwen-1.5b) -// .withEnableThinking(true) - .build()) - .build(); - - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - System.out.println(response.getResult().getOutput()); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); -// messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("帮我推理下,怎么实现一个用户中心!")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - - @Test - @Disabled - public void testStream_thinking() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new UserMessage("详细分析下,如何设计一个电商系统?")); - DashScopeChatOptions options = DashScopeChatOptions.builder() - .withModel("qwen3-235b-a22b-thinking-2507") -// .withModel("qwen-max-2025-01-25") - .withEnableThinking(true) // 必须设置,否则会报错 - .build(); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages, options)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - - @Test - @Disabled - public void testRerank() { - // 准备环境 - RerankModel rerankModel = new DashScopeRerankModel( - DashScopeApi.builder() - .apiKey("sk-47aa124781be4bfb95244cc62f63f7d0") - .build()); - // 准备参数 - String query = "spring"; - Document document01 = new Document("abc"); - Document document02 = new Document("sapring"); - RerankOptions options = DashScopeRerankOptions.builder() - .withTopN(1) - .withModel("gte-rerank-v2") - .build(); - RerankRequest rerankRequest = new RerankRequest( - query, - asList(document01, document02), - options); - - // 调用 - RerankResponse call = rerankModel.call(rerankRequest); - // 打印结果 - System.out.println(JsonUtils.toJsonPrettyString(call)); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/XingHuoChatModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/XingHuoChatModelTests.java deleted file mode 100644 index a3337df..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/XingHuoChatModelTests.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import com.yanzhu.module.ai.framework.ai.core.model.xinghuo.XingHuoChatModel; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.SystemMessage; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.deepseek.DeepSeekChatModel; -import org.springframework.ai.deepseek.DeepSeekChatOptions; -import org.springframework.ai.deepseek.api.DeepSeekApi; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link XingHuoChatModel} 集成测试 - * - * @author fansili - */ -public class XingHuoChatModelTests { - - private final DeepSeekChatModel openAiChatModel = DeepSeekChatModel.builder() - .deepSeekApi(DeepSeekApi.builder() - .baseUrl(XingHuoChatModel.BASE_URL_V2) - .completionsPath(XingHuoChatModel.BASE_COMPLETIONS_PATH_V2) - .apiKey("75b161ed2aef4719b275d6e7f2a4d4cd:YWYxYWI2MTA4ODI2NGZlYTQyNjAzZTcz") // appKey:secretKey - .build()) - .defaultOptions(DeepSeekChatOptions.builder() -// .model("generalv3.5") // 模型 - .model("x1") // 模型 - .temperature(0.7) - .build()) - .build(); - - private final XingHuoChatModel chatModel = new XingHuoChatModel(openAiChatModel); - - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(System.out::println).then().block(); - } - - @Test - @Disabled - public void testStream_thinking() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new UserMessage("详细分析下,如何设计一个电商系统?")); - DeepSeekChatOptions options = DeepSeekChatOptions.builder() - .model("x1") - .build(); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages, options)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/YiYanChatModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/YiYanChatModelTests.java deleted file mode 100644 index 30d7807..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/YiYanChatModelTests.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springaicommunity.qianfan.QianFanChatModel; -import org.springaicommunity.qianfan.QianFanChatOptions; -import org.springaicommunity.qianfan.api.QianFanApi; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -// TODO @芋艿:百度千帆 API 提供了 V2 版本,目前 Spring AI 不兼容,可关键 进展 -/** - * {@link QianFanChatModel} 的集成测试 - * - * @author fansili - */ -public class YiYanChatModelTests { - - private final QianFanChatModel chatModel = new QianFanChatModel( - new QianFanApi("DGnyzREuaY7av7c38bOM9Ji2", "9aR8myflEOPDrEeLhoXv0FdqANOAyIZW"), // 密钥 - QianFanChatOptions.builder() - .model("ERNIE-4.5-8K-Preview") - .build() - ); - - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - // TODO @芋艿:文心一言,只要带上 system message 就报错,已经各种测试,很莫名! -// messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); - // TODO @芋艿:文心一言,只要带上 system message 就报错,已经各种测试,很莫名! -// messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(System.out::println).then().block(); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/ZhiPuAiChatModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/ZhiPuAiChatModelTests.java deleted file mode 100644 index 125f355..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/chat/ZhiPuAiChatModelTests.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.chat; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.chat.messages.Message; -import org.springframework.ai.chat.messages.SystemMessage; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.chat.model.ChatResponse; -import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.zhipuai.ZhiPuAiChatModel; -import org.springframework.ai.zhipuai.ZhiPuAiChatOptions; -import org.springframework.ai.zhipuai.api.ZhiPuAiApi; -import reactor.core.publisher.Flux; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link ZhiPuAiChatModel} 的集成测试 - * - * @author 研筑科技 - */ -public class ZhiPuAiChatModelTests { - - private final ZhiPuAiChatModel chatModel = new ZhiPuAiChatModel( - ZhiPuAiApi.builder().apiKey("2f35fb6ca4ea41fab898729b7fac086c.6ESSfPcCkxaKEUlR").build(), // 密钥 - ZhiPuAiChatOptions.builder() - .model(ZhiPuAiApi.ChatModel.GLM_4.getName()) // 模型 - .build() - ); - - @Test - @Disabled - public void testCall() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - ChatResponse response = chatModel.call(new Prompt(messages)); - // 打印结果 - System.out.println(response); - System.out.println(response.getResult().getOutput()); - } - - @Test - @Disabled - public void testStream() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new SystemMessage("你是一个优质的文言文作者,用文言文描述着各城市的人文风景。")); - messages.add(new UserMessage("1 + 1 = ?")); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - - // TODO @芋艿:暂时没解析 reasoning_content 结果,需要等官方修复 - @Test - @Disabled - public void testStream_thinking() { - // 准备参数 - List messages = new ArrayList<>(); - messages.add(new UserMessage("详细分析下,如何设计一个电商系统?")); - ZhiPuAiChatOptions options = ZhiPuAiChatOptions.builder() - .model("GLM-4.5") - .build(); - - // 调用 - Flux flux = chatModel.stream(new Prompt(messages, options)); - // 打印结果 - flux.doOnNext(response -> { -// System.out.println(response); - System.out.println(response.getResult().getOutput()); - }).then().block(); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/MidjourneyApiTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/MidjourneyApiTests.java deleted file mode 100644 index d58f372..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/MidjourneyApiTests.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.image; - -import com.yanzhu.module.ai.framework.ai.core.model.midjourney.api.MidjourneyApi; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.util.Collections; -import java.util.List; - -/** - * {@link MidjourneyApi} 集成测试 - * - * @author 研筑科技 - */ -public class MidjourneyApiTests { - - private final MidjourneyApi midjourneyApi = new MidjourneyApi( - "https://api.holdai.top/mj", // 链接 - "sk-aN6nWn3fILjrgLFT0fC4Aa60B72e4253826c77B29dC94f17", // 密钥 - null); - - @Test - @Disabled - public void testImagine() { - // 准备参数 - MidjourneyApi.ImagineRequest request = new MidjourneyApi.ImagineRequest(null, - "生成一个小猫,可爱的", null, - MidjourneyApi.ImagineRequest.buildState(512, 512, "6.0", MidjourneyApi.ModelEnum.MIDJOURNEY.getModel())); - - // 方法调用 - MidjourneyApi.SubmitResponse response = midjourneyApi.imagine(request); - // 打印结果 - System.out.println(response); - } - - @Test - @Disabled - public void testAction() { - // 准备参数 - MidjourneyApi.ActionRequest request = new MidjourneyApi.ActionRequest("1720277033455953", - "MJ::JOB::upsample::1::ee267661-ee52-4ced-a530-0343ba95af3b", null); - - // 方法调用 - MidjourneyApi.SubmitResponse response = midjourneyApi.action(request); - // 打印结果 - System.out.println(response); - } - - @Test - @Disabled - public void testGetTaskList() { - // 准备参数。该参数可以通过 MidjourneyApi.SubmitResponse 的 result 获取 -// String taskId = "1720277033455953"; - String taskId = "1720277214045971"; - - // 方法调用 - List taskList = midjourneyApi.getTaskList(Collections.singletonList(taskId)); - // 打印结果 - System.out.println(taskList); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/OpenAiImageModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/OpenAiImageModelTests.java deleted file mode 100644 index 2e6e825..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/OpenAiImageModelTests.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.image; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.image.ImageOptions; -import org.springframework.ai.image.ImagePrompt; -import org.springframework.ai.image.ImageResponse; -import org.springframework.ai.openai.OpenAiImageModel; -import org.springframework.ai.openai.OpenAiImageOptions; -import org.springframework.ai.openai.api.OpenAiImageApi; - -/** - * {@link OpenAiImageModel} 集成测试类 - * - * @author fansili - */ -public class OpenAiImageModelTests { - - private final OpenAiImageModel imageModel = new OpenAiImageModel(OpenAiImageApi.builder() - .baseUrl("https://api.holdai.top") // apiKey - .apiKey("sk-PytRecQlmjEteoa2RRN6cGnwslo72UUPLQVNEMS6K9yjbmpD") - .build()); - - @Test - @Disabled - public void testCall() { - // 准备参数 - ImageOptions options = OpenAiImageOptions.builder() - .model(OpenAiImageApi.ImageModel.DALL_E_2.getValue()) // 这个模型比较便宜 - .height(256).width(256) - .build(); - ImagePrompt prompt = new ImagePrompt("中国长城!", options); - - // 方法调用 - ImageResponse response = imageModel.call(prompt); - // 打印结果 - System.out.println(response); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/QianFanImageTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/QianFanImageTests.java deleted file mode 100644 index 2e06a34..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/QianFanImageTests.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.image; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springaicommunity.qianfan.QianFanImageModel; -import org.springaicommunity.qianfan.QianFanImageOptions; -import org.springaicommunity.qianfan.api.QianFanImageApi; -import org.springframework.ai.image.ImagePrompt; -import org.springframework.ai.image.ImageResponse; - -import static com.yanzhu.module.ai.framework.ai.core.model.image.StabilityAiImageModelTests.viewImage; - -// TODO @芋艿:百度千帆 API 提供了 V2 版本,目前 Spring AI 不兼容,可关键 进展 - -/** - * {@link QianFanImageModel} 集成测试类 - */ -public class QianFanImageTests { - - private final QianFanImageModel imageModel = new QianFanImageModel( - new QianFanImageApi("qS8k8dYr2nXunagK4SSU8Xjj", "pHGbx51ql2f0hOyabQvSZezahVC3hh3e")); // 密钥 - - @Test - @Disabled - public void testCall() { - // 准备参数 - // 只支持 1024x1024、768x768、768x1024、1024x768、576x1024、1024x576 - QianFanImageOptions imageOptions = QianFanImageOptions.builder() - .model(QianFanImageApi.ImageModel.Stable_Diffusion_XL.getValue()) - .width(1024).height(1024) - .N(1) - .build(); - ImagePrompt prompt = new ImagePrompt("good", imageOptions); - - // 方法调用 - ImageResponse response = imageModel.call(prompt); - // 打印结果 - String b64Json = response.getResult().getOutput().getB64Json(); - System.out.println(response); - viewImage(b64Json); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/SiliconFlowImageModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/SiliconFlowImageModelTests.java deleted file mode 100644 index cec64f9..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/SiliconFlowImageModelTests.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.image; - -import com.yanzhu.module.ai.framework.ai.core.model.siliconflow.SiliconFlowImageApi; -import com.yanzhu.module.ai.framework.ai.core.model.siliconflow.SiliconFlowImageModel; -import com.yanzhu.module.ai.framework.ai.core.model.siliconflow.SiliconFlowImageOptions; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.image.ImagePrompt; -import org.springframework.ai.image.ImageResponse; - -/** - * {@link SiliconFlowImageModel} 集成测试 - */ -public class SiliconFlowImageModelTests { - - private final SiliconFlowImageModel imageModel = new SiliconFlowImageModel( - new SiliconFlowImageApi("sk-epsakfenqnyzoxhmbucsxlhkdqlcbnimslqoivkshalvdozz") // 密钥 - ); - - @Test - @Disabled - public void testCall() { - // 准备参数 - SiliconFlowImageOptions imageOptions = SiliconFlowImageOptions.builder() - .model("Kwai-Kolors/Kolors") - .build(); - ImagePrompt prompt = new ImagePrompt("万里长城", imageOptions); - - // 方法调用 - ImageResponse response = imageModel.call(prompt); - // 打印结果 - System.out.println(response); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/StabilityAiImageModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/StabilityAiImageModelTests.java deleted file mode 100644 index 9508c91..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/StabilityAiImageModelTests.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.image; - -import cn.hutool.core.codec.Base64; -import cn.hutool.core.thread.ThreadUtil; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.image.ImageOptions; -import org.springframework.ai.image.ImagePrompt; -import org.springframework.ai.image.ImageResponse; -import org.springframework.ai.openai.OpenAiImageOptions; -import org.springframework.ai.stabilityai.StabilityAiImageModel; -import org.springframework.ai.stabilityai.api.StabilityAiApi; - -import javax.swing.*; -import java.awt.*; -import java.util.concurrent.TimeUnit; - -/** - * {@link StabilityAiImageModel} 集成测试类 - * - * @author fansili - */ -public class StabilityAiImageModelTests { - - private final StabilityAiImageModel imageModel = new StabilityAiImageModel( - new StabilityAiApi("sk-e53UqbboF8QJCscYvzJscJxJXoFcFg4iJjl1oqgE7baJETmx") // 密钥 - ); - - @Test - @Disabled - public void testCall() { - // 准备参数 - ImageOptions options = OpenAiImageOptions.builder() - .model("stable-diffusion-v1-6") - .height(320).width(320) - .build(); - ImagePrompt prompt = new ImagePrompt("great wall", options); - - // 方法调用 - ImageResponse response = imageModel.call(prompt); - // 打印结果 - String b64Json = response.getResult().getOutput().getB64Json(); - System.out.println(response); - viewImage(b64Json); - } - - public static void viewImage(String b64Json) { - // 创建一个 JFrame - JFrame frame = new JFrame("Byte Image Display"); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - frame.setSize(800, 600); - - // 创建一个 JLabel 来显示图片 - byte[] imageBytes = Base64.decode(b64Json); - JLabel label = new JLabel(new ImageIcon(imageBytes)); - - // 将 JLabel 添加到 JFrame - frame.getContentPane().add(label, BorderLayout.CENTER); - - // 显示 JFrame - frame.setVisible(true); - ThreadUtil.sleep(1, TimeUnit.HOURS); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/TongYiImagesModelTest.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/TongYiImagesModelTest.java deleted file mode 100644 index 89ba1a3..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/TongYiImagesModelTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.image; - -import com.alibaba.cloud.ai.dashscope.api.DashScopeImageApi; -import com.alibaba.cloud.ai.dashscope.image.DashScopeImageModel; -import com.alibaba.cloud.ai.dashscope.image.DashScopeImageOptions; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.image.ImageOptions; -import org.springframework.ai.image.ImagePrompt; -import org.springframework.ai.image.ImageResponse; - -/** - * {@link DashScopeImageModel} 集成测试类 - * - * @author fansili - */ -public class TongYiImagesModelTest { - - private final DashScopeImageModel imageModel = DashScopeImageModel.builder() - .dashScopeApi(DashScopeImageApi.builder() - .apiKey("sk-47aa124781be4bfb95244cc62f63f7d0") - .build()) - .build(); - - @Test - @Disabled - public void imageCallTest() { - // 准备参数 - ImageOptions options = DashScopeImageOptions.builder() - .withModel("wanx-v1") - .withHeight(256).withWidth(256) - .build(); - ImagePrompt prompt = new ImagePrompt("中国长城!", options); - - // 方法调用 - ImageResponse response = imageModel.call(prompt); - // 打印结果 - System.out.println(response); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/ZhiPuAiImageModelTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/ZhiPuAiImageModelTests.java deleted file mode 100644 index b3be4a9..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/image/ZhiPuAiImageModelTests.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.image; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.image.ImagePrompt; -import org.springframework.ai.image.ImageResponse; -import org.springframework.ai.zhipuai.ZhiPuAiImageModel; -import org.springframework.ai.zhipuai.ZhiPuAiImageOptions; -import org.springframework.ai.zhipuai.api.ZhiPuAiImageApi; - -/** - * {@link ZhiPuAiImageModel} 集成测试 - */ -public class ZhiPuAiImageModelTests { - - private final ZhiPuAiImageModel imageModel = new ZhiPuAiImageModel( - new ZhiPuAiImageApi("78d3228c1d9e5e342a3e1ab349e2dd7b.VXLoq5vrwK2ofboy") // 密钥 - ); - - @Test - @Disabled - public void testCall() { - // 准备参数 - ZhiPuAiImageOptions imageOptions = ZhiPuAiImageOptions.builder() - .model(ZhiPuAiImageApi.ImageModel.CogView_3.getValue()) - .build(); - ImagePrompt prompt = new ImagePrompt("万里长城", imageOptions); - - // 方法调用 - ImageResponse response = imageModel.call(prompt); - // 打印结果 - System.out.println(response); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/mcp/DouBaoMcpTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/mcp/DouBaoMcpTests.java deleted file mode 100644 index 1672b7b..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/mcp/DouBaoMcpTests.java +++ /dev/null @@ -1,127 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.mcp; - -import com.yanzhu.module.ai.framework.ai.core.model.doubao.DouBaoChatModel; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.ai.chat.client.ChatClient; -import org.springframework.ai.openai.OpenAiChatModel; -import org.springframework.ai.openai.OpenAiChatOptions; -import org.springframework.ai.openai.api.OpenAiApi; -import org.springframework.ai.tool.annotation.Tool; -import org.springframework.ai.tool.method.MethodToolCallbackProvider; - -@Disabled -public class DouBaoMcpTests { - - private final OpenAiChatModel openAiChatModel = OpenAiChatModel.builder() - .openAiApi(OpenAiApi.builder() - .baseUrl(DouBaoChatModel.BASE_URL) - .apiKey("5c1b5747-26d2-4ebd-a4e0-dd0e8d8b4272") // apiKey - .build()) - .defaultOptions(OpenAiChatOptions.builder() - .model("doubao-1-5-lite-32k-250115") // 模型(doubao) - .temperature(0.7) - .build()) - .build(); - - private final DouBaoChatModel chatModel = new DouBaoChatModel(openAiChatModel); - - private final MethodToolCallbackProvider provider = MethodToolCallbackProvider.builder() - .toolObjects(new UserService()) - .build(); - - private final ChatClient chatClient = ChatClient.builder(chatModel) - .defaultTools(provider) - .build(); - - @Test - public void testMcpGetUserInfo() { - // 打印结果 - System.out.println(chatClient.prompt() - .user("目前有哪些工具可以使用") - .call() - .content()); - System.out.println("===================================="); - - // 打印结果 - System.out.println(chatClient.prompt() - .user("小新的年龄是多少") - .call() - .content()); - System.out.println("===================================="); - - // 打印结果 - System.out.println(chatClient.prompt() - .user("获取小新的基本信息") - .call() - .content()); - System.out.println("===================================="); - - // 打印结果 - System.out.println(chatClient.prompt() - .user("小新是什么职业的") - .call() - .content()); - System.out.println("===================================="); - - // 打印结果 - System.out.println(chatClient.prompt() - .user("小新的教育背景") - .call() - .content()); - System.out.println("===================================="); - - // 打印结果 - System.out.println(chatClient.prompt() - .user("小新的兴趣爱好是什么") - .call() - .content()); - System.out.println("===================================="); - } - - - static class UserService { - - @Tool(name = "getUserAge", description = "获取用户年龄") - public String getUserAge(String userName) { - return "《" + userName + "》的年龄为:18"; - } - - @Tool(name = "getUserSex", description = "获取用户性别") - public String getUserSex(String userName) { - return "《" + userName + "》的性别为:男"; - } - - @Tool(name = "getUserBasicInfo", description = "获取用户基本信息,包括姓名、年龄、性别等") - public String getUserBasicInfo(String userName) { - return "《" + userName + "》的基本信息:\n姓名:" + userName + "\n年龄:18\n性别:男\n身高:175cm\n体重:65kg"; - } - - @Tool(name = "getUserContact", description = "获取用户联系方式,包括电话、邮箱等") - public String getUserContact(String userName) { - return "《" + userName + "》的联系方式:\n电话:138****1234\n邮箱:" + userName.toLowerCase() + "@example.com\nQQ:123456789"; - } - - @Tool(name = "getUserAddress", description = "获取用户地址信息") - public String getUserAddress(String userName) { - return "《" + userName + "》的地址信息:北京市朝阳区科技园区88号"; - } - - @Tool(name = "getUserJob", description = "获取用户职业信息") - public String getUserJob(String userName) { - return "《" + userName + "》的职业信息:软件工程师,就职于ABC科技有限公司,工作年限5年"; - } - - @Tool(name = "getUserHobbies", description = "获取用户兴趣爱好") - public String getUserHobbies(String userName) { - return "《" + userName + "》的兴趣爱好:编程、阅读、旅游、摄影、打篮球"; - } - - @Tool(name = "getUserEducation", description = "获取用户教育背景") - public String getUserEducation(String userName) { - return "《" + userName + "》的教育背景:\n本科:计算机科学与技术专业,北京大学\n硕士:软件工程专业,清华大学"; - } - - } - -} \ No newline at end of file diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/music/SunoApiTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/music/SunoApiTests.java deleted file mode 100644 index 6b0abe0..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/music/SunoApiTests.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.music; - -import cn.hutool.core.collection.ListUtil; -import com.yanzhu.module.ai.framework.ai.core.model.suno.api.SunoApi; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.util.List; - -/** - * {@link SunoApi} 集成测试 - * - * @author xiaoxin - */ -public class SunoApiTests { - - private final SunoApi sunoApi = new SunoApi("https://suno-3tah0ycyt-status2xxs-projects.vercel.app"); -// private final SunoApi sunoApi = new SunoApi("http://127.0.0.1:3001"); - - @Test // 描述模式 - @Disabled - public void testGenerate() { - // 准备参数 - SunoApi.MusicGenerateRequest generateRequest = new SunoApi.MusicGenerateRequest( - "happy music", - "chirp-v3-5", - false); - - // 调用方法 - List musicList = sunoApi.generate(generateRequest); - // 打印结果 - System.out.println(musicList); - } - - @Test // 歌词模式 - @Disabled - public void testCustomGenerate() { - // 准备参数 - SunoApi.MusicGenerateRequest generateRequest = new SunoApi.MusicGenerateRequest( - "创作一首带有轻松吉他旋律的流行歌曲,[verse] 描述夏日海滩的宁静,[chorus] 节奏加快,表达对自由的向往。", - "Happy", - "Happy Song", - "chirp-v3.5", - false, - false); - - // 调用方法 - List musicList = sunoApi.customGenerate(generateRequest); - // 打印结果 - System.out.println(musicList); - } - - @Test - @Disabled - public void testGenerateLyrics() { - // 调用方法 - SunoApi.LyricsData lyricsData = sunoApi.generateLyrics("A soothing lullaby"); - // 打印结果 - System.out.println(lyricsData); - } - - @Test - @Disabled - public void testGetMusicList() { - // 准备参数 -// String id = "d460ddda-7c87-4f34-b751-419b08a590ca"; - String id = "584729e5-0fe9-4157-86da-1b4803ff42bf"; - - // 调用方法 - List musicList = sunoApi.getMusicList(ListUtil.of(id)); - // 打印结果 - System.out.println(musicList); - } - - @Test - @Disabled - public void testGetLimitUsage() { - // 调用方法 - SunoApi.LimitUsageData limitUsageData = sunoApi.getLimitUsage(); - // 打印结果 - System.out.println(limitUsageData); - } - -} diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/ppt/xunfei/XunFeiPptApiTests.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/ppt/xunfei/XunFeiPptApiTests.java deleted file mode 100644 index b20f081..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/model/ppt/xunfei/XunFeiPptApiTests.java +++ /dev/null @@ -1,319 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.model.ppt.xunfei; - -import cn.hutool.core.io.FileUtil; -import com.yanzhu.module.ai.framework.ai.core.model.xinghuo.api.XunFeiPptApi; -import com.yanzhu.framework.common.util.json.JsonUtils; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.mock.web.MockMultipartFile; -import org.springframework.web.multipart.MultipartFile; - -import java.io.File; - -/** - * {@link XunFeiPptApi} 集成测试 - * - * @author xiaoxin - */ -public class XunFeiPptApiTests { - - // 讯飞 API 配置信息,实际使用时请替换为您的应用信息 - private static final String APP_ID = "6c8ac023"; - private static final String API_SECRET = "Y2RjM2Q1MWJjZTdkYmFiODc0OGE5NmRk"; - - private final XunFeiPptApi xunfeiPptApi = new XunFeiPptApi(APP_ID, API_SECRET); - - /** - * 获取 PPT 模板列表 - */ - @Test - @Disabled - public void testGetTemplatePage() { - // 调用方法 - XunFeiPptApi.TemplatePageResponse response = xunfeiPptApi.getTemplatePage("商务", 10); - // 打印结果 - System.out.println("模板列表响应:" + JsonUtils.toJsonString(response)); - - if (response != null && response.data() != null && response.data().records() != null) { - System.out.println("模板总数:" + response.data().total()); - System.out.println("当前页码:" + response.data().pageNum()); - System.out.println("模板数量:" + response.data().records().size()); - - // 打印第一个模板的信息(如果存在) - if (!response.data().records().isEmpty()) { - XunFeiPptApi.TemplateInfo firstTemplate = response.data().records().get(0); - System.out.println("模板ID:" + firstTemplate.templateIndexId()); - System.out.println("模板风格:" + firstTemplate.style()); - System.out.println("模板颜色:" + firstTemplate.color()); - System.out.println("模板行业:" + firstTemplate.industry()); - } - } - } - - /** - * 创建大纲(通过文本) - */ - @Test - @Disabled - public void testCreateOutline() { - XunFeiPptApi.CreateResponse response = getCreateResponse(); - // 打印结果 - System.out.println("创建大纲响应:" + JsonUtils.toJsonString(response)); - - // 保存 sid 和 outline 用于后续测试 - if (response != null && response.data() != null) { - System.out.println("sid: " + response.data().sid()); - if (response.data().outline() != null) { - // 使用 OutlineData 的 toJsonString 方法 - System.out.println("outline: " + response.data().outline().toJsonString()); - // 将 outline 对象转换为 JSON 字符串,用于后续 createPptByOutline 测试 - String outlineJson = response.data().outline().toJsonString(); - System.out.println("可用于 createPptByOutline 的 outline 字符串: " + outlineJson); - } - } - } - - /** - * 创建大纲(通过文本) - * - * @return 创建大纲响应 - */ - private XunFeiPptApi.CreateResponse getCreateResponse() { - String param = "智能体平台 Dify 介绍"; - return xunfeiPptApi.createOutline(param); - } - - /** - * 通过大纲创建 PPT(完整参数) - */ - @Test - @Disabled - public void testCreatePptByOutlineWithFullParams() { - // 创建大纲对象 - XunFeiPptApi.CreateResponse createResponse = getCreateResponse(); - // 调用方法 - XunFeiPptApi.CreateResponse response = xunfeiPptApi.createPptByOutline(createResponse.data().outline(), "精简一些,不要超过6个章节"); - // 打印结果 - System.out.println("通过大纲创建 PPT 响应:" + JsonUtils.toJsonString(response)); - - // 保存sid用于后续进度查询 - if (response != null && response.data() != null) { - System.out.println("sid: " + response.data().sid()); - if (response.data().coverImgSrc() != null) { - System.out.println("封面图片: " + response.data().coverImgSrc()); - } - } - } - - /** - * 检查 PPT 生成进度 - */ - @Test - @Disabled - public void testCheckProgress() { - // 准备参数 - 使用之前创建 PPT 时返回的 sid - String sid = "e96dac09f2ec4ee289f029a5fb874ecd"; // 替换为实际的sid - - // 调用方法 - XunFeiPptApi.ProgressResponse response = xunfeiPptApi.checkProgress(sid); - // 打印结果 - System.out.println("检查进度响应:" + JsonUtils.toJsonString(response)); - - // 安全地访问响应数据 - if (response != null && response.data() != null) { - XunFeiPptApi.ProgressResponseData data = response.data(); - - // 打印PPT生成状态 - System.out.println("PPT 构建状态: " + data.pptStatus()); - System.out.println("AI 配图状态: " + data.aiImageStatus()); - System.out.println("演讲备注状态: " + data.cardNoteStatus()); - - // 打印进度信息 - if (data.totalPages() != null && data.donePages() != null) { - System.out.println("总页数: " + data.totalPages()); - System.out.println("已完成页数: " + data.donePages()); - System.out.println("完成进度: " + data.getProgressPercent() + "%"); - } else { - System.out.println("进度: " + data.process() + "%"); - } - - // 检查是否完成 - if (data.isAllDone()) { - System.out.println("PPT 生成已完成!"); - System.out.println("PPT 下载链接: " + data.pptUrl()); - } - // 检查是否失败 - else if (data.isFailed()) { - System.out.println("PPT 生成失败!"); - System.out.println("错误信息: " + data.errMsg()); - } - // 正在进行中 - else { - System.out.println("PPT 生成中,请稍后再查询..."); - } - } - } - - /** - * 轮询检查 PPT 生成进度直到完成 - */ - @Test - @Disabled - public void testPollCheckProgress() throws InterruptedException { - // 准备参数 - 使用之前创建 PP T时返回的 sid - String sid = "1690ef6ee0344e72b5c5434f403b8eaa"; // 替换为实际的sid - - // 最大轮询次数 - int maxPolls = 20; - // 轮询间隔(毫秒)- 讯飞 API 限流为 3 秒一次 - long pollInterval = 3500; - - for (int i = 0; i < maxPolls; i++) { - System.out.println("第" + (i + 1) + "次查询进度..."); - - // 调用方法 - XunFeiPptApi.ProgressResponse response = xunfeiPptApi.checkProgress(sid); - - // 安全地访问响应数据 - if (response != null && response.data() != null) { - XunFeiPptApi.ProgressResponseData data = response.data(); - - // 打印进度信息 - System.out.println("PPT 构建状态: " + data.pptStatus()); - if (data.totalPages() != null && data.donePages() != null) { - System.out.println("完成进度: " + data.donePages() + "/" + data.totalPages() - + " (" + data.getProgressPercent() + "%)"); - } - - // 检查是否完成 - if (data.isAllDone()) { - System.out.println("PPT 生成已完成!"); - System.out.println("PPT 下载链接: " + data.pptUrl()); - break; - } - // 检查是否失败 - else if (data.isFailed()) { - System.out.println("PPT 生成失败!"); - System.out.println("错误信息: " + data.errMsg()); - break; - } - // 正在进行中,继续轮询 - else { - System.out.println("PPT 生成中,等待" + (pollInterval / 1000) + "秒后继续查询..."); - Thread.sleep(pollInterval); - } - } else { - System.out.println("查询失败,等待" + (pollInterval / 1000) + "秒后重试..."); - Thread.sleep(pollInterval); - } - } - } - - /** - * 直接创建 PPT(通过文本) - */ - @Test - @Disabled - public void testCreatePptByText() { - // 准备参数 - String query = "合肥天气趋势分析,包括近5年的气温变化、降水量变化、极端天气事件,以及对城市生活的影响"; - - // 调用方法 - XunFeiPptApi.CreateResponse response = xunfeiPptApi.create(query); - // 打印结果 - System.out.println("直接创建 PPT 响应:" + JsonUtils.toJsonString(response)); - - // 保存 sid 用于后续进度查询 - if (response != null && response.data() != null) { - System.out.println("sid: " + response.data().sid()); - if (response.data().coverImgSrc() != null) { - System.out.println("封面图片: " + response.data().coverImgSrc()); - } - System.out.println("标题: " + response.data().title()); - System.out.println("副标题: " + response.data().subTitle()); - } - } - - /** - * 直接创建 PPT(通过文件) - */ - @Test - @Disabled - public void testCreatePptByFile() { - // 准备参数 - File file = new File("src/test/resources/test.txt"); // 请确保此文件存在 - MultipartFile multipartFile = convertFileToMultipartFile(file); - - // 调用方法 - XunFeiPptApi.CreateResponse response = xunfeiPptApi.create(multipartFile, file.getName()); - // 打印结果 - System.out.println("通过文件创建PPT响应:" + JsonUtils.toJsonString(response)); - - // 保存 sid 用于后续进度查询 - if (response != null && response.data() != null) { - System.out.println("sid: " + response.data().sid()); - if (response.data().coverImgSrc() != null) { - System.out.println("封面图片: " + response.data().coverImgSrc()); - } - System.out.println("标题: " + response.data().title()); - System.out.println("副标题: " + response.data().subTitle()); - } - } - - /** - * 直接创建 PPT(完整参数) - */ - @Test - @Disabled - public void testCreatePptWithFullParams() { - // 准备参数 - String query = "合肥天气趋势分析,包括近 5 年的气温变化、降水量变化、极端天气事件,以及对城市生活的影响"; - - // 创建请求对象 - XunFeiPptApi.CreatePptRequest request = XunFeiPptApi.CreatePptRequest.builder() - .query(query) - .language("cn") - .isCardNote(true) - .search(true) - .isFigure(true) - .aiImage("advanced") - .author("测试用户") - .build(); - - // 调用方法 - XunFeiPptApi.CreateResponse response = xunfeiPptApi.create(request); - // 打印结果 - System.out.println("使用完整参数创建 PPT 响应:" + JsonUtils.toJsonString(response)); - - // 保存 sid 用于后续进度查询 - if (response != null && response.data() != null) { - String sid = response.data().sid(); - System.out.println("sid: " + sid); - if (response.data().coverImgSrc() != null) { - System.out.println("封面图片: " + response.data().coverImgSrc()); - } - System.out.println("标题: " + response.data().title()); - System.out.println("副标题: " + response.data().subTitle()); - - // 立即查询一次进度 - System.out.println("立即查询进度..."); - XunFeiPptApi.ProgressResponse progressResponse = xunfeiPptApi.checkProgress(sid); - if (progressResponse != null && progressResponse.data() != null) { - XunFeiPptApi.ProgressResponseData progressData = progressResponse.data(); - System.out.println("PPT 构建状态: " + progressData.pptStatus()); - if (progressData.totalPages() != null && progressData.donePages() != null) { - System.out.println("完成进度: " + progressData.donePages() + "/" + progressData.totalPages() - + " (" + progressData.getProgressPercent() + "%)"); - } - } - } - } - - /** - * 将 File 转换为 MultipartFile - */ - private MultipartFile convertFileToMultipartFile(File file) { - return new MockMultipartFile("file", file.getName(), "text/plain", FileUtil.readBytes(file)); - } - -} \ No newline at end of file diff --git a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/websearch/AiBoChaWebSearchClientTest.java b/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/websearch/AiBoChaWebSearchClientTest.java deleted file mode 100644 index fe668ed..0000000 --- a/yanzhu-module-ai/src/test/java/com/yanzhu/module/ai/framework/ai/core/websearch/AiBoChaWebSearchClientTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.yanzhu.module.ai.framework.ai.core.websearch; - -import com.yanzhu.framework.common.util.json.JsonUtils; -import com.yanzhu.module.ai.framework.ai.core.webserch.AiWebSearchRequest; -import com.yanzhu.module.ai.framework.ai.core.webserch.AiWebSearchResponse; -import com.yanzhu.module.ai.framework.ai.core.webserch.bocha.AiBoChaWebSearchClient; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -/** - * {@link AiBoChaWebSearchClient} 集成测试类 - * - * @author 研筑科技 - */ -public class AiBoChaWebSearchClientTest { - - private final AiBoChaWebSearchClient webSearchClient = new AiBoChaWebSearchClient( - "sk-40500e52840f4d24b956d0b1d80d9abe"); - - @Test - @Disabled - public void testSearch() { - AiWebSearchRequest request = new AiWebSearchRequest() - .setQuery("阿里巴巴") - .setCount(3); - AiWebSearchResponse response = webSearchClient.search(request); - System.out.println(JsonUtils.toJsonPrettyString(response)); - } - -} \ No newline at end of file diff --git a/yanzhu-module-system/src/main/java/com/yanzhu/module/system/dal/mysql/user/AdminUserMapper.java b/yanzhu-module-system/src/main/java/com/yanzhu/module/system/dal/mysql/user/AdminUserMapper.java index d45e0dd..a02e450 100644 --- a/yanzhu-module-system/src/main/java/com/yanzhu/module/system/dal/mysql/user/AdminUserMapper.java +++ b/yanzhu-module-system/src/main/java/com/yanzhu/module/system/dal/mysql/user/AdminUserMapper.java @@ -3,6 +3,7 @@ package com.yanzhu.module.system.dal.mysql.user; import com.yanzhu.framework.common.pojo.PageResult; import com.yanzhu.framework.mybatis.core.mapper.BaseMapperX; import com.yanzhu.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.yanzhu.framework.tenant.core.aop.TenantIgnore; import com.yanzhu.module.system.controller.admin.user.vo.user.UserPageReqVO; import com.yanzhu.module.system.dal.dataobject.user.AdminUserDO; import org.apache.ibatis.annotations.Mapper; @@ -13,6 +14,7 @@ import java.util.List; @Mapper public interface AdminUserMapper extends BaseMapperX { + @TenantIgnore default AdminUserDO selectByUsername(String username) { return selectOne(AdminUserDO::getUsername, username); } diff --git a/yanzhu-server/pom.xml b/yanzhu-server/pom.xml index d9c9986..8c9de5d 100644 --- a/yanzhu-server/pom.xml +++ b/yanzhu-server/pom.xml @@ -103,11 +103,11 @@ - +