Commit f58c7624 authored by alex yao's avatar alex yao

fix: 修复保存variable_structure结构

parent 5019fc74
...@@ -13,7 +13,9 @@ import cn.com.poc.agent_application.query.PublishAgentApplicationQueryItem; ...@@ -13,7 +13,9 @@ import cn.com.poc.agent_application.query.PublishAgentApplicationQueryItem;
import cn.com.poc.common.utils.JsonUtils; import cn.com.poc.common.utils.JsonUtils;
import cn.com.poc.expose.dto.SearchAgentApplicationDto; import cn.com.poc.expose.dto.SearchAgentApplicationDto;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.core.type.TypeReference;
import com.tencent.core.utils.JsonUtil; import com.tencent.core.utils.JsonUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -50,7 +52,8 @@ public class AgentApplicationInfoConvert { ...@@ -50,7 +52,8 @@ public class AgentApplicationInfoConvert {
entity.setPublishTime(model.getPublishTime()); entity.setPublishTime(model.getPublishTime());
entity.setIsLongMemory(model.getIsLongMemory()); entity.setIsLongMemory(model.getIsLongMemory());
if (StringUtils.isNotBlank(model.getVariableStructure())) { if (StringUtils.isNotBlank(model.getVariableStructure())) {
entity.setVariableStructure(JsonUtils.deSerialize(model.getVariableStructure(), String[].class)); entity.setVariableStructure(JsonUtils.deSerialize(model.getVariableStructure(), new TypeReference<List<Variable>>() {
}.getType()));
} }
if (StringUtils.isNotBlank(model.getFeaturedQuestions())) { if (StringUtils.isNotBlank(model.getFeaturedQuestions())) {
entity.setFeaturedQuestions(JsonUtils.deSerialize(model.getFeaturedQuestions(), String[].class)); entity.setFeaturedQuestions(JsonUtils.deSerialize(model.getFeaturedQuestions(), String[].class));
...@@ -90,7 +93,7 @@ public class AgentApplicationInfoConvert { ...@@ -90,7 +93,7 @@ public class AgentApplicationInfoConvert {
model.setPreamble(entity.getPreamble()); model.setPreamble(entity.getPreamble());
model.setPublishTime(entity.getPublishTime()); model.setPublishTime(entity.getPublishTime());
model.setIsLongMemory(entity.getIsLongMemory()); model.setIsLongMemory(entity.getIsLongMemory());
if (ArrayUtils.isNotEmpty(entity.getVariableStructure())) { if (CollectionUtils.isNotEmpty(entity.getVariableStructure())) {
model.setVariableStructure(JsonUtils.serialize(entity.getVariableStructure())); model.setVariableStructure(JsonUtils.serialize(entity.getVariableStructure()));
} }
if (ArrayUtils.isNotEmpty(entity.getFeaturedQuestions())) { if (ArrayUtils.isNotEmpty(entity.getFeaturedQuestions())) {
...@@ -135,24 +138,7 @@ public class AgentApplicationInfoConvert { ...@@ -135,24 +138,7 @@ public class AgentApplicationInfoConvert {
commConfig.setContinuousQuestionStatus(entity.getContinuousQuestionStatus()); commConfig.setContinuousQuestionStatus(entity.getContinuousQuestionStatus());
commConfig.setContinuousQuestionSystem(entity.getContinuousQuestionSystem()); commConfig.setContinuousQuestionSystem(entity.getContinuousQuestionSystem());
commConfig.setContinuousQuestionTurn(entity.getContinuousQuestionTurn()); commConfig.setContinuousQuestionTurn(entity.getContinuousQuestionTurn());
List<Variable> variables = new ArrayList<>(); commConfig.setVariableStructure(entity.getVariableStructure());
String[] variableStructure = entity.getVariableStructure();
if(variableStructure != null){
for (int i = 0; i < variableStructure.length; i++) {
Variable variable = new Variable();
String input = variableStructure[i];
// 定义正则表达式模式
String regex = "\"key\":\"(.*?)\",\"default\":\"(.*?)\"";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(input);
if (matcher.find()) {
variable.setKey(matcher.group(1));
variable.setVariableDefault(matcher.group(2));
variables.add(variable);
}
}
}
commConfig.setVariableStructure(variables);
commConfig.setIsLongMemory(entity.getIsLongMemory()); commConfig.setIsLongMemory(entity.getIsLongMemory());
...@@ -197,15 +183,8 @@ public class AgentApplicationInfoConvert { ...@@ -197,15 +183,8 @@ public class AgentApplicationInfoConvert {
entity.setContinuousQuestionStatus(dto.getCommConfig().getContinuousQuestionStatus()); entity.setContinuousQuestionStatus(dto.getCommConfig().getContinuousQuestionStatus());
entity.setContinuousQuestionSystem(dto.getCommConfig().getContinuousQuestionSystem()); entity.setContinuousQuestionSystem(dto.getCommConfig().getContinuousQuestionSystem());
entity.setContinuousQuestionTurn(dto.getCommConfig().getContinuousQuestionTurn()); entity.setContinuousQuestionTurn(dto.getCommConfig().getContinuousQuestionTurn());
if (ObjectUtil.isNotEmpty(dto.getCommConfig().getVariableStructure())) { if (CollectionUtils.isNotEmpty(dto.getCommConfig().getVariableStructure())) {
List<Variable> variables = dto.getCommConfig().getVariableStructure(); entity.setVariableStructure(dto.getCommConfig().getVariableStructure());
String[] result = new String[variables.size()];
for (int i = 0; i < variables.size(); i++) {
String key = variables.get(i).getKey();
String variableDefault = variables.get(i).getVariableDefault();
result[i] = "\"key\":\"" + key + "\"," + "\"default\":\"" + variableDefault + "\"";
}
entity.setVariableStructure(result);
} }
entity.setIsLongMemory(dto.getCommConfig().getIsLongMemory()); entity.setIsLongMemory(dto.getCommConfig().getIsLongMemory());
} }
...@@ -244,7 +223,8 @@ public class AgentApplicationInfoConvert { ...@@ -244,7 +223,8 @@ public class AgentApplicationInfoConvert {
entity.setIsLongMemory(infoQueryItem.getIsLongMemory()); entity.setIsLongMemory(infoQueryItem.getIsLongMemory());
if (StringUtils.isNotBlank(infoQueryItem.getVariableStructure())) { if (StringUtils.isNotBlank(infoQueryItem.getVariableStructure())) {
entity.setVariableStructure(JsonUtils.deSerialize(infoQueryItem.getVariableStructure(), String[].class)); entity.setVariableStructure(JsonUtils.deSerialize(infoQueryItem.getVariableStructure(), new TypeReference<List<Variable>>() {
}.getType()));
} }
if (StringUtils.isNotBlank(infoQueryItem.getFeaturedQuestions())) { if (StringUtils.isNotBlank(infoQueryItem.getFeaturedQuestions())) {
......
...@@ -21,7 +21,7 @@ import java.util.regex.Pattern; ...@@ -21,7 +21,7 @@ import java.util.regex.Pattern;
public class BizAgentApplicationMallConvert { public class BizAgentApplicationMallConvert {
public static BizAgentApplicationMallEntity modelToEntity(BizAgentApplicationMallModel model){ public static BizAgentApplicationMallEntity modelToEntity(BizAgentApplicationMallModel model) {
BizAgentApplicationMallEntity entity = new BizAgentApplicationMallEntity(); BizAgentApplicationMallEntity entity = new BizAgentApplicationMallEntity();
entity.setId(model.getId()); entity.setId(model.getId());
entity.setAgentPublishId(model.getAgentPublishId()); entity.setAgentPublishId(model.getAgentPublishId());
...@@ -34,7 +34,7 @@ public class BizAgentApplicationMallConvert { ...@@ -34,7 +34,7 @@ public class BizAgentApplicationMallConvert {
return entity; return entity;
} }
public static BizAgentApplicationMallModel entityToModel(BizAgentApplicationMallEntity entity){ public static BizAgentApplicationMallModel entityToModel(BizAgentApplicationMallEntity entity) {
BizAgentApplicationMallModel model = new BizAgentApplicationMallModel(); BizAgentApplicationMallModel model = new BizAgentApplicationMallModel();
model.setId(entity.getId()); model.setId(entity.getId());
model.setAgentPublishId(entity.getAgentPublishId()); model.setAgentPublishId(entity.getAgentPublishId());
...@@ -55,7 +55,7 @@ public class BizAgentApplicationMallConvert { ...@@ -55,7 +55,7 @@ public class BizAgentApplicationMallConvert {
BizAgentApplicationPublishEntity publishEntity = agentApplicationPublishService.get(entity.getAgentPublishId()); BizAgentApplicationPublishEntity publishEntity = agentApplicationPublishService.get(entity.getAgentPublishId());
AgentApplicationBaseInfo baseInfo = new AgentApplicationBaseInfo(); AgentApplicationBaseInfo baseInfo = new AgentApplicationBaseInfo();
if(publishEntity != null){ if (publishEntity != null) {
baseInfo.setMemberId(publishEntity.getMemberId()); baseInfo.setMemberId(publishEntity.getMemberId());
baseInfo.setAgentId(publishEntity.getAgentId()); baseInfo.setAgentId(publishEntity.getAgentId());
baseInfo.setAgentTitle(publishEntity.getAgentTitle()); baseInfo.setAgentTitle(publishEntity.getAgentTitle());
...@@ -67,37 +67,23 @@ public class BizAgentApplicationMallConvert { ...@@ -67,37 +67,23 @@ public class BizAgentApplicationMallConvert {
} }
AgentApplicationCommConfig commConfig = new AgentApplicationCommConfig(); AgentApplicationCommConfig commConfig = new AgentApplicationCommConfig();
if(publishEntity != null){ if (publishEntity != null) {
commConfig.setPreamble(publishEntity.getPreamble()); commConfig.setPreamble(publishEntity.getPreamble());
commConfig.setFeaturedQuestions(publishEntity.getFeaturedQuestions()); commConfig.setFeaturedQuestions(publishEntity.getFeaturedQuestions());
commConfig.setContinuousQuestionStatus(publishEntity.getContinuousQuestionStatus()); commConfig.setContinuousQuestionStatus(publishEntity.getContinuousQuestionStatus());
commConfig.setContinuousQuestionSystem(publishEntity.getContinuousQuestionSystem()); commConfig.setContinuousQuestionSystem(publishEntity.getContinuousQuestionSystem());
commConfig.setContinuousQuestionTurn(publishEntity.getContinuousQuestionTurn()); commConfig.setContinuousQuestionTurn(publishEntity.getContinuousQuestionTurn());
List<Variable> variables = new ArrayList<>(); commConfig.setVariableStructure(publishEntity.getVariableStructure());
String[] variableStructure = publishEntity.getVariableStructure();
for (int i = 0; i < variableStructure.length; i++) {
Variable variable = new Variable();
String input = variableStructure[i];
// 定义正则表达式模式
Pattern pattern = Pattern.compile("(key|default):([^,]+)");
Matcher matcher = pattern.matcher(input);
if (matcher.find()) {
variable.setKey(matcher.group(1));
variable.setVariableDefault(matcher.group(2));
variables.add(variable);
}
}
commConfig.setVariableStructure(variables);
commConfig.setIsLongMemory(publishEntity.getIsLongMemory()); commConfig.setIsLongMemory(publishEntity.getIsLongMemory());
} }
AgentApplicationKnowledgeConfig knowledgeConfig = new AgentApplicationKnowledgeConfig(); AgentApplicationKnowledgeConfig knowledgeConfig = new AgentApplicationKnowledgeConfig();
if(publishEntity != null){ if (publishEntity != null) {
knowledgeConfig.setKnowledgeIds(publishEntity.getKnowledgeIds()); knowledgeConfig.setKnowledgeIds(publishEntity.getKnowledgeIds());
} }
AgentApplicationCommModelConfig commModelConfig = new AgentApplicationCommModelConfig(); AgentApplicationCommModelConfig commModelConfig = new AgentApplicationCommModelConfig();
if(publishEntity != null){ if (publishEntity != null) {
commModelConfig.setLargeModel(publishEntity.getLargeModel()); commModelConfig.setLargeModel(publishEntity.getLargeModel());
commModelConfig.setTopP(publishEntity.getTopP()); commModelConfig.setTopP(publishEntity.getTopP());
commModelConfig.setCommunicationTurn(publishEntity.getCommunicationTurn()); commModelConfig.setCommunicationTurn(publishEntity.getCommunicationTurn());
...@@ -111,7 +97,7 @@ public class BizAgentApplicationMallConvert { ...@@ -111,7 +97,7 @@ public class BizAgentApplicationMallConvert {
dto.setCommConfig(commConfig); dto.setCommConfig(commConfig);
dto.setKnowledgeConfig(knowledgeConfig); dto.setKnowledgeConfig(knowledgeConfig);
dto.setCommModelConfig(commModelConfig); dto.setCommModelConfig(commModelConfig);
if(publishEntity != null){ if (publishEntity != null) {
dto.setUnitIds(publishEntity.getUnitIds()); dto.setUnitIds(publishEntity.getUnitIds());
} }
...@@ -122,7 +108,7 @@ public class BizAgentApplicationMallConvert { ...@@ -122,7 +108,7 @@ public class BizAgentApplicationMallConvert {
return dto; return dto;
} }
public static BizAgentApplicationMallEntity dtoToEntity(BizAgentApplicationMallDto dto){ public static BizAgentApplicationMallEntity dtoToEntity(BizAgentApplicationMallDto dto) {
BizAgentApplicationMallEntity entity = new BizAgentApplicationMallEntity(); BizAgentApplicationMallEntity entity = new BizAgentApplicationMallEntity();
entity.setId(dto.getId()); entity.setId(dto.getId());
entity.setAgentPublishId(dto.getAgentPublishId()); entity.setAgentPublishId(dto.getAgentPublishId());
......
...@@ -10,7 +10,9 @@ import cn.com.poc.agent_application.entity.Variable; ...@@ -10,7 +10,9 @@ import cn.com.poc.agent_application.entity.Variable;
import cn.com.poc.agent_application.model.BizAgentApplicationPublishModel; import cn.com.poc.agent_application.model.BizAgentApplicationPublishModel;
import cn.com.poc.common.utils.JsonUtils; import cn.com.poc.common.utils.JsonUtils;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.core.type.TypeReference;
import com.tencent.core.utils.JsonUtil; import com.tencent.core.utils.JsonUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -34,12 +36,10 @@ public class BizAgentApplicationPublishConvert { ...@@ -34,12 +36,10 @@ public class BizAgentApplicationPublishConvert {
entity.setPreamble(model.getPreamble()); entity.setPreamble(model.getPreamble());
entity.setIsLongMemory(model.getIsLongMemory()); entity.setIsLongMemory(model.getIsLongMemory());
if (StringUtils.isNotBlank(model.getVariableStructure())) { if (StringUtils.isNotBlank(model.getVariableStructure())) {
entity.setVariableStructure(JsonUtils.deSerialize(model.getVariableStructure(), String[].class)); entity.setVariableStructure(JsonUtils.deSerialize(model.getVariableStructure(), new TypeReference<List<Variable>>() {
}.getType()));
} }
if (StringUtils.isNotBlank(model.getVariableStructure())) {
entity.setVariableStructure(JsonUtils.deSerialize(model.getVariableStructure(), String[].class));
}
if (StringUtils.isNotBlank(model.getFeaturedQuestions())) { if (StringUtils.isNotBlank(model.getFeaturedQuestions())) {
entity.setFeaturedQuestions(JsonUtils.deSerialize(model.getFeaturedQuestions(), String[].class)); entity.setFeaturedQuestions(JsonUtils.deSerialize(model.getFeaturedQuestions(), String[].class));
} }
...@@ -76,7 +76,7 @@ public class BizAgentApplicationPublishConvert { ...@@ -76,7 +76,7 @@ public class BizAgentApplicationPublishConvert {
model.setAgentSystem(entity.getAgentSystem()); model.setAgentSystem(entity.getAgentSystem());
model.setPreamble(entity.getPreamble()); model.setPreamble(entity.getPreamble());
model.setIsLongMemory(entity.getIsLongMemory()); model.setIsLongMemory(entity.getIsLongMemory());
if (ArrayUtils.isNotEmpty(entity.getVariableStructure())) { if (CollectionUtils.isNotEmpty(entity.getVariableStructure())) {
model.setVariableStructure(JsonUtils.serialize(entity.getVariableStructure())); model.setVariableStructure(JsonUtils.serialize(entity.getVariableStructure()));
} }
if (ArrayUtils.isNotEmpty(entity.getFeaturedQuestions())) { if (ArrayUtils.isNotEmpty(entity.getFeaturedQuestions())) {
...@@ -122,24 +122,7 @@ public class BizAgentApplicationPublishConvert { ...@@ -122,24 +122,7 @@ public class BizAgentApplicationPublishConvert {
commConfig.setContinuousQuestionStatus(entity.getContinuousQuestionStatus()); commConfig.setContinuousQuestionStatus(entity.getContinuousQuestionStatus());
commConfig.setContinuousQuestionSystem(entity.getContinuousQuestionSystem()); commConfig.setContinuousQuestionSystem(entity.getContinuousQuestionSystem());
commConfig.setContinuousQuestionTurn(entity.getContinuousQuestionTurn()); commConfig.setContinuousQuestionTurn(entity.getContinuousQuestionTurn());
List<Variable> variables = new ArrayList<>(); commConfig.setVariableStructure(entity.getVariableStructure());
String[] variableStructure = entity.getVariableStructure();
if(variableStructure != null){
for (int i = 0; i < variableStructure.length; i++) {
Variable variable = new Variable();
String input = variableStructure[i];
// 定义正则表达式模式
String regex = "\"key\":\"(.*?)\",\"default\":\"(.*?)\"";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(input);
if (matcher.find()) {
variable.setKey(matcher.group(1));
variable.setVariableDefault(matcher.group(2));
variables.add(variable);
}
}
}
commConfig.setVariableStructure(variables);
commConfig.setIsLongMemory(entity.getIsLongMemory()); commConfig.setIsLongMemory(entity.getIsLongMemory());
AgentApplicationKnowledgeConfig knowledgeConfig = new AgentApplicationKnowledgeConfig(); AgentApplicationKnowledgeConfig knowledgeConfig = new AgentApplicationKnowledgeConfig();
...@@ -184,15 +167,8 @@ public class BizAgentApplicationPublishConvert { ...@@ -184,15 +167,8 @@ public class BizAgentApplicationPublishConvert {
entity.setContinuousQuestionSystem(dto.getCommConfig().getContinuousQuestionSystem()); entity.setContinuousQuestionSystem(dto.getCommConfig().getContinuousQuestionSystem());
entity.setContinuousQuestionTurn(dto.getCommConfig().getContinuousQuestionTurn()); entity.setContinuousQuestionTurn(dto.getCommConfig().getContinuousQuestionTurn());
entity.setIsLongMemory(dto.getCommConfig().getIsLongMemory()); entity.setIsLongMemory(dto.getCommConfig().getIsLongMemory());
if (ObjectUtil.isNotEmpty(dto.getCommConfig().getVariableStructure())) { if (CollectionUtils.isNotEmpty(dto.getCommConfig().getVariableStructure())) {
List<Variable> variables = dto.getCommConfig().getVariableStructure(); entity.setVariableStructure(dto.getCommConfig().getVariableStructure());
String[] result = new String[variables.size()];
for (int i = 0; i < variables.size(); i++) {
String key = variables.get(i).getKey();
String variableDefault = variables.get(i).getVariableDefault();
result[i] = "key:" + key + "," + "default:" + variableDefault;
}
entity.setVariableStructure(result);
} }
} }
......
...@@ -2,6 +2,7 @@ package cn.com.poc.agent_application.entity; ...@@ -2,6 +2,7 @@ package cn.com.poc.agent_application.entity;
import javax.persistence.Column; import javax.persistence.Column;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
public class BizAgentApplicationInfoEntity { public class BizAgentApplicationInfoEntity {
...@@ -290,13 +291,13 @@ public class BizAgentApplicationInfoEntity { ...@@ -290,13 +291,13 @@ public class BizAgentApplicationInfoEntity {
* variable_structure * variable_structure
* 变量结构 * 变量结构
*/ */
private java.lang.String[] variableStructure; private List<Variable> variableStructure;
public java.lang.String[] getVariableStructure() { public List<Variable> getVariableStructure() {
return this.variableStructure; return variableStructure;
} }
public void setVariableStructure(java.lang.String[] variableStructure) { public void setVariableStructure(List<Variable> variableStructure) {
this.variableStructure = variableStructure; this.variableStructure = variableStructure;
} }
...@@ -421,7 +422,7 @@ public class BizAgentApplicationInfoEntity { ...@@ -421,7 +422,7 @@ public class BizAgentApplicationInfoEntity {
", largeModel='" + largeModel + '\'' + ", largeModel='" + largeModel + '\'' +
", topP=" + topP + ", topP=" + topP +
", unitIds=" + Arrays.toString(unitIds) + ", unitIds=" + Arrays.toString(unitIds) +
", variableStructure=" + Arrays.toString(variableStructure) + ", variableStructure=" + variableStructure +
", isLongMemory='" + isLongMemory + '\'' + ", isLongMemory='" + isLongMemory + '\'' +
", isDeleted='" + isDeleted + '\'' + ", isDeleted='" + isDeleted + '\'' +
", creator='" + creator + '\'' + ", creator='" + creator + '\'' +
......
package cn.com.poc.agent_application.entity; package cn.com.poc.agent_application.entity;
import java.util.List;
public class BizAgentApplicationPublishEntity { public class BizAgentApplicationPublishEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -128,13 +130,13 @@ public class BizAgentApplicationPublishEntity { ...@@ -128,13 +130,13 @@ public class BizAgentApplicationPublishEntity {
/** variable_structure /** variable_structure
*变量结构 *变量结构
*/ */
private java.lang.String[] variableStructure; private List<Variable> variableStructure;
public java.lang.String[] getVariableStructure(){ public List<Variable> getVariableStructure(){
return this.variableStructure; return this.variableStructure;
} }
public void setVariableStructure(java.lang.String[] variableStructure){ public void setVariableStructure(List<Variable> variableStructure){
this.variableStructure = variableStructure; this.variableStructure = variableStructure;
} }
......
...@@ -323,7 +323,7 @@ public class AgentApplicationInfoQueryItem extends BaseItemClass implements Seri ...@@ -323,7 +323,7 @@ public class AgentApplicationInfoQueryItem extends BaseItemClass implements Seri
*/ */
private java.lang.String variableStructure; private java.lang.String variableStructure;
@Column(name = "variable_structure", length = 2147483647) @Column(name = "variable_structure")
public java.lang.String getVariableStructure() { public java.lang.String getVariableStructure() {
return this.variableStructure; return this.variableStructure;
} }
......
...@@ -72,15 +72,15 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest { ...@@ -72,15 +72,15 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
} }
List<BizAgentApplicationInfoEntity> bizAgentApplicationInfoEntities = bizAgentApplicationInfoService.agentApplicationInfoQuery(condition, pagingInfo); List<BizAgentApplicationInfoEntity> bizAgentApplicationInfoEntities = bizAgentApplicationInfoService.agentApplicationInfoQuery(condition, pagingInfo);
List<AgentApplicationInfoDto> resultList = new ArrayList<>(); List<AgentApplicationInfoDto> resultList = new ArrayList<>();
for(BizAgentApplicationInfoEntity entity : bizAgentApplicationInfoEntities){ for (BizAgentApplicationInfoEntity entity : bizAgentApplicationInfoEntities) {
AgentApplicationInfoDto infoDto = AgentApplicationInfoConvert.entityToDto(entity); AgentApplicationInfoDto infoDto = AgentApplicationInfoConvert.entityToDto(entity);
// 先判断有没有收藏的查询条件 // 先判断有没有收藏的查询条件
if(StringUtils.isNotBlank(dto.getIsCollect())){ if (StringUtils.isNotBlank(dto.getIsCollect())) {
// 如果有查询条件,则判断符不符合条件 // 如果有查询条件,则判断符不符合条件
if(infoDto.getBaseInfo() != null){ if (infoDto.getBaseInfo() != null) {
BizMemberAgentApplicationCollectEntity collect = bizMemberAgentApplicationCollectService.getByAgentId(infoDto.getBaseInfo().getAgentId()); BizMemberAgentApplicationCollectEntity collect = bizMemberAgentApplicationCollectService.getByAgentId(infoDto.getBaseInfo().getAgentId());
// 如果符合条件,则把值加入 // 如果符合条件,则把值加入
if(collect != null && collect.getIsCollect().equals(dto.getIsCollect())){ if (collect != null && collect.getIsCollect().equals(dto.getIsCollect())) {
infoDto.setIsCollect(collect.getIsCollect()); infoDto.setIsCollect(collect.getIsCollect());
} else if ((collect == null && CommonConstant.IsDeleted.N.equals(dto.getIsCollect()))) { } else if ((collect == null && CommonConstant.IsDeleted.N.equals(dto.getIsCollect()))) {
infoDto.setIsCollect(CommonConstant.IsDeleted.N); infoDto.setIsCollect(CommonConstant.IsDeleted.N);
...@@ -88,33 +88,33 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest { ...@@ -88,33 +88,33 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
// 如果不符合条件,则continue // 如果不符合条件,则continue
continue; continue;
} }
}else { } else {
continue; continue;
} }
}else { } else {
// 如何没有查询条件,则直接按照原来的逻辑走 // 如何没有查询条件,则直接按照原来的逻辑走
// 设置当前用户是否收藏了 // 设置当前用户是否收藏了
if(infoDto.getBaseInfo() != null){ if (infoDto.getBaseInfo() != null) {
BizMemberAgentApplicationCollectEntity collect = bizMemberAgentApplicationCollectService.getByAgentId(infoDto.getBaseInfo().getAgentId()); BizMemberAgentApplicationCollectEntity collect = bizMemberAgentApplicationCollectService.getByAgentId(infoDto.getBaseInfo().getAgentId());
if(collect != null){ if (collect != null) {
infoDto.setIsCollect(collect.getIsCollect()); infoDto.setIsCollect(collect.getIsCollect());
}else { } else {
infoDto.setIsCollect(CommonConstant.IsDeleted.N); infoDto.setIsCollect(CommonConstant.IsDeleted.N);
} }
} }
} }
// 判断是否发布了,若发布则设置agentPublishId // 判断是否发布了,若发布则设置agentPublishId
BizAgentApplicationPublishEntity publishEntity = bizAgentApplicationPublishService.getByAgentId(entity.getAgentId()); BizAgentApplicationPublishEntity publishEntity = bizAgentApplicationPublishService.getByAgentId(entity.getAgentId());
if(publishEntity != null){ if (publishEntity != null) {
infoDto.setAgentPublishId(publishEntity.getId()); infoDto.setAgentPublishId(publishEntity.getId());
// 设置当前作品是否上架 // 设置当前作品是否上架
BizAgentApplicationMallEntity mallEntity = bizAgentApplicationMallService.getByAgentPublishId(publishEntity.getId()); BizAgentApplicationMallEntity mallEntity = bizAgentApplicationMallService.getByAgentPublishId(publishEntity.getId());
if(mallEntity != null){ if (mallEntity != null) {
infoDto.setIsSale(mallEntity.getIsSale()); infoDto.setIsSale(mallEntity.getIsSale());
}else{ } else {
infoDto.setIsSale(CommonConstant.IsDeleted.N); infoDto.setIsSale(CommonConstant.IsDeleted.N);
} }
}else{ } else {
infoDto.setAgentPublishId(null); infoDto.setAgentPublishId(null);
} }
resultList.add(infoDto); resultList.add(infoDto);
...@@ -165,7 +165,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest { ...@@ -165,7 +165,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
bizAgentApplicationInfoService.deletedByAgentId(agentId); bizAgentApplicationInfoService.deletedByAgentId(agentId);
// 删除应用 // 删除应用
BizAgentApplicationPublishEntity publishEntity = bizAgentApplicationPublishService.getByAgentId(agentId); BizAgentApplicationPublishEntity publishEntity = bizAgentApplicationPublishService.getByAgentId(agentId);
if(publishEntity != null){ if (publishEntity != null) {
// 删除应用市场表中的应用 // 删除应用市场表中的应用
bizAgentApplicationMallService.deletedByAgentPublishId(publishEntity.getId()); bizAgentApplicationMallService.deletedByAgentPublishId(publishEntity.getId());
// 删除发布表中的应用 // 删除发布表中的应用
...@@ -204,11 +204,12 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest { ...@@ -204,11 +204,12 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
//配置对话function //配置对话function
List<Tool> tools = new ArrayList<>(); List<Tool> tools = new ArrayList<>();
//开启对话变量 //开启对话变量
if (ArrayUtils.isNotEmpty(infoEntity.getVariableStructure())) { if (CollectionUtils.isNotEmpty(infoEntity.getVariableStructure())) {
//todo 修正
String functionName = LargeModelFunctionEnum.set_value_memory.name(); String functionName = LargeModelFunctionEnum.set_value_memory.name();
String llmConfig = LargeModelFunctionEnum.valueOf(functionName).getFunction().getVariableStructureLLMConfig(infoEntity.getVariableStructure()).get(0); // String llmConfig = LargeModelFunctionEnum.valueOf(functionName).getFunction().getVariableStructureLLMConfig(infoEntity.getVariableStructure()).get(0);
Tool tool = JsonUtils.deSerialize(llmConfig, Tool.class); // Tool tool = JsonUtils.deSerialize(llmConfig, Tool.class);
tools.add(tool); // tools.add(tool);
} }
//开启长期记忆 //开启长期记忆
if (CommonConstant.YOrN.Y.equals(infoEntity.getIsLongMemory())) { if (CommonConstant.YOrN.Y.equals(infoEntity.getIsLongMemory())) {
......
...@@ -310,11 +310,11 @@ public class AgentApplicationServiceImpl implements AgentApplicationService { ...@@ -310,11 +310,11 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
private List<Tool> buildMemoryConfig(BizAgentApplicationPublishEntity infoEntity) { private List<Tool> buildMemoryConfig(BizAgentApplicationPublishEntity infoEntity) {
List<Tool> tools = new ArrayList<>(); List<Tool> tools = new ArrayList<>();
//开启对话变量 //开启对话变量
if (ArrayUtils.isNotEmpty(infoEntity.getVariableStructure())) { if (CollectionUtils.isNotEmpty(infoEntity.getVariableStructure())) {
String functionName = LargeModelFunctionEnum.set_value_memory.name(); // String functionName = LargeModelFunctionEnum.set_value_memory.name();
String llmConfig = LargeModelFunctionEnum.valueOf(functionName).getFunction().getVariableStructureLLMConfig(infoEntity.getVariableStructure()).get(0); // String llmConfig = LargeModelFunctionEnum.valueOf(functionName).getFunction().getVariableStructureLLMConfig(infoEntity.getVariableStructure()).get(0);
Tool tool = JsonUtils.deSerialize(llmConfig, Tool.class); // Tool tool = JsonUtils.deSerialize(llmConfig, Tool.class);
tools.add(tool); // tools.add(tool);
} }
//开启长期记忆 //开启长期记忆
if (CommonConstant.YOrN.Y.equals(infoEntity.getIsLongMemory())) { if (CommonConstant.YOrN.Y.equals(infoEntity.getIsLongMemory())) {
......
package cn.com.poc.thirdparty.resource.demand.ai.function; package cn.com.poc.thirdparty.resource.demand.ai.function;
import cn.com.poc.agent_application.entity.Variable;
import java.util.List; import java.util.List;
public abstract class AbstractLargeModelFunction { public abstract class AbstractLargeModelFunction {
...@@ -15,6 +17,6 @@ public abstract class AbstractLargeModelFunction { ...@@ -15,6 +17,6 @@ public abstract class AbstractLargeModelFunction {
/** /**
* 获取有关变量的配置 * 获取有关变量的配置
*/ */
public abstract List<String> getVariableStructureLLMConfig(String[] variableStructure); public abstract List<String> getVariableStructureLLMConfig(List<Variable> variableStructure);
} }
package cn.com.poc.thirdparty.resource.demand.ai.function.long_memory; package cn.com.poc.thirdparty.resource.demand.ai.function.long_memory;
import cn.com.poc.agent_application.entity.Variable;
import cn.com.poc.common.service.RedisService; import cn.com.poc.common.service.RedisService;
import cn.com.poc.common.utils.BlContext; import cn.com.poc.common.utils.BlContext;
import cn.com.poc.common.utils.DateUtils; import cn.com.poc.common.utils.DateUtils;
...@@ -82,7 +83,7 @@ public class SetLongMemoryFunction extends AbstractLargeModelFunction { ...@@ -82,7 +83,7 @@ public class SetLongMemoryFunction extends AbstractLargeModelFunction {
} }
@Override @Override
public List<String> getVariableStructureLLMConfig(String[] variableStructure) { public List<String> getVariableStructureLLMConfig(List<Variable> variableStructure) {
throw new BusinessException("暂不支持变量结构配置"); throw new BusinessException("暂不支持变量结构配置");
} }
} }
package cn.com.poc.thirdparty.resource.demand.ai.function.value_memory; package cn.com.poc.thirdparty.resource.demand.ai.function.value_memory;
import cn.com.poc.agent_application.entity.Variable;
import cn.com.poc.common.service.RedisService; import cn.com.poc.common.service.RedisService;
import cn.com.poc.common.utils.BlContext; import cn.com.poc.common.utils.BlContext;
import cn.com.poc.thirdparty.resource.demand.ai.function.AbstractLargeModelFunction; import cn.com.poc.thirdparty.resource.demand.ai.function.AbstractLargeModelFunction;
...@@ -49,7 +50,7 @@ public class SetValueMemoryFunction extends AbstractLargeModelFunction { ...@@ -49,7 +50,7 @@ public class SetValueMemoryFunction extends AbstractLargeModelFunction {
} }
@Override @Override
public List<String> getVariableStructureLLMConfig(String[] variableStructure) { public List<String> getVariableStructureLLMConfig(List<Variable> variableStructure) {
Map<String, Object> config = new HashMap<>(); Map<String, Object> config = new HashMap<>();
Map<String, Object> function = new HashMap<>(); Map<String, Object> function = new HashMap<>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment