| | |
| | | package com.ruoyi.ai.config; |
| | | |
| | | import com.ruoyi.ai.store.MongoChatMemoryStore; |
| | | import dev.langchain4j.data.document.Document; |
| | | import dev.langchain4j.data.document.loader.FileSystemDocumentLoader; |
| | | import dev.langchain4j.data.segment.TextSegment; |
| | | import dev.langchain4j.memory.chat.ChatMemoryProvider; |
| | | import dev.langchain4j.memory.chat.MessageWindowChatMemory; |
| | | import dev.langchain4j.model.embedding.EmbeddingModel; |
| | | import dev.langchain4j.rag.content.retriever.ContentRetriever; |
| | | import dev.langchain4j.rag.content.retriever.EmbeddingStoreContentRetriever; |
| | | import dev.langchain4j.store.embedding.EmbeddingStore; |
| | | import dev.langchain4j.store.embedding.EmbeddingStoreIngestor; |
| | | import dev.langchain4j.store.embedding.inmemory.InMemoryEmbeddingStore; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author :yys |
| | |
| | | @Autowired |
| | | private EmbeddingModel embeddingModel; |
| | | |
| | | // @Value("${knowledge.one}") |
| | | // private String one; |
| | | @Value("${knowledge.one}") |
| | | private String one; |
| | | // |
| | | // @Value("${knowledge.two}") |
| | | // private String two; |
| | |
| | | // ContentRetriever contentRetrieverXiaozhi() { |
| | | // //使用FileSystemDocumentLoader读取指定目录下的知识库文档 |
| | | // //并使用默认的文档解析器对文档进行解析 |
| | | //// Document document1 = FileSystemDocumentLoader.loadDocument(one); |
| | | // Document document1 = FileSystemDocumentLoader.loadDocument(one); |
| | | //// Document document2 = FileSystemDocumentLoader.loadDocument(two); |
| | | //// Document document3 = FileSystemDocumentLoader.loadDocument(three); |
| | | //// List<Document> documents = Arrays.asList(document1, document2, document3); |
| | | // |
| | | //// List<Document> documents = Collections.singletonList(document1); |
| | | // List<Document> documents = Collections.singletonList(document1); |
| | | //// 2. 将数据库数据转为LangChain4j的Document对象 |
| | | //// List<Document> documents = new ArrayList<>(); |
| | | // |