ailoy-node
    Preparing search index...

    Class VectorStore

    The VectorStore class provides a high-level abstraction for storing and retrieving documents. It mainly consists of two modules - embedding model and vector store.

    It supports embedding text using AI and interfacing with pluggable vector store backends such as FAISS or ChromaDB. This class handles initialization, insertion, similarity-based retrieval, and cleanup.

    Typical usage involves:

    1. Initializing the store via initialize()
    2. Inserting documents via insert()
    3. Querying similar documents via retrieve()

    The embedding model and vector store are defined dynamically within the provided runtime.

    Index

    Constructors

    Methods

    • Defines the embedding model and vector store components to the runtime. This must be called before using any other method in the class. If already defined, this is a no-op.

      Parameters

      • embeddingModelName: "BAAI/bge-m3"
      • embeddingModelAttrs: Record<string, any>
      • vectorStoreName: VectorStoreName
      • vectorStoreAttrs: Record<string, any>

      Returns Promise<void>

    • Delete resources from the runtime. This should be called when the VectorStore is no longer needed. If already deleted, this is a no-op.

      Returns Promise<void>

    • Generates an embedding vector for the given input text using the embedding model

      Parameters

      • text: string

        Input text to embed

      Returns Promise<NDArray>

    • Retrieves the top-K most similar documents to the given query

      Parameters

      • query: string

        The input query string to search for similar content

      • topK: number = 5

        Number of top similar documents to retrieve

      Returns Promise<VectorStoreRetrieveItem[]>