Package com.google.genkit.ai
Class Document
java.lang.Object
com.google.genkit.ai.Document
Document represents a document for use with embedders and retrievers.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DocumentCreates a text Document.static DocumentCreates a Document with text and metadata.voidsetContent(List<Part> content) voidsetMetadata(Map<String, Object> metadata) text()Gets the text content of this Document.withMetadata(String key, Object value) Adds metadata to this Document.
-
Constructor Details
-
Document
public Document()Default constructor. -
Document
Creates a Document with text content.- Parameters:
text- the text content
-
Document
Creates a Document with parts.- Parameters:
content- the content parts
-
-
Method Details
-
fromText
Creates a text Document.- Parameters:
text- the text content- Returns:
- a Document with text content
-
fromText
Creates a Document with text and metadata.- Parameters:
text- the text contentmetadata- the metadata- Returns:
- a Document with text content and metadata
-
text
Gets the text content of this Document.- Returns:
- the concatenated text content
-
getContent
-
setContent
-
getMetadata
-
setMetadata
-
withMetadata
Adds metadata to this Document.- Parameters:
key- the metadata keyvalue- the metadata value- Returns:
- this Document for chaining
-