|
|
@@ -67,8 +67,8 @@ import static com.yhlxj.web.wss.MidjourneyServerEndpoint.WSS_SESSION_MAP;
|
|
|
@RequiredArgsConstructor
|
|
|
public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
private static final String RELAX_HOST = "http://43.154.230.104:8080";
|
|
|
- private static final String FAST_HOST = "https://aigc.api4midjourney.com/api";
|
|
|
- private static final String FAST_TOKEN = "14a6b469-7cb2-4b99-9238-676c7c5cffef";
|
|
|
+ private static final String FAST_HOST = "https://api.bltcy.ai";
|
|
|
+ private static final String FAST_TOKEN = "Bearer sk-YTg6N3QH6PLTFLbM9291B1Ae12754bC4B26225F1B95f442c";
|
|
|
|
|
|
private static final Map<Long, ImgSize> TASK_IMG_SIZE_MAP = new ConcurrentHashMap<>();
|
|
|
|
|
|
@@ -117,7 +117,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
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>())
|
|
|
.put("prompt", prompt)
|
|
|
- .put("state", user.getId())
|
|
|
+ .put("state", user.getId().toString())
|
|
|
.build();
|
|
|
if (CollectionUtil.isNotEmpty(base64Array)) {
|
|
|
imagineParam.put("base64Array", base64Array);
|
|
|
@@ -127,6 +127,8 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
redisService.hincr(RedisService.key.MIDJOURNEY_ACCOUNT.getName(), result.getInstanceId().toString(), 1.0);
|
|
|
}
|
|
|
saveConversation(user.getId(), mode,result,"IMAGINE", StringUtils.EMPTY, botType);
|
|
|
+ Map<String, Object> properties = result.getProperties();
|
|
|
+ properties.put("finalPrompt",prompt);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@@ -169,7 +171,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
@Override
|
|
|
public SubmitResult submitDescribe(MidjourneyUser user,Integer mode, String botType, String base64) throws Exception {
|
|
|
Map<String, Object> param = MapUtil.builder(new HashMap<String,Object>())
|
|
|
- .put("state", user.getId())
|
|
|
+ .put("state", user.getId().toString())
|
|
|
.put("base64", base64)
|
|
|
.build();
|
|
|
SubmitResult result = submit(user,mode,"describe", null, param);
|
|
|
@@ -184,7 +186,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
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>())
|
|
|
.put("base64Array", base64Array)
|
|
|
- .put("state", user.getId())
|
|
|
+ .put("state", user.getId().toString())
|
|
|
.build();
|
|
|
if (dimensions != null) {
|
|
|
param.put("dimensions", dimensions);
|
|
|
@@ -199,9 +201,13 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
|
|
|
@Override
|
|
|
public SubmitResult submitModal(MidjourneyUser user,Integer mode, Long taskId, String prompt, String maskBase64) throws Exception {
|
|
|
+ MidjourneyUserConversation midjourneyUserConversation = conversationMapper.selectOne(Wrappers.lambdaQuery(MidjourneyUserConversation.class).eq(MidjourneyUserConversation::getTaskId, taskId).last("limit 1"));
|
|
|
+ if (midjourneyUserConversation == null) {
|
|
|
+ throw BusinessRuntimeException.getInstance("关联任务不存在或已失效");
|
|
|
+ }
|
|
|
Map<String, Object> param = MapUtil.builder(new HashMap<String,Object>())
|
|
|
- .put("taskId", taskId)
|
|
|
- .put("state", user.getId())
|
|
|
+ .put("taskId", taskId.toString())
|
|
|
+ .put("state", user.getId().toString())
|
|
|
.build();
|
|
|
if (StringUtils.isNotBlank(prompt)) {
|
|
|
param.put("prompt", prompt);
|
|
|
@@ -214,6 +220,9 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
redisService.hincr(RedisService.key.MIDJOURNEY_ACCOUNT.getName(), result.getInstanceId().toString(), 1.0);
|
|
|
}
|
|
|
saveConversation(user.getId(), mode,result,"MODAL", StringUtils.EMPTY, StringUtils.EMPTY);
|
|
|
+ Map<String, Object> properties = result.getProperties();
|
|
|
+ properties.put("finalPrompt",prompt);
|
|
|
+ properties.put("messageContent","**"+midjourneyUserConversation.getPrompt()+"** - <@mj>" + (mode == 1 ? "(fast)" : "(relaxed)"));
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@@ -221,7 +230,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
public SubmitResult submitShorten(MidjourneyUser user,Integer mode, String botType, String prompt) throws Exception {
|
|
|
Map<String, Object> param = MapUtil.builder(new HashMap<String,Object>())
|
|
|
.put("prompt", prompt)
|
|
|
- .put("state", user.getId())
|
|
|
+ .put("state", user.getId().toString())
|
|
|
.build();
|
|
|
SubmitResult result = submit(user,mode,"shorten", null, param);
|
|
|
if (mode == 2) {
|
|
|
@@ -343,14 +352,17 @@ 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("taskId", taskId.toString())
|
|
|
+ .put("state", user.getId().toString())
|
|
|
.put("customId", customId)
|
|
|
.build();
|
|
|
SubmitResult result = submit(user,mode,"action", conversation.getInstanceId(),param);
|
|
|
if (result.getCode() == 21) {
|
|
|
if (mode == 2 && modalFlag.get()){
|
|
|
SubmitResult modal = submitModal(user, mode,Long.valueOf(result.getResult()), conversation.getPrompt(), null);
|
|
|
+ Map<String, Object> properties = modal.getProperties();
|
|
|
+ properties.put("finalPrompt",conversation.getPrompt());
|
|
|
+ properties.put("messageContent", "**"+conversation.getPrompt()+"** - <@mj>" + " (relaxed)");
|
|
|
log.info("action-modal:{}", modal);
|
|
|
return modal;
|
|
|
}else {
|
|
|
@@ -363,7 +375,11 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
redisService.hincr(RedisService.key.MIDJOURNEY_ACCOUNT.getName(), result.getInstanceId().toString(), 1.0);
|
|
|
}
|
|
|
}
|
|
|
- saveConversation(user.getId(), mode, result,"ACTION", StringUtils.EMPTY, botType);
|
|
|
+ Map<String, Object> properties = result.getProperties();
|
|
|
+ properties.put("finalPrompt",conversation.getPrompt());
|
|
|
+ properties.put("messageContent","**"+conversation.getPrompt()+"** - <@mj>" + (mode == 1 ? " (fast)" : " (relaxed)"));
|
|
|
+ MidjourneyUserConversation midjourneyUserConversation = saveConversation(user.getId(), mode, result, "ACTION", StringUtils.EMPTY, botType);
|
|
|
+ properties.put("id",midjourneyUserConversation.getId());
|
|
|
return result;
|
|
|
}
|
|
|
|