|
|
@@ -82,9 +82,12 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public MidjourneyUserConversation submitImagine(MidjourneyUser user, String prompt, List<String> base64Array) throws Exception {
|
|
|
+ public MidjourneyUserConversation submitImagine(MidjourneyUser user, String prompt,String botType, List<String> base64Array) throws Exception {
|
|
|
Map<String, Object> imagineParam = MapUtil.builder(new HashMap<String,Object>())
|
|
|
- .put("prompt", prompt).put("state", user.getId()).build();
|
|
|
+ .put("prompt", prompt)
|
|
|
+ .put("state", user.getId())
|
|
|
+ .put("botType", botType)
|
|
|
+ .build();
|
|
|
if (CollectionUtil.isNotEmpty(base64Array)) {
|
|
|
imagineParam.put("base64Array", base64Array);
|
|
|
}
|
|
|
@@ -110,16 +113,23 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public MidjourneyUserConversation submitDescribe(MidjourneyUser user, String base64) throws Exception {
|
|
|
- Map<String, Object> param = MapUtil.builder(new HashMap<String,Object>()).put("state", user.getId()).put("base64", base64).build();
|
|
|
+ public MidjourneyUserConversation submitDescribe(MidjourneyUser user, String botType, String base64) throws Exception {
|
|
|
+ Map<String, Object> param = MapUtil.builder(new HashMap<String,Object>())
|
|
|
+ .put("state", user.getId())
|
|
|
+ .put("base64", base64)
|
|
|
+ .put("botType", botType)
|
|
|
+ .build();
|
|
|
SubmitResult result = submit(user.getMode(),"describe", null, param);
|
|
|
return saveConversation(user.getId(), user.getMode(),result,"DESCRIBE", StringUtils.EMPTY);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public MidjourneyUserConversation submitBlend(MidjourneyUser user, BlendDimensions dimensions, List<String> base64Array) throws Exception {
|
|
|
+ public MidjourneyUserConversation submitBlend(MidjourneyUser user, BlendDimensions dimensions, String botType, List<String> base64Array) throws Exception {
|
|
|
Map<String, Object> param = MapUtil.builder(new HashMap<String,Object>())
|
|
|
- .put("base64Array", base64Array).put("state", user.getId()).build();
|
|
|
+ .put("base64Array", base64Array)
|
|
|
+ .put("state", user.getId())
|
|
|
+ .put("botType", botType)
|
|
|
+ .build();
|
|
|
if (dimensions != null) {
|
|
|
param.put("dimensions", dimensions);
|
|
|
}
|
|
|
@@ -130,7 +140,9 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
@Override
|
|
|
public MidjourneyUserConversation submitModal(MidjourneyUser user, Long taskId, String prompt, String maskBase64) throws Exception {
|
|
|
Map<String, Object> param = MapUtil.builder(new HashMap<String,Object>())
|
|
|
- .put("taskId", taskId).put("state", user.getId()).build();
|
|
|
+ .put("taskId", taskId)
|
|
|
+ .put("state", user.getId())
|
|
|
+ .build();
|
|
|
if (StringUtils.isNotBlank(prompt)) {
|
|
|
param.put("prompt", prompt);
|
|
|
}
|
|
|
@@ -142,9 +154,12 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public MidjourneyUserConversation submitShorten(MidjourneyUser user, String prompt) throws Exception {
|
|
|
+ public MidjourneyUserConversation submitShorten(MidjourneyUser user, String prompt, String botType) throws Exception {
|
|
|
Map<String, Object> param = MapUtil.builder(new HashMap<String,Object>())
|
|
|
- .put("prompt", prompt).put("state", user.getId()).build();
|
|
|
+ .put("prompt", prompt)
|
|
|
+ .put("state", user.getId())
|
|
|
+ .put("botType", botType)
|
|
|
+ .build();
|
|
|
SubmitResult result = submit(user.getMode(),"shorten", null, param);
|
|
|
return saveConversation(user.getId(), user.getMode(), result,"SHORTEN", StringUtils.EMPTY);
|
|
|
}
|
|
|
@@ -183,7 +198,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public SubmitResult submitAction(MidjourneyUser user, Long taskId, String customId,Long num) throws Exception {
|
|
|
+ public SubmitResult submitAction(MidjourneyUser user, Long taskId, String customId, Long num, String botType) throws Exception {
|
|
|
MidjourneyUserConversation conversation = conversationMapper.selectOne(Wrappers.lambdaQuery(MidjourneyUserConversation.class).eq(MidjourneyUserConversation::getTaskId, taskId).last("limit 1"));
|
|
|
if (conversation == null) {
|
|
|
throw BusinessRuntimeException.getInstance("关联任务不存在或已失效");
|
|
|
@@ -207,7 +222,11 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
return null;
|
|
|
}
|
|
|
Map<String, Object> param = MapUtil.builder(new HashMap<String,Object>())
|
|
|
- .put("taskId", taskId).put("state", user.getId()).put("customId", customId).build();
|
|
|
+ .put("taskId", taskId)
|
|
|
+ .put("state", user.getId())
|
|
|
+ .put("customId", customId)
|
|
|
+ .put("botType", botType)
|
|
|
+ .build();
|
|
|
SubmitResult result = submit(user.getMode(),"action", conversation.getInstanceId(),param);
|
|
|
if (result.getCode() == 21) {
|
|
|
// 以上操作有弹窗确认,恢复次数
|
|
|
@@ -222,12 +241,12 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
|
|
|
public SubmitResult submit(Integer mode,String action,Long instanceId, Map<String, Object> param) throws Exception {
|
|
|
String url = "";
|
|
|
+ String accountWithMinUsage = "";
|
|
|
if (mode == 1) {
|
|
|
param.put("mode", "FAST");
|
|
|
url = FAST_HOST;
|
|
|
} else if (mode == 2) {
|
|
|
url = RELAX_HOST;
|
|
|
- String accountWithMinUsage;
|
|
|
//慢速查询在使用次数最少的账号
|
|
|
accountWithMinUsage = getAccountWithMinUsage(instanceId);
|
|
|
param.put("accountFilter",MapUtil.builder(new HashMap<String,Object>())
|
|
|
@@ -241,6 +260,9 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
int code = submitResult.getCode();
|
|
|
if (code != 1 && code != 21 && code != 22) {
|
|
|
if (code == 3) {
|
|
|
+ if(mode == 2 && StringUtils.isNotBlank(accountWithMinUsage)){
|
|
|
+ redisService.hdel(RedisService.key.MIDJOURNEY_ACCOUNT.getName(),accountWithMinUsage);
|
|
|
+ }
|
|
|
throw BusinessRuntimeException.getInstance("账号不存在");
|
|
|
}
|
|
|
if (code == 4) {
|