Commit ba1333bdef8a4f7e1c87fe025d467ee74bf41e14
Merge remote-tracking branch 'origin/master-jdk21-ai' into master-jdk21-ai
Showing
7 changed files
with
82 additions
and
17 deletions
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/image/AiImageDO.java
| ... | ... | @@ -49,8 +49,8 @@ public class AiImageDO extends BaseDO { |
| 49 | 49 | |
| 50 | 50 | // ============ mj 需要字段 |
| 51 | 51 | |
| 52 | - @Schema(description = "用户操作的消息编号(MJ返回)") | |
| 53 | - private String mjMessageId; | |
| 52 | + @Schema(description = "用户操作的Nonce编号(MJ返回)") | |
| 53 | + private String mjNonceId; | |
| 54 | 54 | |
| 55 | 55 | @Schema(description = "用户操作的操作编号(MJ返回)") |
| 56 | 56 | private String mjOperationId; | ... | ... |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/AiImageMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.ai.dal.mysql; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 4 | 5 | import cn.iocoder.yudao.module.ai.dal.dataobject.image.AiImageDO; |
| 5 | 6 | import org.apache.ibatis.annotations.Mapper; |
| 6 | 7 | import org.springframework.stereotype.Repository; |
| ... | ... | @@ -17,4 +18,13 @@ import org.springframework.stereotype.Repository; |
| 17 | 18 | public interface AiImageMapper extends BaseMapperX<AiImageDO> { |
| 18 | 19 | |
| 19 | 20 | |
| 21 | + /** | |
| 22 | + * 更新 - 根据 messageId | |
| 23 | + * | |
| 24 | + * @param mjNonceId | |
| 25 | + * @param aiImageDO | |
| 26 | + */ | |
| 27 | + default void updateByMjNonce(Long mjNonceId, AiImageDO aiImageDO) { | |
| 28 | + this.update(aiImageDO, new LambdaQueryWrapperX<AiImageDO>().eq(AiImageDO::getMjNonceId, mjNonceId)); | |
| 29 | + } | |
| 20 | 30 | } | ... | ... |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiImageServiceImpl.java
| ... | ... | @@ -145,7 +145,7 @@ public class AiImageServiceImpl implements AiImageService { |
| 145 | 145 | // 校验 OperateId 是否存在 |
| 146 | 146 | AiImageMidjourneyOperationsVO midjourneyOperationsVO = validateMidjourneyOperationsExists(midjourneyOperations, req.getOperateId()); |
| 147 | 147 | // 校验 messageId |
| 148 | - validateMessageId(aiImageDO.getMjMessageId(), req.getMessageId()); | |
| 148 | + validateMessageId(aiImageDO.getMjNonceId(), req.getMessageId()); | |
| 149 | 149 | // 获取 mjOperationName |
| 150 | 150 | String mjOperationName = midjourneyOperationsVO.getLabel(); |
| 151 | 151 | // 保存一个 image 任务记录 |
| ... | ... | @@ -222,7 +222,7 @@ public class AiImageServiceImpl implements AiImageService { |
| 222 | 222 | aiImageDO.setDrawingImageUrl(drawingImageUrl); |
| 223 | 223 | aiImageDO.setDrawingErrorMessage(drawingErrorMessage); |
| 224 | 224 | // |
| 225 | - aiImageDO.setMjMessageId(mjMessageId); | |
| 225 | + aiImageDO.setMjNonceId(mjMessageId); | |
| 226 | 226 | aiImageDO.setMjOperationId(mjOperationId); |
| 227 | 227 | aiImageDO.setMjOperationName(mjOperationName); |
| 228 | 228 | aiImageMapper.insert(aiImageDO); | ... | ... |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/midjourneyHandler/YuDaoMidjourneyMessageHandler.java
| ... | ... | @@ -62,12 +62,11 @@ public class YuDaoMidjourneyMessageHandler implements MidjourneyMessageHandler { |
| 62 | 62 | |
| 63 | 63 | private void errorHandler(MidjourneyMessage midjourneyMessage) { |
| 64 | 64 | // image 编号 |
| 65 | - Long aiImageId = Long.valueOf(midjourneyMessage.getNonce()); | |
| 65 | + Long nonceId = Long.valueOf(midjourneyMessage.getNonce()); | |
| 66 | 66 | // 获取 error message |
| 67 | 67 | String errorMessage = getErrorMessage(midjourneyMessage); |
| 68 | - aiImageMapper.updateById( | |
| 68 | + aiImageMapper.updateByMjNonce(nonceId, | |
| 69 | 69 | new AiImageDO() |
| 70 | - .setId(aiImageId) | |
| 71 | 70 | .setDrawingErrorMessage(errorMessage) |
| 72 | 71 | .setDrawingStatus(AiImageDrawingStatusEnum.FAIL.getStatus()) |
| 73 | 72 | ); |
| ... | ... | @@ -83,7 +82,8 @@ public class YuDaoMidjourneyMessageHandler implements MidjourneyMessageHandler { |
| 83 | 82 | |
| 84 | 83 | private void successHandler(MidjourneyMessage midjourneyMessage) { |
| 85 | 84 | // 获取id |
| 86 | - Long aiImageId = Long.valueOf(midjourneyMessage.getNonce()); | |
| 85 | + Long nonceId = Long.valueOf(midjourneyMessage.getNonce()); | |
| 86 | + // TODO @芋艿 这个地方有问题,不能根据 nonce来更新,不返回这个信息(别人获取了 image-xxx-xx 后面一段hash,由于没有mj账号测试,暂不清楚。) | |
| 87 | 87 | // 获取生成 url |
| 88 | 88 | String imageUrl = null; |
| 89 | 89 | if (CollUtil.isNotEmpty(midjourneyMessage.getAttachments())) { |
| ... | ... | @@ -102,12 +102,11 @@ public class YuDaoMidjourneyMessageHandler implements MidjourneyMessageHandler { |
| 102 | 102 | // 获取 midjourneyOperations |
| 103 | 103 | List<AiImageMidjourneyOperationsVO> midjourneyOperations = getMidjourneyOperationsList(midjourneyMessage); |
| 104 | 104 | // 更新数据库 |
| 105 | - aiImageMapper.updateById( | |
| 105 | + aiImageMapper.updateByMjNonce(nonceId, | |
| 106 | 106 | new AiImageDO() |
| 107 | - .setId(aiImageId) | |
| 108 | 107 | .setDrawingImageUrl(imageUrl) |
| 109 | 108 | .setDrawingStatus(drawingStatusEnum == null ? null : drawingStatusEnum.getStatus()) |
| 110 | - .setMjMessageId(midjourneyMessage.getId()) | |
| 109 | + .setMjNonceId(midjourneyMessage.getId()) | |
| 111 | 110 | .setMjOperations(JsonUtils.toJsonString(midjourneyOperations)) |
| 112 | 111 | ); |
| 113 | 112 | } | ... | ... |
yudao-module-ai/yudao-module-ai-biz/src/main/resources/http/image.http
| ... | ... | @@ -20,5 +20,5 @@ Content-Type: application/json |
| 20 | 20 | Authorization: {{token}} |
| 21 | 21 | |
| 22 | 22 | { |
| 23 | - "prompt": "Cute cartoon style mobile game scene, a colorful camping car with an outdoor table and chairs next to it on the road in a spring forest, the simple structure of the camper van, soft lighting, C4D rendering, 3d model in the style of a cartoon, cute shape, a pastel color scheme, closeup view from the side angle, high resolution, bright colors, a happy atmosphere. --ar 1:2 --v 6.0" | |
| 23 | + "prompt": "Cute cartoon style mobile game scene, a colorful camping car with an outdoor table and chairs next to it on the road in a spring forest, the simple structure of the camper van, soft lighting, C4D rendering, 3d model in the style of a cartoon, cute shape, a pastel color scheme, closeup view from the side angle, high resolution, bright colors, a happy atmosphere." | |
| 24 | 24 | } |
| 25 | 25 | \ No newline at end of file | ... | ... |
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/resources/requestTestJson/imageGenerationProcess/test2.json
0 → 100644
| 1 | +{ | |
| 2 | + "type": 2, | |
| 3 | + "application_id": "936929561302675456", | |
| 4 | + "guild_id": "1237948819677904956", | |
| 5 | + "channel_id": "1237948819677904960", | |
| 6 | + "session_id": "4bdb0c32158f625bbd7f0a54bfbb54aa", | |
| 7 | + "data": { | |
| 8 | + "version": "1237876415471554623", | |
| 9 | + "id": "938956540159881230", | |
| 10 | + "name": "imagine", | |
| 11 | + "type": 1, | |
| 12 | + "options": [ | |
| 13 | + { | |
| 14 | + "type": 3, | |
| 15 | + "name": "prompt", | |
| 16 | + "value": "哈哈哈" | |
| 17 | + } | |
| 18 | + ], | |
| 19 | + "application_command": { | |
| 20 | + "id": "938956540159881230", | |
| 21 | + "type": 1, | |
| 22 | + "application_id": "936929561302675456", | |
| 23 | + "version": "1237876415471554623", | |
| 24 | + "name": "imagine", | |
| 25 | + "description": "Create images with Midjourney", | |
| 26 | + "options": [ | |
| 27 | + { | |
| 28 | + "type": 3, | |
| 29 | + "name": "prompt", | |
| 30 | + "description": "The prompt to imagine", | |
| 31 | + "required": true, | |
| 32 | + "description_localized": "The prompt to imagine", | |
| 33 | + "name_localized": "prompt" | |
| 34 | + } | |
| 35 | + ], | |
| 36 | + "dm_permission": true, | |
| 37 | + "contexts": [ | |
| 38 | + 0, | |
| 39 | + 1, | |
| 40 | + 2 | |
| 41 | + ], | |
| 42 | + "integration_types": [ | |
| 43 | + 0, | |
| 44 | + 1 | |
| 45 | + ], | |
| 46 | + "global_popularity_rank": 1, | |
| 47 | + "description_localized": "Create images with Midjourney", | |
| 48 | + "name_localized": "imagine" | |
| 49 | + }, | |
| 50 | + "attachments": [] | |
| 51 | + }, | |
| 52 | + "nonce": "1238062212925358080", | |
| 53 | + "analytics_location": "slash_ui" | |
| 54 | +} | |
| 0 | 55 | \ No newline at end of file | ... | ... |
yudao-server/src/main/resources/application-local.yaml
| ... | ... | @@ -52,7 +52,7 @@ spring: |
| 52 | 52 | # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true;useUnicode=true;characterEncoding=utf-8 # SQLServer 连接的示例 |
| 53 | 53 | # url: jdbc:dm://127.0.0.1:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 |
| 54 | 54 | username: root |
| 55 | - password: 123456 | |
| 55 | + password: root | |
| 56 | 56 | # username: sa # SQL Server 连接的示例 |
| 57 | 57 | # password: Yudao@2024 # SQL Server 连接的示例 |
| 58 | 58 | # username: SYSDBA # DM 连接的示例 |
| ... | ... | @@ -61,7 +61,7 @@ spring: |
| 61 | 61 | lazy: true # 开启懒加载,保证启动速度 |
| 62 | 62 | url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true |
| 63 | 63 | username: root |
| 64 | - password: 123456 | |
| 64 | + password: root | |
| 65 | 65 | |
| 66 | 66 | # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 |
| 67 | 67 | data: |
| ... | ... | @@ -248,9 +248,9 @@ yudao: |
| 248 | 248 | style: vivid |
| 249 | 249 | midjourney: |
| 250 | 250 | enable: true |
| 251 | - token: OTc1MzcyNDg1OTcxMzEyNzAw.G2iiSo.OqW9vToC5dokiyb1QOWnCwRPsYpOjLyNcf9--M | |
| 252 | - guild-id: 1234355413420347402 | |
| 253 | - channel-id: 1234380679576424448 | |
| 251 | + token: MTE4MjE3MjY2MjkxNTY3ODIzOA.GEV1SG.c49F8lZoGCUHwsj8O0UdodmM6nyQHvuD2fXflw | |
| 252 | + guild-id: 1237948819677904956 | |
| 253 | + channel-id: 1237948819677904960 | |
| 254 | 254 | captcha: |
| 255 | 255 | enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试; |
| 256 | 256 | security: |
| ... | ... | @@ -267,6 +267,8 @@ yudao: |
| 267 | 267 | enable: false |
| 268 | 268 | demo: false # 关闭演示模式 |
| 269 | 269 | tencent-lbs-key: TVDBZ-TDILD-4ON4B-PFDZA-RNLKH-VVF6E # QQ 地图的密钥 https://lbs.qq.com/service/staticV2/staticGuide/staticDoc |
| 270 | + tenant: | |
| 271 | + enable: false | |
| 270 | 272 | |
| 271 | 273 | justauth: |
| 272 | 274 | enabled: true | ... | ... |