Merge branch 'dev/dev_xp' into dev/dev
This commit is contained in:
@@ -1416,13 +1416,12 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
}
|
||||
|
||||
public List<Map<String, String>> getAllPose(){
|
||||
String posePath = "aida-sys-image/pose/pose-1.gif";
|
||||
String firstFramePath = "aida-sys-image/pose/pose-1-first_frame.jpeg";
|
||||
HashMap<String, String> resp = new HashMap<>();
|
||||
// todo 以后要返回poseId
|
||||
resp.put("gif", minioUtil.getPreSignedUrl(posePath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
resp.put("firstFrame", minioUtil.getPreSignedUrl(firstFramePath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
return Arrays.asList(resp);
|
||||
List<Map<String, String>> propertyList = PoseEnum.getPropertyList();
|
||||
propertyList.forEach(item -> {
|
||||
item.put("gif", minioUtil.getPreSignedUrl(item.get("gif"), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
item.put("firstFrame", minioUtil.getPreSignedUrl(item.get("firstFrame"), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
});
|
||||
return propertyList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1688,13 +1687,13 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
|
||||
// 轮询配置
|
||||
private static final int MAX_RETRIES = 30; // 最大重试次数
|
||||
private static final int POLL_INTERVAL = 2000; // 轮询间隔(毫秒)
|
||||
private static final int POLL_INTERVAL = 20000; // 轮询间隔(毫秒)
|
||||
|
||||
public String getVideoTemplateId(String videoPath){
|
||||
String key = RedisUtil.ANIMATE_ANYONE_TEMPLATE_ID + videoPath;
|
||||
String templateId = redisUtil.getFromString(key);
|
||||
boolean contains = PoseEnum.getVideoList().contains(videoPath);
|
||||
|
||||
if (StringUtil.isNullOrEmpty(templateId)){
|
||||
String templateId;
|
||||
if (!contains){
|
||||
String videoUrl = minioUtil.getPreSignedUrl(videoPath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME);
|
||||
JSONObject requestBody = new JSONObject();
|
||||
requestBody.set("model", "animate-anyone-template-gen2");
|
||||
@@ -1704,8 +1703,8 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
requestBody.set("input", input);
|
||||
requestBody.set("parameters", parameters);
|
||||
|
||||
String resp = sendRequestUtil.sendPost(TEMPLATE_ID_GEN, requestBody.toString());
|
||||
|
||||
log.info("获取pose的模板id 请求数据:{}", requestBody);
|
||||
String resp = sendRequestUtil.sendAliYunPostAsync(TEMPLATE_ID_GEN, requestBody.toString());
|
||||
if (StringUtil.isNullOrEmpty(resp)){
|
||||
throw new BusinessException("请求获取video template id失败");
|
||||
}
|
||||
@@ -1720,7 +1719,8 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
throw new BusinessException("获取动作模板失败");
|
||||
}
|
||||
// templateId = "AACT.8090e67b.-E3pujumEfCbDTI_rjSH-A.LwIlGT3j";
|
||||
redisUtil.addToString(key, templateId);
|
||||
} else {
|
||||
templateId = PoseEnum.getByVideoPath(videoPath).getTemplateId();
|
||||
}
|
||||
|
||||
return templateId;
|
||||
@@ -2043,7 +2043,9 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
&& func.equals(CreditsEventsEnum.POSE_TRANSFORMATION.getValue())){
|
||||
List<PoseTransformation> poseTransformations = poseTransformationMapper.selectList(
|
||||
new QueryWrapper<PoseTransformation>().eq("unique_id", taskId));
|
||||
if (!poseTransformations.isEmpty() && poseTransformations.get(0).getModelName().equals("wx")){
|
||||
if (!poseTransformations.isEmpty()
|
||||
&& !StringUtil.isNullOrEmpty(poseTransformations.get(0).getModelName())
|
||||
&& poseTransformations.get(0).getModelName().equals("wx")){
|
||||
return "wx";
|
||||
}else {
|
||||
return "local";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ai.da.service.impl;
|
||||
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.constant.CommonConstant;
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.enums.CollectionLevel1TypeEnum;
|
||||
@@ -20,11 +21,16 @@ import com.ai.da.python.PythonService;
|
||||
import com.ai.da.service.DesignService;
|
||||
import com.ai.da.service.LLMService;
|
||||
import com.ai.da.service.SysFileService;
|
||||
import com.ai.da.service.WorkspaceService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
import org.checkerframework.checker.units.qual.C;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -71,6 +77,8 @@ public class LLMServiceImpl implements LLMService {
|
||||
private CollectionElementMapper collectionElementMapper;
|
||||
@Resource
|
||||
private CollectionElementRelModelMapper collectionElementRelModelMapper;
|
||||
@Value("${minio.bucketName.sysImage}")
|
||||
private String sysImage;
|
||||
|
||||
@Override
|
||||
public SseEmitter stream(String prompt, Long projectParamId, String fileUrl, List<String> imageUrlList, String token, Boolean enableThinking, String process) {
|
||||
@@ -78,12 +86,12 @@ public class LLMServiceImpl implements LLMService {
|
||||
|
||||
executor.submit(() -> {
|
||||
try {
|
||||
boolean validate = jwtTokenHelper.validateToken(token);
|
||||
boolean validate = jwtTokenHelper.validateToken(token); //
|
||||
if (validate) {
|
||||
AuthPrincipalVo principal = jwtTokenHelper.parserToUser(token);
|
||||
Long accountId = principal.getId();
|
||||
String url = "http://18.167.251.121:10002/chat-stream";
|
||||
// String url = "http://10.1.1.240:1013/chat-stream";
|
||||
// String url = "http://18.167.251.121:10002/chat-stream";
|
||||
String url = "http://10.1.1.240:1013/chat-stream";
|
||||
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setDoOutput(true);
|
||||
@@ -222,10 +230,12 @@ public class LLMServiceImpl implements LLMService {
|
||||
@Override
|
||||
public SseEmitter streamNew(String prompt, Long projectParamId, String fileUrl, List<String> imageUrlList, String token, Boolean enableThinking, String process) {
|
||||
SseEmitter emitter = new SseEmitter(0L); // 永不超时
|
||||
List<String> designTools = Arrays.asList("moodboard", "printboard", "generate_color_code", "sketchboard");
|
||||
|
||||
executor.submit(() -> {
|
||||
try {
|
||||
boolean validate = jwtTokenHelper.validateToken(token);
|
||||
// boolean validate = jwtTokenHelper.validateToken(token);
|
||||
boolean validate = true;
|
||||
if (validate) {
|
||||
AuthPrincipalVo principal = jwtTokenHelper.parserToUser(token);
|
||||
Long accountId = principal.getId();
|
||||
@@ -327,7 +337,9 @@ public class LLMServiceImpl implements LLMService {
|
||||
}
|
||||
String toolsName = json.getString("tools_name");
|
||||
JSONObject toolsData = json.getJSONObject("content");
|
||||
if (Objects.nonNull(toolsName) && !toolsName.equals("design_control_signal") && !toolsName.equals("generate_project_info")) {
|
||||
/*&& !toolsName.equals("design_control_signal")
|
||||
&& !toolsName.equals("generate_project_info")*/
|
||||
if (Objects.nonNull(toolsName) && designTools.contains(toolsName)) {
|
||||
boolean color = true;
|
||||
ReceiveDesignParam receiveDesignParam = JSONObject.parseObject(JSONObject.toJSONString(toolsData), ReceiveDesignParam.class);
|
||||
receiveDesignParam.setProjectId(projectId);
|
||||
@@ -354,6 +366,11 @@ public class LLMServiceImpl implements LLMService {
|
||||
systemImage.setContent(contentSave);
|
||||
systemImage.setAccountId(accountId);
|
||||
chatMessageMapper.insert(systemImage);
|
||||
} else if (Objects.nonNull(toolsName) && toolsName.equals("search_sketch_img")) {
|
||||
json.put("content", processSearchSketchToolCon(toolsData));
|
||||
} else if (Objects.nonNull(toolsName)
|
||||
&& toolsName.equals("update_project_info")) {
|
||||
updateProjectParams(projectId, toolsData);
|
||||
}
|
||||
emitter.send(json.toJSONString());
|
||||
}
|
||||
@@ -368,7 +385,6 @@ public class LLMServiceImpl implements LLMService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
emitter.complete();
|
||||
} catch (Exception e) {
|
||||
System.out.println("走进异常");
|
||||
@@ -379,6 +395,72 @@ public class LLMServiceImpl implements LLMService {
|
||||
return emitter;
|
||||
}
|
||||
|
||||
private String processSearchSketchToolCon(JSONObject content){
|
||||
// content内容 "{\"sketch_list\": [\"\\\\female\\\\blouse\\\\blouse_645.jpg\", \"\\\\female\\\\dress\\\\0902004968.jpg\"]}"
|
||||
JSONArray sketchList = content.getJSONArray("sketch_list");
|
||||
if (sketchList.isEmpty()){
|
||||
return null;
|
||||
}
|
||||
ArrayList<ReceiveCollectionElement> dataList = new ArrayList<>();
|
||||
sketchList.forEach(sketch -> {
|
||||
ReceiveCollectionElement receiveCollectionElement = new ReceiveCollectionElement();
|
||||
receiveCollectionElement.setUrl((String) sketch);
|
||||
receiveCollectionElement.setMinioUrl(minioUtil.getPreSignedUrl(sysImage + "/images" + sketch, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
dataList.add(receiveCollectionElement);
|
||||
});
|
||||
ReceiveDesignParam receiveDesignParam = new ReceiveDesignParam();
|
||||
receiveDesignParam.setReceiveCollectionElementList(dataList);
|
||||
return JSONArray.toJSONString(receiveDesignParam);
|
||||
}
|
||||
|
||||
@Resource
|
||||
private WorkspaceService workspaceService;
|
||||
private String updateProjectParams(Long projectId, JSONObject jsonObject){
|
||||
// 1. 获取 project_info 并转换为 List<Map<String, String>>
|
||||
List<Map<String, String>> projectInfoList = (List<Map<String, String>>) jsonObject.get("project_info");
|
||||
|
||||
Long workspaceId = workspaceService.getByProjectId(projectId);
|
||||
if (Objects.isNull(workspaceId)){
|
||||
throw new BusinessException("未知projectId");
|
||||
}
|
||||
Workspace workspace = workspaceService.getBaseMapper().selectOne(new QueryWrapper<Workspace>().eq("project_id", projectId));
|
||||
if (!projectInfoList.isEmpty()){
|
||||
projectInfoList.forEach(info ->
|
||||
info.forEach((key, value) -> {
|
||||
switch (key){
|
||||
case "project_name":
|
||||
Project project = projectMapper.selectById(projectId);
|
||||
project.setName(value);
|
||||
project.setUpdateTime(LocalDateTime.now());
|
||||
projectMapper.updateById(project);
|
||||
break;
|
||||
case "ageGroup":
|
||||
workspace.setAgeGroup(value);
|
||||
break;
|
||||
case "gender":
|
||||
workspace.setSex(value);
|
||||
break;
|
||||
case "position":
|
||||
workspace.setPosition(value);
|
||||
break;
|
||||
case "style":
|
||||
QueryWrapper<Style> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(Style::getName, value);
|
||||
Style style = styleMapper.selectOne(qw);
|
||||
if (Objects.nonNull(style)) {
|
||||
WorkspaceRelStyle workspaceRelStyle = workspaceRelStyleMapper.selectOne(new QueryWrapper<WorkspaceRelStyle>().eq("workspace_id", workspaceId));
|
||||
workspaceRelStyle.setStyleId(style.getId());
|
||||
workspaceRelStyleMapper.updateById(workspaceRelStyle);
|
||||
}
|
||||
break;
|
||||
}
|
||||
})
|
||||
);
|
||||
workspaceMapper.updateById(workspace);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long chatCreateProject(String prompt, String process, String fileUrl, List<String> imageUrlList) {
|
||||
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||
|
||||
Reference in New Issue
Block a user