refactor(module-llm):调整文件处理逻辑
- 恢复了对 .doc 文件的处理逻辑,将其转换为 .docx - 注释掉了对 .md 文件的处理逻辑- 优化了代码格式和缩进
This commit is contained in:
parent
6e19d81a72
commit
3fecb7e378
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理响应结果
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user