♻️Refactor: 知识库规则集导入上下文
This commit is contained in:
@@ -21,7 +21,7 @@ public class MyMarkdownReader {
|
||||
this.docs = resolver.getResources("classpath:rag/*.md");
|
||||
}
|
||||
|
||||
List<Document> loadMarkdown() {
|
||||
public List<Document> loadMarkdown() {
|
||||
MarkdownDocumentReaderConfig config = MarkdownDocumentReaderConfig.builder()
|
||||
.withHorizontalRuleCreateDocument(true)
|
||||
.withIncludeCodeBlock(false)
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package com.wonder.bi.manager;
|
||||
|
||||
import com.wonder.bi.rag.MyMarkdownReader;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.ai.document.Document;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@SpringBootTest
|
||||
@@ -13,6 +17,9 @@ class InsightAgentManagerTest {
|
||||
@Resource
|
||||
private InsightAgentManager insightAgent;
|
||||
|
||||
@Resource
|
||||
private MyMarkdownReader reader;
|
||||
|
||||
@Test
|
||||
void getAnalysisInsight() {
|
||||
String insight = insightAgent.getAnalysisInsight("分析需求:\n" +
|
||||
@@ -25,4 +32,26 @@ class InsightAgentManagerTest {
|
||||
"定义增长 50% 及以上为快速增长");
|
||||
Assertions.assertNotNull(insight);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAnalysisInsightWithRag() {
|
||||
List<Document> documents = reader.loadMarkdown();
|
||||
StringBuilder ragText = new StringBuilder();
|
||||
for (Document document: documents) {
|
||||
ragText.append(document.toString());
|
||||
}
|
||||
String insight = insightAgent.getAnalysisInsight("分析需求:\n" +
|
||||
"分析班级成绩分布\n" +
|
||||
"原始数据:\n" +
|
||||
"序号,分数\n" +
|
||||
"1号,90\n" +
|
||||
"2号,90\n" +
|
||||
"3号,80\n" +
|
||||
"4号,20\n" +
|
||||
"5号,40\n" +
|
||||
"6号,89\n" +
|
||||
"7号,59\n",
|
||||
ragText.toString());
|
||||
Assertions.assertNotNull(insight);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user