Class ConvexVectorStore<DataModel, TableName, IndexName, TextFieldName, EmbeddingFieldName, MetadataFieldName, InsertMutation, GetQuery>

Class that is a wrapper around Convex storage and vector search. It is used to insert embeddings in Convex documents with a vector search index, and perform a vector search on them.

ConvexVectorStore does NOT implement maxMarginalRelevanceSearch.

Type Parameters

  • DataModel extends GenericDataModel

  • TableName extends TableNamesInDataModel<DataModel>

  • IndexName extends VectorIndexNames<NamedTableInfo<DataModel, TableName>>

  • TextFieldName extends FieldPaths<NamedTableInfo<DataModel, TableName>>

  • EmbeddingFieldName extends FieldPaths<NamedTableInfo<DataModel, TableName>>

  • MetadataFieldName extends FieldPaths<NamedTableInfo<DataModel, TableName>>

  • InsertMutation extends FunctionReference<"mutation", "internal", {
        document: object;
        table: string;
    }>

  • GetQuery extends FunctionReference<"query", "internal", {
        id: string;
    }, object | null>

Hierarchy

Constructors

  • Type Parameters

    • DataModel extends GenericDataModel

    • TableName extends string

    • IndexName extends string | number | symbol

    • TextFieldName extends string

    • EmbeddingFieldName extends string

    • MetadataFieldName extends string

    • InsertMutation extends FunctionReference<"mutation", "internal", {
          document: object;
          table: string;
      }>

    • GetQuery extends FunctionReference<"query", "internal", {
          id: string;
      }, null | object>

    Parameters

    • embeddings: Embeddings
    • config: ConvexVectorStoreConfig<DataModel, TableName, IndexName, TextFieldName, EmbeddingFieldName, MetadataFieldName, InsertMutation, GetQuery>

    Returns ConvexVectorStore<DataModel, TableName, IndexName, TextFieldName, EmbeddingFieldName, MetadataFieldName, InsertMutation, GetQuery>

Properties

FilterType: {
    filter?: ((q) => FilterExpression<boolean>);
    includeEmbeddings?: boolean;
}

Type that defines the filter used in the similaritySearchVectorWithScore and maxMarginalRelevanceSearch methods. It includes limit, filter and a flag to include embeddings.

Type declaration

  • Optional filter?: ((q) => FilterExpression<boolean>)
      • (q): FilterExpression<boolean>
      • Parameters

        • q: VectorFilterBuilder<GenericDocument, NamedVectorIndex<NamedTableInfo<DataModel, TableName>, IndexName>>

        Returns FilterExpression<boolean>

  • Optional includeEmbeddings?: boolean
embeddings: Embeddings
lc_kwargs: SerializedFields
lc_namespace: string[] = ...

A path to the module that contains the class, eg. ["langchain", "llms"] Usually should be the same as the entrypoint the class is exported from.

lc_serializable: boolean = false

Accessors

  • get lc_aliases(): undefined | {
        [key: string]: string;
    }
  • A map of aliases for constructor args. Keys are the attribute names, e.g. "foo". Values are the alias that will replace the key in serialization. This is used to eg. make argument names match Python.

    Returns undefined | {
        [key: string]: string;
    }

  • get lc_attributes(): undefined | SerializedFields
  • A map of additional attributes to merge with constructor args. Keys are the attribute names, e.g. "foo". Values are the attribute values, which will be serialized. These attributes need to be accepted by the constructor as arguments.

    Returns undefined | SerializedFields

  • get lc_secrets(): undefined | {
        [key: string]: string;
    }
  • A map of secrets, which will be omitted from serialization. Keys are paths to the secret in constructor args, e.g. "foo.bar.baz". Values are the secret ids, which will be used when deserializing.

    Returns undefined | {
        [key: string]: string;
    }

Methods

  • Add documents to the Convex table. It first converts the documents to vectors using the embeddings and then calls the addVectors method.

    Parameters

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

      Documents to be added.

    Returns Promise<void>

    Promise that resolves when the documents have been added.

  • Add vectors and their corresponding documents to the Convex table.

    Parameters

    • vectors: number[][]

      Vectors to be added.

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

      Corresponding documents to be added.

    Returns Promise<void>

    Promise that resolves when the vectors and documents have been added.

  • Parameters

    • Optional kOrFields: number | Partial<VectorStoreRetrieverInput<ConvexVectorStore<DataModel, TableName, IndexName, TextFieldName, EmbeddingFieldName, MetadataFieldName, InsertMutation, GetQuery>>>
    • Optional filter: {
          filter?: ((q) => FilterExpression<boolean>);
          includeEmbeddings?: boolean;
      }
      • Optional filter?: ((q) => FilterExpression<boolean>)
          • (q): FilterExpression<boolean>
          • Parameters

            • q: VectorFilterBuilder<GenericDocument, NamedVectorIndex<NamedTableInfo<DataModel, TableName>, IndexName>>

            Returns FilterExpression<boolean>

      • Optional includeEmbeddings?: boolean
    • Optional callbacks: Callbacks
    • Optional tags: string[]
    • Optional metadata: Record<string, unknown>
    • Optional verbose: boolean

    Returns VectorStoreRetriever<ConvexVectorStore<DataModel, TableName, IndexName, TextFieldName, EmbeddingFieldName, MetadataFieldName, InsertMutation, GetQuery>>

  • Similarity search on the vectors stored in the Convex table. It returns a list of documents and their corresponding similarity scores.

    Parameters

    • query: number[]

      Query vector for the similarity search.

    • k: number

      Number of nearest neighbors to return.

    • Optional filter: {
          filter?: ((q) => FilterExpression<boolean>);
          includeEmbeddings?: boolean;
      }

      Optional filter to be applied.

      • Optional filter?: ((q) => FilterExpression<boolean>)
          • (q): FilterExpression<boolean>
          • Parameters

            • q: VectorFilterBuilder<GenericDocument, NamedVectorIndex<NamedTableInfo<DataModel, TableName>, IndexName>>

            Returns FilterExpression<boolean>

      • Optional includeEmbeddings?: boolean

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

    Promise that resolves to a list of documents and their corresponding similarity scores.

  • 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<{
          filter?: ((q) => FilterExpression<boolean>);
          includeEmbeddings?: boolean;
      }>
    • _callbacks: undefined | Callbacks

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

    • List of documents selected by maximal marginal relevance.
  • Static method to create an instance of ConvexVectorStore from a list of documents. It first converts the documents to vectors and then adds them to the Convex table.

    Type Parameters

    • DataModel extends GenericDataModel

    • TableName extends string

    • IndexName extends string | number | symbol

    • TextFieldName extends string

    • EmbeddingFieldName extends string

    • MetadataFieldName extends string

    • InsertMutation extends FunctionReference<"mutation", "internal", {
          document: object;
          table: string;
      }>

    • GetQuery extends FunctionReference<"query", "internal", {
          id: string;
      }, null | object>

    Parameters

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

      List of documents to be converted to vectors.

    • embeddings: Embeddings

      Embeddings to be used for conversion.

    • dbConfig: ConvexVectorStoreConfig<DataModel, TableName, IndexName, TextFieldName, EmbeddingFieldName, MetadataFieldName, InsertMutation, GetQuery>

      Database configuration for Convex.

    Returns Promise<ConvexVectorStore<DataModel, TableName, IndexName, TextFieldName, EmbeddingFieldName, MetadataFieldName, InsertMutation, GetQuery>>

    Promise that resolves to a new instance of ConvexVectorStore.

  • Static method to create an instance of ConvexVectorStore from a list of texts. It first converts the texts to vectors and then adds them to the Convex table.

    Type Parameters

    • DataModel extends GenericDataModel

    • TableName extends string

    • IndexName extends string | number | symbol

    • TextFieldName extends string

    • EmbeddingFieldName extends string

    • MetadataFieldName extends string

    • InsertMutation extends FunctionReference<"mutation", "internal", {
          document: object;
          table: string;
      }>

    • GetQuery extends FunctionReference<"query", "internal", {
          id: string;
      }, null | object>

    Parameters

    • texts: string[]

      List of texts to be converted to vectors.

    • metadatas: object | object[]

      Metadata for the texts.

    • embeddings: Embeddings

      Embeddings to be used for conversion.

    • dbConfig: ConvexVectorStoreConfig<DataModel, TableName, IndexName, TextFieldName, EmbeddingFieldName, MetadataFieldName, InsertMutation, GetQuery>

      Database configuration for Convex.

    Returns Promise<ConvexVectorStore<DataModel, TableName, IndexName, TextFieldName, EmbeddingFieldName, MetadataFieldName, InsertMutation, GetQuery>>

    Promise that resolves to a new instance of ConvexVectorStore.

  • The name of the serializable. Override to provide an alias or to preserve the serialized module name in minified environments.

    Implemented as a static method to support loading logic.

    Returns string

Generated using TypeDoc