Commit 8f2a35c7 authored by alex yao's avatar alex yao

feat:getVariableList排序

parent 07c311c0
......@@ -18,7 +18,6 @@ import cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Tool;
import cn.com.poc.thirdparty.resource.demand.ai.function.LargeModelFunctionEnum;
import cn.com.poc.thirdparty.resource.demand.ai.function.long_memory.SetLongMemoryConstants;
import cn.com.poc.thirdparty.resource.demand.ai.function.value_memory.GetValueMemory;
import cn.com.poc.thirdparty.resource.demand.ai.function.value_memory.SetValueMemoryConstants;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.data.model.PagingInfo;
import cn.hutool.core.collection.ListUtil;
......@@ -40,8 +39,6 @@ import java.util.stream.Collectors;
@Component
public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
private final Collator collator = Collator.getInstance(Locale.CHINA);
@Resource
private BizAgentApplicationInfoService bizAgentApplicationInfoService;
......@@ -209,6 +206,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
Assert.notEmpty(dto.getMessages());
try {
String agentId = dto.getAgentId();
String dialogueId = agentId;
BizAgentApplicationInfoEntity infoEntity = bizAgentApplicationInfoService.getByAgentId(agentId);
if (infoEntity == null) {
throw new I18nMessageException("exception/application.does.not.exist");
......@@ -255,9 +253,9 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
String agentSystem = StringUtils.isBlank(dto.getAgentSystem()) ? infoEntity.getAgentSystem() : dto.getAgentSystem();
//调用应用服务
agentApplicationInfoService.callAgentApplication(agentId, model, infoEntity.getUnitIds()
, agentSystem, kdIds.toArray(new Integer[0]), infoEntity.getCommunicationTurn(), topP, temperature
, dto.getMessages(), tools, httpServletResponse);
agentApplicationInfoService.callAgentApplication(agentId, dialogueId, model,
infoEntity.getUnitIds(), agentSystem, kdIds.toArray(new Integer[0]), infoEntity.getCommunicationTurn(), topP,
temperature, dto.getMessages(), tools, httpServletResponse);
} catch (
Exception e) {
httpServletResponse.setContentType("text/event-stream");
......@@ -347,11 +345,11 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
@Override
public List<AgentApplicationValueMemoryDto> getVariableList(String agentId) {
Map<Object, Object> map = GetValueMemory.get(agentId);
List<AgentApplicationValueMemoryDto> result = new ArrayList<>();
if (MapUtils.isEmpty(map)) {
BizAgentApplicationInfoEntity infoEntity = bizAgentApplicationInfoService.getByAgentId(agentId);
Map<Object, Object> map = GetValueMemory.get(agentId);
List<Variable> variableStructure = infoEntity.getVariableStructure();
if (MapUtils.isEmpty(map)) {
if (CollectionUtils.isEmpty(variableStructure)) {
return result;
}
......@@ -362,15 +360,14 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
result.add(valueMemoryDto);
}
} else {
Set<Object> keySet = map.keySet();
for (Object key : keySet) {
for (Variable variable : variableStructure) {
AgentApplicationValueMemoryDto valueMemoryDto = new AgentApplicationValueMemoryDto();
valueMemoryDto.setKey(key.toString());
valueMemoryDto.setValue(map.get(key).toString());
valueMemoryDto.setKey(variable.getKey());
valueMemoryDto.setValue(map.containsKey(variable.getKey()) ? map.get(variable.getKey()).toString() : variable.getVariableDefault());
result.add(valueMemoryDto);
}
}
return result.stream().sorted(Comparator.comparing(AgentApplicationValueMemoryDto::getKey, collator)).collect(Collectors.toList());
return result;
}
@Override
......
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