20250407 rag知识库地址在applicaiton中配置
This commit is contained in:
parent
88a9f4684e
commit
228fb4a94e
@ -31,13 +31,16 @@ public class AssistantInit {
|
||||
@Value("${langchain4j.model}")
|
||||
private String model;
|
||||
|
||||
@Value("${rag.path}")
|
||||
private String ragPath;
|
||||
|
||||
@Bean
|
||||
public Assist init() {
|
||||
ChatLanguageModel qwenModel = QwenChatModel.builder()
|
||||
.apiKey(apiKey)
|
||||
.modelName(model)
|
||||
.build();
|
||||
List<Document> documents = FileSystemDocumentLoader.loadDocuments("E:\\ideaProject\\liang-ai");
|
||||
List<Document> documents = FileSystemDocumentLoader.loadDocuments(ragPath);
|
||||
// for simplicity, we will use an in-memory one:
|
||||
InMemoryEmbeddingStore<TextSegment> embeddingStore = new InMemoryEmbeddingStore<>();
|
||||
EmbeddingStoreIngestor.ingest(documents, embeddingStore);
|
||||
|
@ -31,6 +31,9 @@ public class SegmentConfig {
|
||||
@Value("${langchain4j.model}")
|
||||
private String model;
|
||||
|
||||
@Value("${rag.path}")
|
||||
private String ragPath;
|
||||
|
||||
@Bean
|
||||
public SegmentAssist segmentAssist() {
|
||||
ChatLanguageModel qwenModel = QwenChatModel.builder()
|
||||
@ -39,7 +42,7 @@ public class SegmentConfig {
|
||||
.build();
|
||||
QwenEmbeddingModel embeddingModel = QwenEmbeddingModel.builder().apiKey(apiKey).build();
|
||||
InMemoryEmbeddingStore<TextSegment> embeddingStore = new InMemoryEmbeddingStore<>();
|
||||
List<Document> documents = FileSystemDocumentLoader.loadDocuments("E:\\ideaProject\\liang-ai\\rag");
|
||||
List<Document> documents = FileSystemDocumentLoader.loadDocuments(ragPath);
|
||||
for (Document document : documents) {
|
||||
DocumentByLineSplitter splitter = new DocumentByLineSplitter(300,30);
|
||||
List<TextSegment> segments = splitter.split(document);
|
||||
|
@ -2,7 +2,7 @@
|
||||
GET http://localhost:8080/langchain/chat?input=今天天气如何
|
||||
|
||||
### 测试 LangChainController 的 highlevel chat 接口
|
||||
GET http://localhost:8080/langchain/high/chat?input=请推荐3件DWALK商城的商品
|
||||
GET http://localhost:8080/langchain/high/chat?input=梁靖林的个人博客地址是什么
|
||||
|
||||
### 测试 LangChainController 的 highlevel memory chat 接口
|
||||
GET http://localhost:8080/langchain/high/memory-chat?memoryId=1&input=你好,我想要买电脑笔记本
|
||||
|
@ -22,10 +22,13 @@ public class EmbeddingService {
|
||||
@Value("${langchain4j.api-key}")
|
||||
private String apiKey;
|
||||
|
||||
@Value("${rag.path}")
|
||||
private String ragPath;
|
||||
|
||||
public void embedding(String input) {
|
||||
QwenEmbeddingModel embeddingModel = QwenEmbeddingModel.builder().apiKey(apiKey).build();
|
||||
InMemoryEmbeddingStore<TextSegment> embeddingStore = new InMemoryEmbeddingStore<>();
|
||||
List<Document> documents = FileSystemDocumentLoader.loadDocuments("E:\\ideaProject\\liang-ai\\rag");
|
||||
List<Document> documents = FileSystemDocumentLoader.loadDocuments(ragPath);
|
||||
for (Document document : documents) {
|
||||
DocumentByLineSplitter splitter = new DocumentByLineSplitter(200,30);
|
||||
List<TextSegment> segments = splitter.split(document);
|
||||
|
@ -5,4 +5,6 @@ langchain4j.community.dashscope.chat-model.model-name=deepseek-v3
|
||||
|
||||
|
||||
langchain4j.api-key=sk-2f703a41fff0488e9b6888013d2ee58a
|
||||
langchain4j.model=deepseek-v3
|
||||
langchain4j.model=deepseek-v3
|
||||
|
||||
rag.path=D:/IdeaProjects/liang-ai/rag
|
Loading…
Reference in New Issue
Block a user