From 62d5ed8395cdb7e17d09dbe0a0a78f53a7299263 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 6 Jul 2024 22:47:33 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=91AI=EF=BC=9A=E5=AE=8C=E5=96=84=20MidjourneyApiTests=20?= =?UTF-8?q?=E5=8D=95=E6=B5=8B=EF=BC=8C=E6=96=B9=E4=BE=BF=E5=A4=A7=E5=AE=B6?= =?UTF-8?q?=E5=BF=AB=E9=80=9F=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ai/image/MidjourneyApiTests.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/image/MidjourneyApiTests.java diff --git a/yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/image/MidjourneyApiTests.java b/yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/image/MidjourneyApiTests.java new file mode 100644 index 0000000000..c03cebb2bf --- /dev/null +++ b/yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/image/MidjourneyApiTests.java @@ -0,0 +1,62 @@ +package cn.iocoder.yudao.framework.ai.image; + +import cn.iocoder.yudao.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-dZEPiVaNcT3FHhef51996bAa0bC74806BeAb620dA5Da10Bf", + 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); + } + +}