refactor(module-llm):优化知识库创建文件方法
- 添加 @Async 注解实现异步处理 - 简化文件嵌入逻辑,暂时注释掉非 txt 文件的处理 -优化代码结构,提高可读性和性能
This commit is contained in:
parent
2f9b1c32ac
commit
c4d8b68d91
@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.llm.service.http.vo.KnowledgeRagEmbedReqVO;
|
||||
import cn.iocoder.yudao.module.llm.service.http.vo.RegUploadReqVO;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -37,6 +38,7 @@ public class AsyncKnowledgeBase {
|
||||
|
||||
|
||||
// 向向量知识库创建文件
|
||||
@Async
|
||||
public void createKnowledgeBase (List<KnowledgeDocumentsDO> knowledgeList, List<Long> ids) {
|
||||
if (!CollectionUtils.isAnyEmpty(ids)) {
|
||||
String mes = ragHttpService.ragDocumentsDel(llmBackendProperties.getRagDocumentsDel(), ids);
|
||||
@ -60,13 +62,13 @@ public class AsyncKnowledgeBase {
|
||||
|
||||
int lastIndex = knowledge.getDocumentName().lastIndexOf(".");
|
||||
if (lastIndex != -1) {
|
||||
|
||||
String extension = knowledge.getDocumentName().substring(lastIndex + 1).toLowerCase();
|
||||
if ("txt".equals(extension)) {
|
||||
ragHttpService.embedUploadFile(regUploadReqVO);
|
||||
} else {
|
||||
knowledgeEmbed(knowledge, knowledge.getKnowledgeBaseId());
|
||||
}
|
||||
ragHttpService.embedUploadFile(regUploadReqVO);
|
||||
// String extension = knowledge.getDocumentName().substring(lastIndex + 1).toLowerCase();
|
||||
// if ("txt".equals(extension)) {
|
||||
// ragHttpService.embedUploadFile(regUploadReqVO);
|
||||
// } else {
|
||||
// knowledgeEmbed(knowledge, knowledge.getKnowledgeBaseId());
|
||||
// }
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("the creation of the knowledge base error {}", e.getMessage());
|
||||
|
Loading…
x
Reference in New Issue
Block a user