|
@@ -114,7 +114,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public MidjourneyUserConversation 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) 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())
|
|
.put("state", user.getId())
|
|
@@ -126,7 +126,8 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
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);
|
|
|
}
|
|
}
|
|
|
- return saveConversation(user.getId(), mode,result,"IMAGINE", StringUtils.EMPTY, botType);
|
|
|
|
|
|
|
+ saveConversation(user.getId(), mode,result,"IMAGINE", StringUtils.EMPTY, botType);
|
|
|
|
|
+ return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public MidjourneyUserConversation saveConversation(Long userId,Integer mode,SubmitResult result, String action,String prompt, String botType) throws Exception {
|
|
public MidjourneyUserConversation saveConversation(Long userId,Integer mode,SubmitResult result, String action,String prompt, String botType) throws Exception {
|
|
@@ -166,7 +167,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public MidjourneyUserConversation submitDescribe(MidjourneyUser user,Integer mode, String botType, String base64) throws Exception {
|
|
|
|
|
|
|
+ public SubmitResult submitDescribe(MidjourneyUser user,Integer mode, String botType, String base64) 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())
|
|
.put("state", user.getId())
|
|
|
.put("base64", base64)
|
|
.put("base64", base64)
|
|
@@ -175,11 +176,12 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
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);
|
|
|
}
|
|
}
|
|
|
- return saveConversation(user.getId(), mode,result,"DESCRIBE", StringUtils.EMPTY, botType);
|
|
|
|
|
|
|
+ saveConversation(user.getId(), mode,result,"DESCRIBE", StringUtils.EMPTY, botType);
|
|
|
|
|
+ return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public MidjourneyUserConversation 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) 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())
|
|
.put("state", user.getId())
|
|
@@ -191,11 +193,12 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
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);
|
|
|
}
|
|
}
|
|
|
- return saveConversation(user.getId(), mode,result,"BLEND", StringUtils.EMPTY, botType);
|
|
|
|
|
|
|
+ saveConversation(user.getId(), mode,result,"BLEND", StringUtils.EMPTY, botType);
|
|
|
|
|
+ return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public MidjourneyUserConversation 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) throws Exception {
|
|
|
Map<String, Object> param = MapUtil.builder(new HashMap<String,Object>())
|
|
Map<String, Object> param = MapUtil.builder(new HashMap<String,Object>())
|
|
|
.put("taskId", taskId)
|
|
.put("taskId", taskId)
|
|
|
.put("state", user.getId())
|
|
.put("state", user.getId())
|
|
@@ -210,11 +213,12 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
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);
|
|
|
}
|
|
}
|
|
|
- return saveConversation(user.getId(), mode,result,"MODAL", StringUtils.EMPTY, StringUtils.EMPTY);
|
|
|
|
|
|
|
+ saveConversation(user.getId(), mode,result,"MODAL", StringUtils.EMPTY, StringUtils.EMPTY);
|
|
|
|
|
+ return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public MidjourneyUserConversation submitShorten(MidjourneyUser user,Integer mode, String botType, String prompt) throws Exception {
|
|
|
|
|
|
|
+ public SubmitResult submitShorten(MidjourneyUser user,Integer mode, String botType, String prompt) 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())
|
|
.put("state", user.getId())
|
|
@@ -223,11 +227,12 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
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);
|
|
|
}
|
|
}
|
|
|
- return saveConversation(user.getId(), mode, result,"SHORTEN", StringUtils.EMPTY, botType);
|
|
|
|
|
|
|
+ saveConversation(user.getId(), mode, result,"SHORTEN", StringUtils.EMPTY, botType);
|
|
|
|
|
+ return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public MidjourneyUserConversation submitSeed(MidjourneyUser user, Integer mode,Long taskId, String botType) throws Exception {
|
|
|
|
|
|
|
+ public SubmitResult submitSeed(MidjourneyUser user, Integer mode,Long taskId, String botType) throws Exception {
|
|
|
//SubmitResult result = seed(user.getMode(),"seed", taskId);
|
|
//SubmitResult result = seed(user.getMode(),"seed", taskId);
|
|
|
//return saveConversation(user.getId(), user.getMode(), result,"SEED", StringUtils.EMPTY, botType);
|
|
//return saveConversation(user.getId(), user.getMode(), result,"SEED", StringUtils.EMPTY, botType);
|
|
|
return null;
|
|
return null;
|
|
@@ -307,7 +312,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public Object submitAction(MidjourneyUser user,MidjourneyUserConversation conversation,Integer mode, Long taskId, String customId, Long num, String botType) throws Exception {
|
|
|
|
|
|
|
+ public SubmitResult submitAction(MidjourneyUser user,MidjourneyUserConversation conversation,Integer mode, Long taskId, String customId, Long num, String botType) throws Exception {
|
|
|
AtomicBoolean modalFlag = new AtomicBoolean(false);
|
|
AtomicBoolean modalFlag = new AtomicBoolean(false);
|
|
|
if (StringUtils.isNotBlank(conversation.getButtons())){
|
|
if (StringUtils.isNotBlank(conversation.getButtons())){
|
|
|
List<MessageButton> messageButtons = Jsons.parseList(conversation.getButtons(), MessageButton.class);
|
|
List<MessageButton> messageButtons = Jsons.parseList(conversation.getButtons(), MessageButton.class);
|
|
@@ -345,7 +350,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
SubmitResult result = submit(user,mode,"action", conversation.getInstanceId(),param);
|
|
SubmitResult result = submit(user,mode,"action", conversation.getInstanceId(),param);
|
|
|
if (result.getCode() == 21) {
|
|
if (result.getCode() == 21) {
|
|
|
if (mode == 2 && modalFlag.get()){
|
|
if (mode == 2 && modalFlag.get()){
|
|
|
- MidjourneyUserConversation modal = submitModal(user, mode,Long.valueOf(result.getResult()), conversation.getPrompt(), null);
|
|
|
|
|
|
|
+ SubmitResult modal = submitModal(user, mode,Long.valueOf(result.getResult()), conversation.getPrompt(), null);
|
|
|
log.info("action-modal:{}", modal);
|
|
log.info("action-modal:{}", modal);
|
|
|
return modal;
|
|
return modal;
|
|
|
}else {
|
|
}else {
|
|
@@ -651,7 +656,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public MidjourneyUserConversation cancelConversation(MidjourneyUser user, Long id) {
|
|
|
|
|
|
|
+ public void cancelConversation(MidjourneyUser user, Long id) {
|
|
|
MidjourneyUserConversation conversation = conversationMapper.selectOne(Wrappers.lambdaQuery(MidjourneyUserConversation.class).eq(MidjourneyUserConversation::getId, id));
|
|
MidjourneyUserConversation conversation = conversationMapper.selectOne(Wrappers.lambdaQuery(MidjourneyUserConversation.class).eq(MidjourneyUserConversation::getId, id));
|
|
|
if (conversation == null) {
|
|
if (conversation == null) {
|
|
|
throw BusinessRuntimeException.getInstance("会话不存在");
|
|
throw BusinessRuntimeException.getInstance("会话不存在");
|
|
@@ -665,7 +670,6 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
//TASK_EXECUTOR.execute(() -> {
|
|
//TASK_EXECUTOR.execute(() -> {
|
|
|
//cancel(user.getMode(),conversation.getTaskId());
|
|
//cancel(user.getMode(),conversation.getTaskId());
|
|
|
//});
|
|
//});
|
|
|
- return conversation;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void cancel(Integer mode,Long taskId) {
|
|
public void cancel(Integer mode,Long taskId) {
|