React Native RAG - v0.2.0
    Preparing search index...

    Interface VectorStore

    Defines the essential operations for a vector store. A vector store efficiently stores and retrieves high-dimensional vectors, facilitating similarity searches for AI applications like semantic search. It provides core functionalities for managing documents (add, update, delete) and performing similarity-based queries.

    interface VectorStore {
        load: () => Promise<VectorStore>;
        unload: () => Promise<void>;
        add(
            params: {
                document?: string;
                embedding?: number[];
                id?: string;
                metadata?: Record<string, any>;
            },
        ): Promise<string>;
        delete(params: { predicate: (value: GetResult) => boolean }): Promise<void>;
        query(
            params: {
                nResults?: number;
                predicate?: (value: QueryResult) => boolean;
                queryEmbedding?: number[];
                queryText?: string;
            },
        ): Promise<QueryResult[]>;
        update(
            params: {
                document?: string;
                embedding?: number[];
                id: string;
                metadata?: Record<string, any>;
            },
        ): Promise<void>;
    }

    Implemented by

    Index

    Properties

    Methods

    Properties

    load: () => Promise<VectorStore>

    Initializes the vector store, loading necessary resources.

    Type Declaration

      • (): Promise<VectorStore>
      • Returns Promise<VectorStore>

        Promise that resolves to the initialized vector store instance.

    unload: () => Promise<void>

    Unloads the vector store, releasing any resources used.

    Type Declaration

      • (): Promise<void>
      • Returns Promise<void>

        Promise that resolves when the vector store is unloaded.

    Methods

    • Adds a document to the vector store.

      Parameters

      • params: {
            document?: string;
            embedding?: number[];
            id?: string;
            metadata?: Record<string, any>;
        }

        Object containing:

        • Optionaldocument?: string

          Raw text content of the document.

        • Optionalembedding?: number[]

          Embedding for the document. If not provided, it will be generated based on the document.

        • Optionalid?: string

          The ID of the document. If not provided, it will be auto-generated.

        • Optionalmetadata?: Record<string, any>

          Metadata associated with the document.

      Returns Promise<string>

      Promise that resolves to the ID of the newly added document.

    • Deletes documents from the vector store by the provided predicate.

      Parameters

      • params: { predicate: (value: GetResult) => boolean }

        Object containing:

        • predicate: (value: GetResult) => boolean

          Predicate to match documents for deletion.

      Returns Promise<void>

      Promise that resolves once the documents are deleted.

    • Performs a similarity search against the stored vectors.

      Parameters

      • params: {
            nResults?: number;
            predicate?: (value: QueryResult) => boolean;
            queryEmbedding?: number[];
            queryText?: string;
        }

        Object containing:

        • OptionalnResults?: number

          The number of top similar results to return.

        • Optionalpredicate?: (value: QueryResult) => boolean

          Function to filter results after retrieval.

        • OptionalqueryEmbedding?: number[]

          Pre-computed embedding for the query.

        • OptionalqueryText?: string

          The raw query string to search for.

      Returns Promise<QueryResult[]>

      Promise that resolves to an array of QueryResult.

    • Updates a document in the vector store by its ID.

      Parameters

      • params: {
            document?: string;
            embedding?: number[];
            id: string;
            metadata?: Record<string, any>;
        }

        Object containing:

        • Optionaldocument?: string

          New content for the document.

        • Optionalembedding?: number[]

          New embedding for the document. If not provided, it will be generated based on the document.

        • id: string

          The ID of the document to update.

        • Optionalmetadata?: Record<string, any>

          New metadata for the document.

      Returns Promise<void>

      Promise that resolves once the document is updated.