Skip to content

Commit 5b11501

Browse files
committed
Update usage of Document::getContent to getText
1 parent f252b24 commit 5b11501

File tree

8 files changed

+12
-13
lines changed

8 files changed

+12
-13
lines changed

document-readers/markdown-reader/src/test/java/org/springframework/ai/reader/markdown/MarkdownDocumentReaderTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void testOnlyHeadersWithParagraphs() {
3939
List<Document> documents = reader.get();
4040

4141
assertThat(documents).hasSize(4)
42-
.extracting(Document::getMetadata, Document::getContent)
42+
.extracting(Document::getMetadata, Document::getText)
4343
.containsOnly(tuple(Map.of("category", "header_1", "title", "Header 1a"),
4444
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur diam eros, laoreet sit amet cursus vitae, varius sed nisi. Cras sit amet quam quis velit commodo porta consectetur id nisi. Phasellus tincidunt pulvinar augue."),
4545
tuple(Map.of("category", "header_1", "title", "Header 1b"),
@@ -57,7 +57,7 @@ void testWithFormatting() {
5757
List<Document> documents = reader.get();
5858

5959
assertThat(documents).hasSize(2)
60-
.extracting(Document::getMetadata, Document::getContent)
60+
.extracting(Document::getMetadata, Document::getText)
6161
.containsOnly(tuple(Map.of("category", "header_1", "title", "This is a fancy header name"),
6262
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tincidunt velit non bibendum gravida. Cras accumsan tincidunt ornare. Donec hendrerit consequat tellus blandit accumsan. Aenean aliquam metus at arcu elementum dignissim."),
6363
tuple(Map.of("category", "header_3", "title", "Header 3"),
@@ -75,7 +75,7 @@ void testDocumentDividedViaHorizontalRules() {
7575
List<Document> documents = reader.get();
7676

7777
assertThat(documents).hasSize(7)
78-
.extracting(Document::getMetadata, Document::getContent)
78+
.extracting(Document::getMetadata, Document::getText)
7979
.containsOnly(tuple(Map.of(),
8080
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tincidunt velit non bibendum gravida."),
8181
tuple(Map.of(),
@@ -187,7 +187,7 @@ void testBlockquote() {
187187
List<Document> documents = reader.get();
188188

189189
assertThat(documents).hasSize(2)
190-
.extracting(Document::getMetadata, Document::getContent)
190+
.extracting(Document::getMetadata, Document::getText)
191191
.containsOnly(tuple(Map.of(),
192192
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur diam eros, laoreet sit amet cursus vitae, varius sed nisi. Cras sit amet quam quis velit commodo porta consectetur id nisi. Phasellus tincidunt pulvinar augue."),
193193
tuple(Map.of("category", "blockquote"),
@@ -219,7 +219,7 @@ void testLists() {
219219
List<Document> documents = reader.get();
220220

221221
assertThat(documents).hasSize(2)
222-
.extracting(Document::getMetadata, Document::getContent)
222+
.extracting(Document::getMetadata, Document::getText)
223223
.containsOnly(tuple(Map.of("category", "header_2", "title", "Ordered list"),
224224
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur diam eros, laoreet sit amet cursus vitae, varius sed nisi. Cras sit amet quam quis velit commodo porta consectetur id nisi. Phasellus tincidunt pulvinar augue. Proin vel laoreet leo, sed luctus augue. Sed et ligula commodo, commodo lacus at, consequat turpis. Maecenas eget sapien odio. Pellentesque auctor pharetra eros, viverra sodales lorem aliquet id. Curabitur semper nisi vel sem interdum suscipit. Maecenas urna lectus, pellentesque in accumsan aliquam, congue eu libero. Ut rhoncus nec justo a porttitor."),
225225
tuple(Map.of("category", "header_2", "title", "Unordered list"),

document-readers/pdf-reader/src/test/java/org/springframework/ai/reader/pdf/PagePdfDocumentReaderTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void classpathRead() {
5252

5353
assertThat(docs).hasSize(4);
5454

55-
String allText = docs.stream().map(Document::getContent).collect(Collectors.joining(System.lineSeparator()));
55+
String allText = docs.stream().map(Document::getText).collect(Collectors.joining(System.lineSeparator()));
5656

5757
assertThat(allText).doesNotContain(
5858
List.of("Page 1 of 4", "Page 2 of 4", "Page 3 of 4", "Page 4 of 4", "PDF Bookmark Sample"));

spring-ai-core/src/main/java/org/springframework/ai/chat/client/advisor/QuestionAnswerAdvisor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.springframework.ai.chat.model.ChatResponse;
3636
import org.springframework.ai.chat.prompt.PromptTemplate;
3737
import org.springframework.ai.document.Document;
38-
import org.springframework.ai.model.Content;
3938
import org.springframework.ai.vectorstore.SearchRequest;
4039
import org.springframework.ai.vectorstore.VectorStore;
4140
import org.springframework.ai.vectorstore.filter.Filter;

spring-ai-core/src/main/java/org/springframework/ai/embedding/EmbeddingModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ default List<float[]> embed(List<Document> documents, EmbeddingOptions options,
8686
List<float[]> embeddings = new ArrayList<>(documents.size());
8787
List<List<Document>> batch = batchingStrategy.batch(documents);
8888
for (List<Document> subBatch : batch) {
89-
List<String> texts = subBatch.stream().map(Document::getContent).toList();
89+
List<String> texts = subBatch.stream().map(Document::getText).toList();
9090
EmbeddingRequest request = new EmbeddingRequest(texts, options);
9191
EmbeddingResponse response = this.call(request);
9292
for (int i = 0; i < subBatch.size(); i++) {

spring-ai-core/src/main/java/org/springframework/ai/vectorstore/observation/VectorStoreObservationContentProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static List<String> documents(VectorStoreObservationContext context) {
3636
return List.of();
3737
}
3838

39-
return context.getQueryResponse().stream().map(Document::getContent).toList();
39+
return context.getQueryResponse().stream().map(Document::getText).toList();
4040
}
4141

4242
}

spring-ai-core/src/test/java/org/springframework/ai/rag/retrieval/join/ConcatenationDocumentJoinerTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ void whenDuplicatedDocumentsThenOnlyFirstOccurrenceIsKept() {
8989

9090
assertThat(result).hasSize(4);
9191
assertThat(result).extracting(Document::getId).containsExactlyInAnyOrder("1", "2", "3", "4");
92-
assertThat(result).extracting(Document::getContent).contains("Content 2");
93-
assertThat(result).extracting(Document::getContent).doesNotContain("Content 2 Duplicate");
92+
assertThat(result).extracting(Document::getText).contains("Content 2");
93+
assertThat(result).extracting(Document::getText).doesNotContain("Content 2 Duplicate");
9494
}
9595

9696
}

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/vectordbs/hana.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ public class CricketWorldCupHanaController {
298298
@GetMapping("/ai/hana-vector-store/cricket-world-cup")
299299
public Map<String, String> hanaVectorStoreSearch(@RequestParam(value = "message") String message) {
300300
var documents = this.hanaCloudVectorStore.similaritySearch(message);
301-
var inlined = documents.stream().map(Document::getContent).collect(Collectors.joining(System.lineSeparator()));
301+
var inlined = documents.stream().map(Document::getText).collect(Collectors.joining(System.lineSeparator()));
302302
var similarDocsMessage = new SystemPromptTemplate("Based on the following: {documents}")
303303
.createMessage(Map.of("documents", inlined));
304304

vector-stores/spring-ai-hanadb-store/src/test/java/org/springframework/ai/vectorstore/CricketWorldCupHanaController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public ResponseEntity<String> handleFileUpload(@RequestParam("pdf") MultipartFil
8484
@GetMapping("/ai/hana-vector-store/cricket-world-cup")
8585
public Map<String, String> hanaVectorStoreSearch(@RequestParam("message") String message) {
8686
var documents = this.hanaCloudVectorStore.similaritySearch(message);
87-
var inlined = documents.stream().map(Document::getContent).collect(Collectors.joining(System.lineSeparator()));
87+
var inlined = documents.stream().map(Document::getText).collect(Collectors.joining(System.lineSeparator()));
8888
var similarDocsMessage = new SystemPromptTemplate("Based on the following: {documents}")
8989
.createMessage(Map.of("documents", inlined));
9090

0 commit comments

Comments
 (0)