Class for interacting with SingleStoreDB, a high-performance distributed SQL database. It provides vector storage and vector functions.

Hierarchy

  • VectorStore
    • SingleStoreVectorStore

Constructors

Properties

FilterType: string | object

Defines the filter type used in search and delete operations. Can be an object for structured conditions or a string for simpler filtering.

connectionPool: Pool
contentColumnName: string
distanceMetric: DistanceMetrics
embeddings: EmbeddingsInterface

Embeddings interface for generating vector embeddings from text queries, enabling vector-based similarity searches.

idColumnName: string
metadataColumnName: string
searchConfig: SearchConfig
tableName: string
useFullTextIndex: boolean
useVectorIndex: boolean
vectorColumnName: string
vectorIndexName: string
vectorIndexOptions: Metadata
vectorSize: number

Methods

  • Adds new vectors to the SingleStoreDB database.

    Parameters

    • vectors: number[][]

      An array of vectors.

    • documents: Document<Record<string, any>>[]

      An array of Document objects.

    Returns Promise<void>

  • Creates a VectorStoreRetriever instance with flexible configuration options.

    Parameters

    • OptionalkOrFields: number | Partial<VectorStoreRetrieverInput<SingleStoreVectorStore>>

      If a number is provided, it sets the k parameter (number of items to retrieve).

      • If an object is provided, it should contain various configuration options.
    • Optionalfilter: string | object

      Optional filter criteria to limit the items retrieved based on the specified filter type.

    • Optionalcallbacks: Callbacks

      Optional callbacks that may be triggered at specific stages of the retrieval process.

    • Optionaltags: string[]

      Tags to categorize or label the VectorStoreRetriever. Defaults to an empty array if not provided.

    • Optionalmetadata: Record<string, unknown>

      Additional metadata as key-value pairs to add contextual information for the retrieval process.

    • Optionalverbose: boolean

      If true, enables detailed logging for the retrieval process. Defaults to false.

    Returns VectorStoreRetriever<SingleStoreVectorStore>

    • A configured VectorStoreRetriever instance based on the provided parameters.

    Basic usage with a k value:

    const retriever = myVectorStore.asRetriever(5);
    

    Usage with a configuration object:

    const retriever = myVectorStore.asRetriever({
    k: 10,
    filter: myFilter,
    tags: ['example', 'test'],
    verbose: true,
    searchType: 'mmr',
    searchKwargs: { alpha: 0.5 },
    });
  • Deletes documents from the vector store based on the specified parameters.

    Parameters

    • Optional_params: Record<string, any>

      Flexible key-value pairs defining conditions for document deletion.

    Returns Promise<void>

    A promise that resolves once the deletion is complete.

  • Return documents selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to the query AND diversity among selected documents.

    Parameters

    • query: string

      Text to look up documents similar to.

    • options: MaxMarginalRelevanceSearchOptions<string | object>
    • _callbacks: undefined | Callbacks

    Returns Promise<DocumentInterface<Record<string, any>>[]>

    • List of documents selected by maximal marginal relevance.
  • Performs a similarity search on the texts stored in the SingleStoreDB

    Parameters

    • query: string

      A string representing the query text.

    • Optionalk: number

      The number of nearest neighbors to return. By default, it is 4.

    • Optionalfilter: Metadata

      Optional metadata to filter the texts by.

    • Optional_callbacks: Callbacks

      Callbacks object, not used in this implementation.

    Returns Promise<DocumentInterface<Metadata>[]>

    Top matching documents

  • Performs a similarity search on the texts stored in the SingleStoreDB using the specified search strategy and distance metric.

    Parameters

    • query: string

      A string representing the query text.

    • vector: number[]

      An array of numbers representing the query vector.

    • k: number

      The number of nearest neighbors to return.

    • Optionalfilter: Metadata

      Optional metadata to filter the texts by.

    Returns Promise<[Document<Record<string, any>>, number][]>

    Top matching documents with score

  • Performs a similarity search on the vectors stored in the SingleStoreDB database.

    Parameters

    • query: number[]

      An array of numbers representing the query vector.

    • k: number

      The number of nearest neighbors to return.

    • Optionalfilter: Metadata

      Optional metadata to filter the vectors by.

    Returns Promise<[Document<Record<string, any>>, number][]>

    Top matching vectors with score

  • Performs a similarity search on the texts stored in the SingleStoreDB

    Parameters

    • query: string

      A string representing the query text.

    • Optionalk: number

      The number of nearest neighbors to return. By default, it is 4.

    • Optionalfilter: Metadata

      Optional metadata to filter the texts by.

    • Optional_callbacks: Callbacks

    Returns Promise<[DocumentInterface<Metadata>, number][]>

    Top matching documents with score

  • Returns Serialized