Commit 20f7ab64 authored by alex yao's avatar alex yao

feat: handle large model session parameter exceptions

parent ed056161
......@@ -86,7 +86,6 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
throw new BusinessException("用户未登录");
}
Long userRecordId = null;
try {
BizAgentApplicationPublishEntity infoEntity = bizAgentApplicationPublishService.getByAgentId(agentId);
if (infoEntity == null) {
......@@ -118,8 +117,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
inputRecord.setDialogsId(dialogsId);
inputRecord.setRole(AgentApplicationDialoguesRecordConstants.ROLE.USER);
inputRecord.setTimestamp(inputTimestamp);
BizAgentApplicationDialoguesRecordEntity saveRecord = bizAgentApplicationDialoguesRecordService.save(inputRecord);
userRecordId = saveRecord.getId();
bizAgentApplicationDialoguesRecordService.save(inputRecord);
// 记录输出时间戳
......@@ -139,9 +137,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
outputRecord.setContent(output);
bizAgentApplicationDialoguesRecordService.save(outputRecord);
} catch (Exception e) {
if (userRecordId != null) {
bizAgentApplicationDialoguesRecordService.deletedById(userRecordId);
}
throw new BusinessException(e.getMessage());
}
}
......@@ -266,6 +262,15 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
messages.add(message);
}
}
//判断最后是否为User,若是则删除。
if (LLMRoleEnum.USER.getRole().equals(messages.get(messages.size() - 1).getRole())) {
Long recordId = recordEntities.get(recordEntities.size() - 1).getId();
bizAgentApplicationDialoguesRecordService.deletedById(recordId);
messages.remove(messages.size() - 1);
}
// 用户输入
Message message = new Message();
message.setContent(input);
message.setRole(LLMRoleEnum.USER.getRole());
......
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