Skip to content

Commit 3db3b1f

Browse files
authored
Fix HypotheticalQuestionGraphIngestor wrong constructor (#219)
1 parent 0c61d79 commit 3db3b1f

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

content-retrievers/langchain4j-community-neo4j-retriever/src/test/java/dev/langchain4j/community/rag/content/retriever/neo4j/Neo4jEmbeddingStoreIngestorTest.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public void testHypotheticalQuestionIngestor() {
265265

266266
when(chatLanguageModel.chat(anyList()))
267267
.thenReturn(ChatResponse.builder()
268-
.aiMessage(AiMessage.aiMessage("What is the Machine learning?"))
268+
.aiMessage(AiMessage.aiMessage("Who is John Doe?"))
269269
.build());
270270

271271
hypotheticalQuestionIngestorCommon(chatLanguageModel);
@@ -334,10 +334,8 @@ protected static void summaryGraphIngestorCommon(ChatModel chatModel) {
334334

335335
protected static void hypotheticalQuestionIngestorCommon(ChatModel chatModel) {
336336

337-
int maxSegmentSize = 250;
338-
339337
// Splits into sentences using OpenNLP
340-
DocumentSplitter splitter = new DocumentBySentenceSplitter(maxSegmentSize, 0);
338+
DocumentSplitter splitter = new DocumentBySentenceSplitter(100, 0);
341339

342340
// Ingest the document into Neo4j as chunk-question nodes
343341
Neo4jEmbeddingStoreIngestor ingestor = HypotheticalQuestionGraphIngestor.builder()
@@ -348,17 +346,17 @@ protected static void hypotheticalQuestionIngestorCommon(ChatModel chatModel) {
348346
.embeddingStore(embeddingStore)
349347
.build();
350348

351-
Document document = getDocumentAI();
349+
Document document = getDocumentMiscTopics();
352350
ingestor.ingest(document);
353351

354352
final EmbeddingStoreContentRetriever retriever = getEmbeddingStoreContentRetriever(ingestor);
355-
List<Content> results = retriever.retrieve(Query.from("Tell me about machine learning"));
353+
List<Content> results = retriever.retrieve(Query.from("Who is John Doe?"));
356354

357355
assertFalse(results.isEmpty(), "Should retrieve at least one parent document");
358356

359357
Content result = results.get(0);
360358

361-
assertThat(result.textSegment().text().toLowerCase()).containsIgnoringWhitespaces("machine learning");
359+
assertThat(result.textSegment().text().toLowerCase()).containsIgnoringWhitespaces("super saiyan");
362360
assertEquals("Wikipedia link", result.textSegment().metadata().getString("source"));
363361
assertEquals("https://example.com/ai", result.textSegment().metadata().getString("url"));
364362
}

embedding-stores/langchain4j-community-neo4j/src/main/java/dev/langchain4j/community/store/embedding/neo4j/HypotheticalQuestionGraphIngestor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public HypotheticalQuestionGraphIngestor(final Builder builder) {
2323
super(builder);
2424
}
2525

26-
public static SummaryGraphIngestor.Builder builder() {
27-
return new SummaryGraphIngestor.Builder();
26+
public static HypotheticalQuestionGraphIngestor.Builder builder() {
27+
return new HypotheticalQuestionGraphIngestor.Builder();
2828
}
2929

3030
public static class Builder extends Neo4jEmbeddingStoreIngestor.Builder {

0 commit comments

Comments
 (0)