Class DocumentCollection

DocumentCollection extends DocumentCollectionModel. It provides methods to interact with a Zep document collection.

Hierarchy (view full)

Constructors

Properties

created_at?: Date
description?: string
document_count?: number
document_embedded_count?: number
embedding_dimensions?: number
is_auto_embedded?: boolean
is_indexed?: boolean
is_normalized?: boolean
metadata?: Record<string, any>
name: string
updated_at?: Date
uuid?: string

Accessors

  • get status(): string
  • Returns the status of the document collection.

    Returns string

    The status of the document collection. "ready" if all documents are embedded, "pending" otherwise.

Methods

  • Adds documents to the collection.

    Parameters

    Returns Promise<string[]>

    A promise that resolves to an array of document UUIDs.

    Throws

    If the collection name is not provided or no documents are provided.

    Throws

    If the request fails.

  • Creates an index for the collection.

    Parameters

    • Optional force: boolean

      Whether to force index creation even if there are less than MIN_DOCS_TO_INDEX documents.

    Returns Promise<void>

    A promise that resolves when the index is created.

    Throws

    If the collection name is not provided or the collection has less than MIN_DOCS_TO_INDEX documents and force is not true.

    Throws

    If the request fails.

  • Deletes a document from the collection.

    Parameters

    • uuid: string

      The uuid of the document to delete.

    Returns Promise<void>

    A promise that resolves when the document is deleted.

    Throws

    If the collection name is not provided or the document does not have a uuid.

    Throws

    If the request fails.

    Throws

    If the request no document is found for the given uuid.

  • Gets a document from the collection.

    Parameters

    • uuid: string

      The uuid of the document to get.

    Returns Promise<IDocument>

    A promise that resolves to the document.

    Throws

    If the collection name is not provided or the document does not have a uuid.

    Throws

    If the request fails.

    Throws

    If the request no document is found for the given uuid.

  • Gets multiple documents from the collection.

    Parameters

    • uuids: string[]

      The uuids of the documents to get.

    Returns Promise<IDocument[]>

    A promise that resolves to an array of documents.

    Throws

    If any of the documents do not match the expected format.

    Throws

    If the collection name is not provided or no uuids are provided.

    Throws

    If the request fails.

  • Searches the collection.

    Parameters

    • query: ISearchQuery

      The search query.

    • Optional limit: number

      The maximum number of results to return.

    Returns Promise<IDocument[]>

    A promise that resolves to an array of documents.

    Throws

    If the collection name is not provided or the search query does not have at least one of text, embedding, or metadata.

    Throws

    If the request fails.

  • Searches the collection and returns the results and the query vector.

    Parameters

    • query: ISearchQuery

      The search query.

    • Optional limit: number

      The maximum number of results to return.

    Returns Promise<[IDocument[], Float32Array]>

    A promise that resolves to an array of documents and the query vector.

    Throws

    If the collection name is not provided or the search query does not have at least one of text, embedding, or metadata.

    Throws

    If the request fails.

  • Updates a document in the collection.

    Parameters

    Returns Promise<void>

    A promise that resolves when the document is updated.

    Throws

    If the collection name is not provided or the document does not have a uuid.

    Throws

    If the request fails.

    Throws

    If the request no document is found for the given uuid.

Generated using TypeDoc