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