From 44f7c841de1878f61e51df966d1114456380d77b Mon Sep 17 00:00:00 2001 From: cherishsince Date: Thu, 25 Apr 2024 16:56:54 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=20dall2\dall3=20=E7=BB=98=E7=94=BB=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E8=BF=98=E6=9C=AA=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ai/controller/AiImageController.java | 17 +++++++++++++- ...rawingImage.java => AiDrawingImageDO.java} | 2 +- .../module/ai/service/AiImageService.java | 11 ++++++++++ .../ai/service/impl/AiImageServiceImpl.java | 5 +++++ .../module/ai/vo/AiImageDallDrawingReq.java | 22 +++++++++++++++++++ 5 files changed, 55 insertions(+), 2 deletions(-) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/{AiDrawingImage.java => AiDrawingImageDO.java} (94%) create mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiImageDallDrawingReq.java diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiImageController.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiImageController.java index 1f10398e9..dad0d00f4 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiImageController.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiImageController.java @@ -1,10 +1,17 @@ package cn.iocoder.yudao.module.ai.controller; +import cn.iocoder.yudao.module.ai.service.AiImageService; +import cn.iocoder.yudao.module.ai.vo.AiImageDallDrawingReq; +import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; /** * ai作图 @@ -15,10 +22,18 @@ import org.springframework.web.bind.annotation.RestController; */ @Tag(name = "A10-ai作图") @RestController -@RequestMapping("/ai/chat/message") +@RequestMapping("/ai/image") @Slf4j @AllArgsConstructor public class AiImageController { + private final AiImageService aiImageService; + @Operation(summary = "dall2/dall3绘画", description = "openAi dall3是付费的!") + @GetMapping("/dallDrawing") + public SseEmitter dallDrawing(@Validated @ModelAttribute AiImageDallDrawingReq req) { + Utf8SseEmitter sseEmitter = new Utf8SseEmitter(); + aiImageService.dallDrawing(req, sseEmitter); + return null; + } } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/AiDrawingImage.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/AiDrawingImageDO.java similarity index 94% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/AiDrawingImage.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/AiDrawingImageDO.java index 3b29be61b..87d885deb 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/AiDrawingImage.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/AiDrawingImageDO.java @@ -18,7 +18,7 @@ import lombok.experimental.Accessors; @Data @Accessors(chain = true) @TableName("ai_drawing_image") -public class AiDrawingImage extends BaseDO { +public class AiDrawingImageDO extends BaseDO { @TableId(type = IdType.AUTO) private Long id; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiImageService.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiImageService.java index 703359f3c..05e512d24 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiImageService.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiImageService.java @@ -1,5 +1,8 @@ package cn.iocoder.yudao.module.ai.service; +import cn.iocoder.yudao.module.ai.controller.Utf8SseEmitter; +import cn.iocoder.yudao.module.ai.vo.AiImageDallDrawingReq; + /** * ai 作图 * @@ -8,4 +11,12 @@ package cn.iocoder.yudao.module.ai.service; * @since 1.0 */ public interface AiImageService { + + /** + * ai绘画 - dall2/dall3 绘画 + * + * @param req + * @param sseEmitter + */ + void dallDrawing(AiImageDallDrawingReq req, Utf8SseEmitter sseEmitter); } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiImageServiceImpl.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiImageServiceImpl.java index 872099935..2221ae3be 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiImageServiceImpl.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiImageServiceImpl.java @@ -1,6 +1,8 @@ package cn.iocoder.yudao.module.ai.service.impl; +import cn.iocoder.yudao.module.ai.controller.Utf8SseEmitter; import cn.iocoder.yudao.module.ai.service.AiImageService; +import cn.iocoder.yudao.module.ai.vo.AiImageDallDrawingReq; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -18,5 +20,8 @@ import org.springframework.stereotype.Service; public class AiImageServiceImpl implements AiImageService { + @Override + public void dallDrawing(AiImageDallDrawingReq req, Utf8SseEmitter sseEmitter) { + } } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiImageDallDrawingReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiImageDallDrawingReq.java new file mode 100644 index 000000000..e640e818a --- /dev/null +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiImageDallDrawingReq.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.ai.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * dall2/dall2 绘画 + * + * @author fansili + * @time 2024/4/25 16:24 + * @since 1.0 + */ +@Data +@Accessors(chain = true) +public class AiImageDallDrawingReq { + + @Schema(description = "提示词") + @NotNull(message = "提示词不能为空!") + private String prompt; +}