llm opt, 支持非markdown的关联

This commit is contained in:
Luke.Ye 2025-07-09 00:24:20 +08:00
parent 133dd724ba
commit 9a7e855d65

View File

@ -110,6 +110,7 @@ public class LLMAppServiceImpl implements LLMAppService {
log.info("[pinDocsByKeywords] 未查到匹配ES文档跳过pin操作。");
return Lists.newArrayList();
}
log.info("[pinDocsByKeywords] 已查询到关键词关联的文档。 {}", JSONUtil.toJsonStr(esFilepaths));
// 将当前问题标注为处理中
markQuestionProcessing(question);
@ -122,9 +123,23 @@ public class LLMAppServiceImpl implements LLMAppService {
}
// 3. 找到需要pin的docPath集合
List<WorkspaceAttachment> toPinDocs = attachments.stream()
.filter(att -> esFilepaths.stream().anyMatch(f -> att.getUrl().endsWith(f)))
.collect(Collectors.toList());
List<WorkspaceAttachment> toPinDocs = attachments.stream().filter(att -> {
String url = att.getUrl();
if (url == null) return false;
// .md 文件
if (url.endsWith(".md")) {
return esFilepaths.stream().anyMatch(f -> url.endsWith(f));
}
// 其它文件 .pptx.pdf.docx等
int lastSlash = url.lastIndexOf('/');
String fileName = lastSlash != -1 ? url.substring(lastSlash + 1) : url;
// esFilepaths 里也提取末尾文件名
return esFilepaths.stream().anyMatch(f -> {
int esLastSlash = f.lastIndexOf('/');
String esName = esLastSlash != -1 ? f.substring(esLastSlash + 1) : f;
return fileName.equals(esName);
});
}).collect(Collectors.toList());
// 4. 只unpin之前已pin的文档
attachments.stream()