fix(llm): 修复向量库返回结果解析异常
- 在解析向量库返回结果时增加异常捕获处理 - 当解析 JSON 格式出错时,记录错误日志并抛出 RuntimeException - 优化了错误处理逻辑
This commit is contained in:
parent
671766700e
commit
764c9455f2
@ -310,18 +310,24 @@ public class RagHttpService {
|
||||
// 检查响应状态
|
||||
String responseBody = response.getBody();
|
||||
log.info(" ========= String Response Body Result: {}", responseBody);
|
||||
JSONObject parseObject = JSON.parseObject(responseBody);
|
||||
log.info(" ========= JSON Response Body Result: {}", responseBody);
|
||||
try {
|
||||
JSONObject parseObject = JSON.parseObject(responseBody);
|
||||
log.info(" ========= JSON Response Body Result: {}", responseBody);
|
||||
|
||||
if (parseObject.containsKey("status") && parseObject.getBoolean("status")) {
|
||||
// 修改状态为 上传成功
|
||||
updateFileState(documents, KnowledgeStatusEnum.UPLOAD_SUCCESS);
|
||||
} else {
|
||||
// 修改状态为 上传失败
|
||||
updateFileState(documents, KnowledgeStatusEnum.UPLOAD_FAILED);
|
||||
throw exception(new ErrorCode(10047, responseBody));
|
||||
if (parseObject.containsKey("status") && parseObject.getBoolean("status")) {
|
||||
// 修改状态为 上传成功
|
||||
updateFileState(documents, KnowledgeStatusEnum.UPLOAD_SUCCESS);
|
||||
} else {
|
||||
// 修改状态为 上传失败
|
||||
updateFileState(documents, KnowledgeStatusEnum.UPLOAD_FAILED);
|
||||
throw exception(new ErrorCode(10047, responseBody));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("返回结果 解析为 JSON格式错误: {}", e.getMessage());
|
||||
throw new RuntimeException("返回结果 解析为 JSON格式错误: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
|
||||
} catch (UnirestException e) {
|
||||
if (isSocketClosedException(e)) {
|
||||
log.warn("knowledgeEmbed Socket 连接已关闭,尝试重新上传...");
|
||||
|
Loading…
x
Reference in New Issue
Block a user