mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-09-18 19:11:55 +08:00
【代码优化】AI:向量化的集成
This commit is contained in:
@@ -7,7 +7,6 @@ package cn.iocoder.yudao.module.ai.service.knowledge;
|
||||
*/
|
||||
public interface DocService {
|
||||
|
||||
|
||||
/**
|
||||
* 向量化文档
|
||||
*/
|
||||
|
@@ -21,24 +21,23 @@ import java.util.List;
|
||||
public class DocServiceImpl implements DocService {
|
||||
|
||||
@Resource
|
||||
RedisVectorStore vectorStore;
|
||||
private RedisVectorStore vectorStore;
|
||||
@Resource
|
||||
TokenTextSplitter tokenTextSplitter;
|
||||
private TokenTextSplitter tokenTextSplitter;
|
||||
|
||||
// TODO @xin 临时测试用,后续删
|
||||
@Value("classpath:/webapp/test/Fel.pdf")
|
||||
private org.springframework.core.io.Resource data;
|
||||
|
||||
|
||||
@Override
|
||||
public void embeddingDoc() {
|
||||
// 读取文件
|
||||
org.springframework.core.io.Resource file = data;
|
||||
TikaDocumentReader loader = new TikaDocumentReader(file);
|
||||
TikaDocumentReader loader = new TikaDocumentReader(data);
|
||||
List<Document> documents = loader.get();
|
||||
// 文档分段
|
||||
List<Document> segments = tokenTextSplitter.apply(documents);
|
||||
// 向量化并存储
|
||||
vectorStore.add(segments);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user