20250329 简单的个人rag知识库构建
This commit is contained in:
parent
1aabf305a4
commit
7e1e31e0bd
5
pom.xml
5
pom.xml
@ -36,6 +36,11 @@
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dev.langchain4j</groupId>
|
||||
<artifactId>langchain4j-easy-rag</artifactId>
|
||||
<version>1.0.0-beta1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.langchain4j</groupId>
|
||||
|
@ -2,26 +2,40 @@ package com.ai.config;
|
||||
|
||||
import com.ai.service.Assist;
|
||||
import dev.langchain4j.community.model.dashscope.QwenChatModel;
|
||||
import dev.langchain4j.data.document.Document;
|
||||
import dev.langchain4j.data.document.loader.FileSystemDocumentLoader;
|
||||
import dev.langchain4j.data.segment.TextSegment;
|
||||
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
|
||||
import dev.langchain4j.model.chat.ChatLanguageModel;
|
||||
import dev.langchain4j.rag.content.retriever.EmbeddingStoreContentRetriever;
|
||||
import dev.langchain4j.service.AiServices;
|
||||
import dev.langchain4j.store.embedding.EmbeddingStoreIngestor;
|
||||
import dev.langchain4j.store.embedding.inmemory.InMemoryEmbeddingStore;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
@RequiredArgsConstructor
|
||||
public class AssistantInit {
|
||||
|
||||
ChatLanguageModel qwenModel = QwenChatModel.builder()
|
||||
.apiKey("sk-2f703a41fff0488e9b6888013d2ee58a")
|
||||
.modelName("deepseek-v3")
|
||||
.build();
|
||||
// All files in a directory, txt seems to be faster
|
||||
|
||||
@Bean
|
||||
public Assist init() {
|
||||
ChatLanguageModel qwenModel = QwenChatModel.builder()
|
||||
.apiKey("sk-2f703a41fff0488e9b6888013d2ee58a")
|
||||
.modelName("deepseek-v3")
|
||||
.build();
|
||||
List<Document> documents = FileSystemDocumentLoader.loadDocuments("E:\\ideaProject\\liang-ai");
|
||||
// for simplicity, we will use an in-memory one:
|
||||
InMemoryEmbeddingStore<TextSegment> embeddingStore = new InMemoryEmbeddingStore<>();
|
||||
EmbeddingStoreIngestor.ingest(documents, embeddingStore);
|
||||
return AiServices.builder(Assist.class)
|
||||
.chatMemoryProvider(memoryId -> MessageWindowChatMemory.withMaxMessages(10))
|
||||
.chatLanguageModel(qwenModel).build();
|
||||
.chatLanguageModel(qwenModel)
|
||||
.contentRetriever(EmbeddingStoreContentRetriever.from(embeddingStore)).build();
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
GET http://localhost:8080/langchain/chat?input=今天天气如何
|
||||
|
||||
### 测试 LangChainController 的 highlevel chat 接口
|
||||
GET http://localhost:8080/langchain/high/chat?input=评价一下路飞
|
||||
GET http://localhost:8080/langchain/high/chat?input=请推荐3件DWALK商城的商品
|
||||
|
||||
### 测试 LangChainController 的 highlevel memory chat 接口
|
||||
GET http://localhost:8080/langchain/high/memory-chat?memoryId=1&input=你好,我想要买电脑笔记本
|
||||
|
18
个人知识库
Normal file
18
个人知识库
Normal file
@ -0,0 +1,18 @@
|
||||
梁靖林个人博客halo
|
||||
地址:halo.liangjl.top
|
||||
账号:liangjinglin
|
||||
密码: 353912918a
|
||||
|
||||
DWALK商城 商品推荐优先级规则
|
||||
1.根据本月销量推荐,销量越高,优先级越高,考量占比50%
|
||||
2.根据评分,评分越高,优先级越高 考量占比50%
|
||||
3.根据评论数,评论数越多,优先级越高 考量占比10%
|
||||
4.根据收藏数,收藏数越多,优先级越高 考量占比5%
|
||||
|
||||
DWALK商城商品情况
|
||||
1.茅台 销量:100 评分:4 评论数:100 收藏数:100
|
||||
2.meta50 销量:200 评分:5 评论数:500 收藏数:5000
|
||||
3.机械革命 销量:50 评分:4.5 评论数:80 收藏数:100
|
||||
4.潮汕牛肉丸 销量:150 评分:3 评论数:100 收藏数:20
|
||||
5.风筒 销量:80 评分:3.5 评论数:50 收藏数:10
|
||||
6.口红 销量:30 评分:4.5 评论数:200 收藏数:200
|
Loading…
Reference in New Issue
Block a user