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 dcf6a5d75..9aa01a646 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 @@ -1,11 +1,13 @@ package cn.iocoder.yudao.module.llm.service.http; +import cn.iocoder.yudao.framework.common.exception.ErrorCode; import cn.iocoder.yudao.framework.common.util.http.HttpUtils; import cn.iocoder.yudao.module.llm.framework.backend.config.LLMBackendProperties; import cn.iocoder.yudao.module.llm.service.http.vo.*; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.BeanUtils; import com.google.gson.JsonArray; import kong.unirest.HttpResponse; @@ -26,6 +28,9 @@ import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.llm.enums.ErrorCodeConstants.MODEL_COMPLETIONS_ERROR; + /** * rag相关接口 */ @@ -217,9 +222,16 @@ public class RagHttpService { .field("file_id", reqVO.getFileId()) .field("file", reqVO.getFileInputStream(), reqVO.getFileName()) .asString(); + String body = response.getBody(); + log.info("body : {}", body); - log.info(" ========= Response Body Result: {}", response.getBody()); - + JSONObject jsonObject = JSON.parseObject(body); + if (jsonObject.getBoolean("status")) { + log.info(" ========= Response Body Result: {}", response.getBody()); + throw exception(new ErrorCode(10047, " ------------ 知识库上传成功")); + } else { + throw exception(new ErrorCode(10047, " xxxxxxxxxxxx 知识库上传失败")); + } } }