Class Document.Builder

java.lang.Object
com.tnsai.knowledge.Document.Builder
Enclosing class:
Document

public static final class Document.Builder extends Object
Builder for creating Document instances.
  • Method Details

    • id

      public Document.Builder id(String id)
      Sets the document ID. If not set, a UUID will be generated.
      Parameters:
      id - the document ID
      Returns:
      this builder
    • content

      public Document.Builder content(String content)
      Sets the document content.
      Parameters:
      content - the content text
      Returns:
      this builder
    • metadata

      public Document.Builder metadata(String key, Object value)
      Adds a metadata entry.
      Parameters:
      key - the metadata key
      value - the metadata value
      Returns:
      this builder
    • metadata

      public Document.Builder metadata(Map<String,Object> metadata)
      Adds multiple metadata entries.
      Parameters:
      metadata - the metadata map
      Returns:
      this builder
    • embedding

      public Document.Builder embedding(float[] embedding)
      Sets the document embedding.
      Parameters:
      embedding - the embedding vector
      Returns:
      this builder
    • build

      public Document build()
      Builds the document.
      Returns:
      the new document
      Throws:
      IllegalStateException - if content is not set