|
@@ -159,7 +159,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public SubmitResult submitImagine(MidjourneyUser user, Integer mode,String prompt, String botType, List<String> base64Array) throws Exception {
|
|
|
|
|
|
|
+ public SubmitResult submitImagine(MidjourneyUser user, Integer mode,String prompt, String botType, List<String> base64Array, Long num) throws Exception {
|
|
|
Map<String, Object> imagineParam = MapUtil.builder(new HashMap<String,Object>())
|
|
Map<String, Object> imagineParam = MapUtil.builder(new HashMap<String,Object>())
|
|
|
.put("prompt", prompt)
|
|
.put("prompt", prompt)
|
|
|
.put("state", user.getId().toString())
|
|
.put("state", user.getId().toString())
|
|
@@ -167,7 +167,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
if (CollectionUtil.isNotEmpty(base64Array)) {
|
|
if (CollectionUtil.isNotEmpty(base64Array)) {
|
|
|
imagineParam.put("base64Array", base64Array);
|
|
imagineParam.put("base64Array", base64Array);
|
|
|
}
|
|
}
|
|
|
- SubmitResult result = submit(user,mode,"imagine", null,imagineParam, null,false);
|
|
|
|
|
|
|
+ SubmitResult result = submit(user,mode,"imagine", null,imagineParam, null,false, num);
|
|
|
if (mode == 2) {
|
|
if (mode == 2) {
|
|
|
redisService.hincr(RedisService.key.MIDJOURNEY_ACCOUNT.getName(), result.getInstanceId().toString(), 1.0);
|
|
redisService.hincr(RedisService.key.MIDJOURNEY_ACCOUNT.getName(), result.getInstanceId().toString(), 1.0);
|
|
|
}
|
|
}
|
|
@@ -240,12 +240,12 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public SubmitResult submitDescribe(MidjourneyUser user,Integer mode, String botType, String base64) throws Exception {
|
|
|
|
|
|
|
+ public SubmitResult submitDescribe(MidjourneyUser user,Integer mode, String botType, String base64, Long num) throws Exception {
|
|
|
Map<String, Object> param = MapUtil.builder(new HashMap<String,Object>())
|
|
Map<String, Object> param = MapUtil.builder(new HashMap<String,Object>())
|
|
|
.put("state", user.getId().toString())
|
|
.put("state", user.getId().toString())
|
|
|
.put("base64", base64)
|
|
.put("base64", base64)
|
|
|
.build();
|
|
.build();
|
|
|
- SubmitResult result = submit(user,mode,"describe", null, param, null,false);
|
|
|
|
|
|
|
+ SubmitResult result = submit(user,mode,"describe", null, param, null,false, num);
|
|
|
if (mode == 2) {
|
|
if (mode == 2) {
|
|
|
redisService.hincr(RedisService.key.MIDJOURNEY_ACCOUNT.getName(), result.getInstanceId().toString(), 1.0);
|
|
redisService.hincr(RedisService.key.MIDJOURNEY_ACCOUNT.getName(), result.getInstanceId().toString(), 1.0);
|
|
|
}
|
|
}
|
|
@@ -254,7 +254,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public SubmitResult submitBlend(MidjourneyUser user, Integer mode,BlendDimensions dimensions, String botType, List<String> base64Array) throws Exception {
|
|
|
|
|
|
|
+ public SubmitResult submitBlend(MidjourneyUser user, Integer mode,BlendDimensions dimensions, String botType, List<String> base64Array, Long num) throws Exception {
|
|
|
Map<String, Object> param = MapUtil.builder(new HashMap<String,Object>())
|
|
Map<String, Object> param = MapUtil.builder(new HashMap<String,Object>())
|
|
|
.put("base64Array", base64Array)
|
|
.put("base64Array", base64Array)
|
|
|
.put("state", user.getId().toString())
|
|
.put("state", user.getId().toString())
|
|
@@ -262,7 +262,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
if (dimensions != null) {
|
|
if (dimensions != null) {
|
|
|
param.put("dimensions", dimensions);
|
|
param.put("dimensions", dimensions);
|
|
|
}
|
|
}
|
|
|
- SubmitResult result = submit(user,mode,"blend", null, param, null,false);
|
|
|
|
|
|
|
+ SubmitResult result = submit(user,mode,"blend", null, param, null,false, num);
|
|
|
if (mode == 2) {
|
|
if (mode == 2) {
|
|
|
redisService.hincr(RedisService.key.MIDJOURNEY_ACCOUNT.getName(), result.getInstanceId().toString(), 1.0);
|
|
redisService.hincr(RedisService.key.MIDJOURNEY_ACCOUNT.getName(), result.getInstanceId().toString(), 1.0);
|
|
|
}
|
|
}
|
|
@@ -283,7 +283,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public SubmitResult submitModal(MidjourneyUser user,Integer mode, Long taskId, String prompt, String maskBase64) throws Exception {
|
|
|
|
|
|
|
+ public SubmitResult submitModal(MidjourneyUser user,Integer mode, Long taskId, String prompt, String maskBase64, Long num) throws Exception {
|
|
|
MidjourneyUserConversation midjourneyUserConversation = conversationMapper.selectOne(Wrappers.lambdaQuery(MidjourneyUserConversation.class).eq(MidjourneyUserConversation::getTaskId, taskId).last("limit 1"));
|
|
MidjourneyUserConversation midjourneyUserConversation = conversationMapper.selectOne(Wrappers.lambdaQuery(MidjourneyUserConversation.class).eq(MidjourneyUserConversation::getTaskId, taskId).last("limit 1"));
|
|
|
Map<String, Object> param = MapUtil.builder(new HashMap<String,Object>())
|
|
Map<String, Object> param = MapUtil.builder(new HashMap<String,Object>())
|
|
|
.put("taskId", taskId.toString())
|
|
.put("taskId", taskId.toString())
|
|
@@ -305,10 +305,10 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
throw BusinessRuntimeException.getInstance("任务超时,请稍后再试");
|
|
throw BusinessRuntimeException.getInstance("任务超时,请稍后再试");
|
|
|
}
|
|
}
|
|
|
Thread.sleep(3000);
|
|
Thread.sleep(3000);
|
|
|
- return submitModal(user, mode, taskId, prompt, maskBase64);
|
|
|
|
|
|
|
+ return submitModal(user, mode, taskId, prompt, maskBase64, num);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- SubmitResult result = submit(user,mode,"modal", null, param, apiChannelId,false);
|
|
|
|
|
|
|
+ SubmitResult result = submit(user,mode,"modal", null, param, apiChannelId,false, num);
|
|
|
saveConversation(user.getId(), mode,result,"MODAL", StringUtils.EMPTY, StringUtils.EMPTY,apiChannelId);
|
|
saveConversation(user.getId(), mode,result,"MODAL", StringUtils.EMPTY, StringUtils.EMPTY,apiChannelId);
|
|
|
Map<String, Object> properties = result.getProperties();
|
|
Map<String, Object> properties = result.getProperties();
|
|
|
String modeStr;
|
|
String modeStr;
|
|
@@ -338,12 +338,12 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public SubmitResult submitShorten(MidjourneyUser user,Integer mode, String botType, String prompt) throws Exception {
|
|
|
|
|
|
|
+ public SubmitResult submitShorten(MidjourneyUser user,Integer mode, String botType, String prompt, Long num) throws Exception {
|
|
|
Map<String, Object> param = MapUtil.builder(new HashMap<String,Object>())
|
|
Map<String, Object> param = MapUtil.builder(new HashMap<String,Object>())
|
|
|
.put("prompt", prompt)
|
|
.put("prompt", prompt)
|
|
|
.put("state", user.getId().toString())
|
|
.put("state", user.getId().toString())
|
|
|
.build();
|
|
.build();
|
|
|
- SubmitResult result = submit(user,mode,"shorten", null, param, null,false);
|
|
|
|
|
|
|
+ SubmitResult result = submit(user,mode,"shorten", null, param, null,false, num);
|
|
|
if (mode == 2) {
|
|
if (mode == 2) {
|
|
|
redisService.hincr(RedisService.key.MIDJOURNEY_ACCOUNT.getName(), result.getInstanceId().toString(), 1.0);
|
|
redisService.hincr(RedisService.key.MIDJOURNEY_ACCOUNT.getName(), result.getInstanceId().toString(), 1.0);
|
|
|
}
|
|
}
|
|
@@ -468,7 +468,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
.put("state", user.getId().toString())
|
|
.put("state", user.getId().toString())
|
|
|
.put("customId", customId)
|
|
.put("customId", customId)
|
|
|
.build();
|
|
.build();
|
|
|
- SubmitResult result = submit(user,mode,"action", conversation.getInstanceId(),param, apiChannelId,false);
|
|
|
|
|
|
|
+ SubmitResult result = submit(user,mode,"action", conversation.getInstanceId(),param, apiChannelId,false, num);
|
|
|
Map<String, Object> properties = result.getProperties();
|
|
Map<String, Object> properties = result.getProperties();
|
|
|
String modeStr;
|
|
String modeStr;
|
|
|
String mjVersionStatusKey;
|
|
String mjVersionStatusKey;
|
|
@@ -482,7 +482,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
properties.put("messageContent","**"+conversation.getPrompt()+"** - <@mj>" + modeStr);
|
|
properties.put("messageContent","**"+conversation.getPrompt()+"** - <@mj>" + modeStr);
|
|
|
if (result.getCode() == 21) {
|
|
if (result.getCode() == 21) {
|
|
|
if (mode == 2 && modalFlag.get()){
|
|
if (mode == 2 && modalFlag.get()){
|
|
|
- SubmitResult modal = submitModal(user, mode,Long.valueOf(result.getResult()), conversation.getPrompt(), null);
|
|
|
|
|
|
|
+ SubmitResult modal = submitModal(user, mode,Long.valueOf(result.getResult()), conversation.getPrompt(), null, num);
|
|
|
log.info("action-modal:{}", modal);
|
|
log.info("action-modal:{}", modal);
|
|
|
return modal;
|
|
return modal;
|
|
|
}else {
|
|
}else {
|
|
@@ -515,7 +515,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- public SubmitResult submit(MidjourneyUser user, Integer mode, String action, Long instanceId, Map<String, Object> param, Long apiChannelId,Boolean again) throws Exception {
|
|
|
|
|
|
|
+ public SubmitResult submit(MidjourneyUser user, Integer mode, String action, Long instanceId, Map<String, Object> param, Long apiChannelId,Boolean again, Long num) throws Exception {
|
|
|
|
|
|
|
|
String accountWithMinUsage = "";
|
|
String accountWithMinUsage = "";
|
|
|
String url = "";
|
|
String url = "";
|
|
@@ -557,16 +557,16 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
submitResult.setInstanceId(Long.valueOf(accountWithMinUsage));
|
|
submitResult.setInstanceId(Long.valueOf(accountWithMinUsage));
|
|
|
}
|
|
}
|
|
|
if (code == 23){
|
|
if (code == 23){
|
|
|
- recoverUserLimit(user.getId(), mode,1L);
|
|
|
|
|
|
|
+ recoverUserLimit(user.getId(), mode, num);
|
|
|
return submitResult;
|
|
return submitResult;
|
|
|
}
|
|
}
|
|
|
if (code != 1 && code != 21 && code != 22) {
|
|
if (code != 1 && code != 21 && code != 22) {
|
|
|
- submitResult = checkResult(user, mode, action, instanceId, param, code, accountWithMinUsage, submitResult);
|
|
|
|
|
|
|
+ submitResult = checkResult(user, mode, action, instanceId, param, code, accountWithMinUsage, submitResult, num);
|
|
|
}
|
|
}
|
|
|
return submitResult;
|
|
return submitResult;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private SubmitResult checkResult(MidjourneyUser user, Integer mode, String action, Long instanceId, Map<String, Object> param, int code, String accountWithMinUsage, SubmitResult submitResult) throws Exception {
|
|
|
|
|
|
|
+ private SubmitResult checkResult(MidjourneyUser user, Integer mode, String action, Long instanceId, Map<String, Object> param, int code, String accountWithMinUsage, SubmitResult submitResult, Long num) throws Exception {
|
|
|
if (code == 3) {
|
|
if (code == 3) {
|
|
|
if(mode == 2){
|
|
if(mode == 2){
|
|
|
redisService.hdel(RedisService.key.MIDJOURNEY_ACCOUNT.getName(), accountWithMinUsage);
|
|
redisService.hdel(RedisService.key.MIDJOURNEY_ACCOUNT.getName(), accountWithMinUsage);
|
|
@@ -575,7 +575,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
midjourneyAccountService.updateStatus(account.getId());
|
|
midjourneyAccountService.updateStatus(account.getId());
|
|
|
});
|
|
});
|
|
|
if(RETRY_ACTION.contains(action)){
|
|
if(RETRY_ACTION.contains(action)){
|
|
|
- return submit(user,mode, action, instanceId, param, null,true);
|
|
|
|
|
|
|
+ return submit(user,mode, action, instanceId, param, null,true, num);
|
|
|
}
|
|
}
|
|
|
} else if(mode == 1) {
|
|
} else if(mode == 1) {
|
|
|
// 重试逻辑,切换供应商域名
|
|
// 重试逻辑,切换供应商域名
|