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 394be88a5..aa0998ef9 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 @@ -415,24 +415,24 @@ public class RagHttpService { Path tempFilePath = downloadFileToTemp(fileUrl, fileName); log.info("文件已下载到临时目录: {}", tempFilePath); -// String fileSuffix = getFileSuffix(fileName); -// if ("doc".equals(fileSuffix)) { -// log.info("正在处理 doc 文件"); -// try { -// tempFilePath= converterDocToDocx(tempFilePath.toString(), tempFilePath.toString().replace(".doc", ".docx")); -// } catch (Exception e) { -// throw new RuntimeException(e); -// } -// } + String fileSuffix = getFileSuffix(fileName); + if ("doc".equals(fileSuffix)) { + log.info("正在处理 doc 文件"); + try { + tempFilePath = converterDocToDocx(tempFilePath.toString(), tempFilePath.toString().replace(".doc", ".docx")); + } catch (Exception e) { + throw new RuntimeException(e); + } + } -// if ("md".equals(fileSuffix)) { -// log.info("正在处理 md 文件"); -// try { -// tempFilePath= converterMdToTxt(tempFilePath.toString(), tempFilePath.toString().replace(".md", ".txt")); -// } catch (Exception e) { -// throw new RuntimeException(e); -// } -// } + // if ("md".equals(fileSuffix)) { + // log.info("正在处理 md 文件"); + // try { + // tempFilePath= converterMdToTxt(tempFilePath.toString(), tempFilePath.toString().replace(".md", ".txt")); + // } catch (Exception e) { + // throw new RuntimeException(e); + // } + // } // 创建 OkHttpClient 实例 log.info("创建 OkHttpClient 实例,设置超时时间为 3 分钟"); @@ -626,7 +626,7 @@ public class RagHttpService { return path; } - public static Path converterDocToDocx(String inputPath, String outputPath) throws Exception { + public static Path converterDocToDocx (String inputPath, String outputPath) throws Exception { // 读取DOC文档 try (HWPFDocument doc = new HWPFDocument(Files.newInputStream(Paths.get(inputPath)))) { XWPFDocument docx = new XWPFDocument(); @@ -650,6 +650,7 @@ public class RagHttpService { return Paths.get(outputPath); } } + /** * 处理响应结果 */