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

    SQLite-backed implementation of VectorStore using @op-engineering/op-sqlite.

    Stores embeddings as an F32 blob and uses vector indexing helpers for efficient cosine-similarity search. Suitable for on-device retrieval in React Native apps.

    const store = await new OPSQLiteVectorStore({ name: 'vector-db', embeddings }).load();
    await store.add({ document: 'hello world' });
    const [top] = await store.query({ queryText: 'hello', nResults: 1 });
    console.log(top.id, top.similarity);

    Implements

    Index

    Constructors

    Properties

    db: DB

    Methods

    • Inserts a document with an embedding. Generates an ID when not provided.

      Parameters

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

        Parameters for the operation.

        • Optionaldocument?: string

          Raw text content for the document.

        • Optionalembedding?: number[]

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

        • Optionalid?: string

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

        • Optionalmetadata?: Record<string, any>

          Metadata for the document.

      Returns Promise<string>

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

    • Deletes documents by predicate.

      Parameters

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

        Parameters for deletion.

        • predicate: (value: GetResult) => boolean

          Predicate to match documents for deletion.

      Returns Promise<void>

      Promise that resolves once the documents are deleted.

    • Drops the vectors table entirely.

      Returns Promise<void>

    • Executes a cosine-similarity query over stored vectors. Provide exactly one of queryText or queryEmbedding.

      Parameters

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

        Query parameters.

        • OptionalnResults?: number

          Number of top results to return.

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

          Function to filter results after retrieval.

        • OptionalqueryEmbedding?: number[]

          Precomputed query embedding.

        • OptionalqueryText?: string

          Raw query string to search for.

      Returns Promise<QueryResult[]>

      Promise that resolves to an array of QueryResult.

    • Closes embeddings and the underlying database connection.

      Returns Promise<void>

      Promise that resolves when unloading is complete.

    • Updates a document by ID.

      Parameters

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

        Parameters for the update.

        • Optionaldocument?: string

          New content for the document.

        • Optionalembedding?: number[]

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

        • id: string

          ID of the document to update.

        • Optionalmetadata?: Record<string, any>

          New metadata for the document.

      Returns Promise<void>

      Promise that resolves when the update completes.