diff --git a/yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/midjourney/api/MidjourneyApi.java b/yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/midjourney/api/MidjourneyApi.java index a501652b8..3c5e81fee 100644 --- a/yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/midjourney/api/MidjourneyApi.java +++ b/yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/midjourney/api/MidjourneyApi.java @@ -1,12 +1,11 @@ package cn.iocoder.yudao.framework.ai.core.model.midjourney.api; import cn.iocoder.yudao.framework.ai.core.model.midjourney.MidjourneyProperties; -import cn.iocoder.yudao.framework.ai.core.model.midjourney.vo.MidjourneyActionRequest; -import cn.iocoder.yudao.framework.ai.core.model.midjourney.vo.MidjourneyImagineRequest; -import cn.iocoder.yudao.framework.ai.core.model.midjourney.vo.MidjourneyNotifyRequest; -import cn.iocoder.yudao.framework.ai.core.model.midjourney.vo.MidjourneySubmitResponse; import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; +import lombok.AllArgsConstructor; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.springframework.ai.openai.api.ApiUtils; import org.springframework.web.reactive.function.client.WebClient; @@ -14,6 +13,7 @@ import reactor.core.publisher.Mono; import java.util.Collection; import java.util.List; +import java.util.Map; /** * Midjourney api @@ -71,11 +71,11 @@ public class MidjourneyApi { * @param taskIds * @return */ - public List listByCondition(Collection taskIds) { + public List listByCondition(Collection taskIds) { // 1、发送 post 请求 String res = post(URI_LIST_BY_CONDITION, ImmutableMap.of("ids", taskIds)); // 2、转换 对象 - return JsonUtils.parseArray(res, MidjourneyNotifyRequest.class); + return JsonUtils.parseArray(res, NotifyRequest.class); } private String post(String uri, Object body) { @@ -93,4 +93,205 @@ public class MidjourneyApi { .bodyToMono(String.class) .block(); } + + // ====== record 结构 + + /** + * Midjourney - Imagine 请求 + * + * @param base64Array 垫图(参考图)base64数组 + * @param notifyHook 通知地址 + * @param prompt 提示词 + * @param state 自定义参数 + */ + public record MidjourneyImagineRequest(List base64Array, + String notifyHook, + String prompt, + String state) { + } + + /** + * Midjourney - Action 请求 + * + * @param customId 操作按钮id + * @param taskId 操作按钮id + * @param notifyHook 通知地址 + * @param state 自定义参数 + */ + public record MidjourneyActionRequest(String customId, + String taskId, + String notifyHook, + String state) { + } + + /** + * Midjourney - Submit 返回 + * + * @param code 状态码: 1(提交成功), 21(已存在), 22(排队中), other(错误) + * @param description 描述 + * @param properties 扩展字段 + * @param result 任务ID + */ + public record MidjourneySubmitResponse(String code, + String description, + Map properties, + String result) { + } + + /** + * Midjourney - 通知 request + * + * @param id job id + * @param action 任务类型 {@link TaskActionEnum} + * @param status 任务状态 {@link TaskStatusEnum} + * @param prompt 提示词 + * @param promptEn 提示词-英文 + * @param description 任务描述 + * @param state 自定义参数 + * @param submitTime 提交时间 + * @param startTime 开始执行时间 + * @param finishTime 结束时间 + * @param imageUrl 图片url + * @param progress 任务进度 + * @param failReason 失败原因 + * @param buttons 任务完成后的可执行按钮 + */ + public record NotifyRequest(String id, + String action, + String status, + + String prompt, + String promptEn, + + String description, + String state, + + Long submitTime, + Long startTime, + Long finishTime, + + String imageUrl, + String progress, + String failReason, + List