From cee050c56a0776ec8732899250e9ca3d933598f7 Mon Sep 17 00:00:00 2001 From: Liuyang <2746366019@qq.com> Date: Thu, 13 Feb 2025 17:17:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(llm):=20=E4=BF=AE=E5=A4=8D=E7=9F=A5?= =?UTF-8?q?=E8=AF=86=E5=BA=93=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E6=88=90?= =?UTF-8?q?=E5=8A=9F=E5=90=8E=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复了文件上传成功后,解析响应数据时可能出现的空指针异常 - 优化了错误处理逻辑,当响应中不包含 "status" 字段时,直接抛出异常 - 移除了 handleFailure 方法中冗余的异常信息 --- .../yudao/module/llm/service/http/RagHttpService.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/http/RagHttpService.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/http/RagHttpService.java index 53f15d500..c4f9592b5 100644 --- a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/http/RagHttpService.java +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/http/RagHttpService.java @@ -337,9 +337,10 @@ public class RagHttpService { log.info("解析后的JSON响应: {}", parseObject); // 如果状态为true,则更新文件状态为上传成功,否则更新为上传失败 - if (parseObject.getBooleanValue("status")) { + if (parseObject.containsKey("status") && parseObject.getBoolean("status")) { + // 修改状态为 上传成功 updateFileState(documents, KnowledgeStatusEnum.UPLOAD_SUCCESS); - } else { + } else { String errorMsg = parseObject.getString("error"); updateFileState(documents, KnowledgeStatusEnum.UPLOAD_FAILED); throw exception(new ErrorCode(10047, errorMsg)); @@ -356,7 +357,7 @@ public class RagHttpService { private void handleFailure (KnowledgeDocumentsDO documents, String errorMsg, Exception e) { updateFileState(documents, KnowledgeStatusEnum.UPLOAD_FAILED); log.error("handleFailure {}: {}", errorMsg, e.getMessage()); - throw new RuntimeException(errorMsg, e); + throw new RuntimeException(errorMsg); } /**