Document represents document content along with its metadata that can be embedded, indexed or retrieved. Each document can contain multiple parts (for example text and an image)

Hierarchy (View Summary)

Implements

Constructors

Properties

Accessors

Methods

Constructors

  • Parameters

    • data: {
          content: (
              | { media?: undefined; text: string }
              | { media: { contentType?: string; url: string }; text?: undefined }
          )[];
          metadata: { score: number } & { [k: string]: unknown };
      }

    Returns RankedDocument

Properties

content: (
    | { media?: undefined; text: string }
    | { media: { contentType?: string; url: string }; text?: undefined }
)[]
metadata: { score: number } & Record<string, any>

Accessors

  • get media(): null | { contentType?: string; url: string }
  • Returns the first media part detected in the document. Useful for extracting (for example) an image.

    Returns null | { contentType?: string; url: string }

    The first detected media part in the document.

  • get text(): string
  • Concatenates all text parts present in the document with no delimiter.

    Returns string

    A string of all concatenated text parts.

Methods

  • Returns the score of the document.

    Returns number

    The score of the document.

  • Returns {
        content: (
            | { media?: undefined; text: string }
            | { media: { contentType?: string; url: string }; text?: undefined }
        )[];
        metadata?: Record<string, any>;
    }

  • Parameters

    • text: string
    • Optionalmetadata: Record<string, any>

    Returns Document