Commit 446d8046 authored by alex yao's avatar alex yao

fix:NPE

parent 0d69cf0a
...@@ -13,6 +13,7 @@ import cn.com.poc.common.constant.CommonConstant; ...@@ -13,6 +13,7 @@ import cn.com.poc.common.constant.CommonConstant;
import cn.com.poc.common.utils.Assert; import cn.com.poc.common.utils.Assert;
import cn.com.poc.common.utils.BlContext; import cn.com.poc.common.utils.BlContext;
import cn.com.poc.common.utils.JsonUtils; import cn.com.poc.common.utils.JsonUtils;
import cn.com.poc.knowledge.constant.KnowledgeConstant;
import cn.com.poc.knowledge.entity.BizKnowledgeDocumentEntity; import cn.com.poc.knowledge.entity.BizKnowledgeDocumentEntity;
import cn.com.poc.knowledge.service.BizKnowledgeDocumentService; import cn.com.poc.knowledge.service.BizKnowledgeDocumentService;
import cn.com.poc.support.security.oauth.entity.UserBaseEntity; import cn.com.poc.support.security.oauth.entity.UserBaseEntity;
...@@ -582,7 +583,8 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ ...@@ -582,7 +583,8 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
List<String> knowledgeIds = new ArrayList<>(); List<String> knowledgeIds = new ArrayList<>();
for (Integer kdId : kdIds) { for (Integer kdId : kdIds) {
BizKnowledgeDocumentEntity knowledgeDocumentEntity = bizKnowledgeDocumentService.get(kdId); BizKnowledgeDocumentEntity knowledgeDocumentEntity = bizKnowledgeDocumentService.get(kdId);
if (null == knowledgeDocumentEntity) { // 筛选训练完成的文档,否则跳过该文档
if (null == knowledgeDocumentEntity && KnowledgeConstant.TrainStatus.COMPLETE.equals(knowledgeDocumentEntity.getTrainStatus())) {
continue; continue;
} }
knowledgeIds.add(knowledgeDocumentEntity.getKnowledgeId()); knowledgeIds.add(knowledgeDocumentEntity.getKnowledgeId());
...@@ -743,7 +745,8 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ ...@@ -743,7 +745,8 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
if (StringUtils.isBlank(res)) { if (StringUtils.isBlank(res)) {
continue; continue;
} }
LargeModelDemandResult result = JsonUtils.deSerialize(res.replaceFirst(EVENT_STREAM_PREFIX, StringUtils.EMPTY), LargeModelDemandResult.class); res = StringUtils.replace(res, EVENT_STREAM_PREFIX, StringUtils.EMPTY);
LargeModelDemandResult result = JsonUtils.deSerialize(res, LargeModelDemandResult.class);
if (!"0".equals(result.getCode())) { if (!"0".equals(result.getCode())) {
logger.error("LLM Error,code:{}", result.getCode()); logger.error("LLM Error,code:{}", result.getCode());
I18nMessageException ex = new I18nMessageException("exception/call.failure"); I18nMessageException ex = new I18nMessageException("exception/call.failure");
...@@ -754,13 +757,13 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ ...@@ -754,13 +757,13 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
if (StringUtils.isNotBlank(result.getMessage())) { if (StringUtils.isNotBlank(result.getMessage())) {
output.append(result.getMessage()); output.append(result.getMessage());
} }
writer.write(res + "\n\n"); writer.write(EVENT_STREAM_PREFIX + res + "\n\n");
writer.flush(); writer.flush();
} }
writer.write(EVENT_STREAM_PREFIX + "[DONE]\n\n");
// 关闭资源 // 关闭资源
bufferedReader.close(); writer.write(EVENT_STREAM_PREFIX + "[DONE]\n\n");
writer.close(); writer.close();
bufferedReader.close();
return output.toString(); return output.toString();
} }
......
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