Class PrismaVectorStore<TModel, TModelName, TSelectModel, TFilterModel>

A specific implementation of the VectorStore class that is designed to work with Prisma. It provides methods for adding models, documents, and vectors, as well as for performing similarity searches.

Type Parameters

  • TModel extends Record<string, unknown>

  • TModelName extends string

  • TSelectModel extends ModelColumns<TModel>

  • TFilterModel extends PrismaSqlFilter<TModel>

Hierarchy

Constructors

  • Type Parameters

    • TModel extends Record<string, unknown>

    • TModelName extends string

    • TSelectModel extends ModelColumns<TModel>

    • TFilterModel extends PrismaSqlFilter<TModel>

    Parameters

    • embeddings: Embeddings
    • config: {
          columns: TSelectModel;
          db: PrismaClient;
          prisma: PrismaNamespace;
          tableName: TModelName;
          vectorColumnName: string;
          filter?: TFilterModel;
      }
      • columns: TSelectModel
      • db: PrismaClient
      • prisma: PrismaNamespace
      • tableName: TModelName
      • vectorColumnName: string
      • Optional filter?: TFilterModel

    Returns PrismaVectorStore<TModel, TModelName, TSelectModel, TFilterModel>

Properties

FilterType: string | object
contentColumn: keyof TModel & string
embeddings: Embeddings
idColumn: keyof TModel & string
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
filter?: TFilterModel
ContentColumn: typeof ContentColumnSymbol = ContentColumnSymbol
IdColumn: typeof IdColumnSymbol = IdColumnSymbol
Prisma: PrismaNamespace
db: PrismaClient
selectColumns: string[]
tableName: string
vectorColumnName: string

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

  • Adds the specified models to the store.

    Parameters

    • models: TModel[]

      The models to add.

    Returns Promise<void>

    A promise that resolves when the models have been added.

  • Adds the specified vectors to the store.

    Parameters

    • vectors: number[][]

      The vectors to add.

    • documents: Document<TModel>[]

      The documents associated with the vectors.

    Returns Promise<void>

    A promise that resolves when the vectors have been added.

  • Performs a similarity search with the specified query.

    Parameters

    • query: string

      The query to use for the similarity search.

    • k: number = 4

      The number of results to return.

    • _filter: undefined | string | object = undefined

      The filter to apply to the results.

    • _callbacks: undefined | Callbacks = undefined

      The callbacks to use during the search.

    Returns Promise<Document<SimilarityModel<TModel, TSelectModel>>[]>

    A promise that resolves with the search results.

  • Performs a similarity search with the specified vector and returns the results along with their scores.

    Parameters

    • query: number[]

      The vector to use for the similarity search.

    • k: number

      The number of results to return.

    • Optional filter: TFilterModel

      The filter to apply to the results.

    Returns Promise<[Document<SimilarityModel<TModel, TSelectModel>>, number][]>

    A promise that resolves with the search results and their scores.

  • Performs a similarity search with the specified query and returns the results along with their scores.

    Parameters

    • query: string

      The query to use for the similarity search.

    • Optional k: number

      The number of results to return.

    • Optional filter: TFilterModel

      The filter to apply to the results.

    • _callbacks: undefined | Callbacks = undefined

      The callbacks to use during the search.

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

    A promise that resolves with the search results and their scores.

  • Creates a new PrismaVectorStore from the specified documents.

    Parameters

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

      The documents to use to create the store.

    • embeddings: Embeddings

      The embeddings to use.

    • dbConfig: {
          columns: ModelColumns<Record<string, unknown>>;
          db: PrismaClient;
          prisma: PrismaNamespace;
          tableName: string;
          vectorColumnName: string;
      }

      The database configuration.

      • columns: ModelColumns<Record<string, unknown>>
      • db: PrismaClient
      • prisma: PrismaNamespace
      • tableName: string
      • vectorColumnName: string

    Returns Promise<DefaultPrismaVectorStore>

    A promise that resolves with the new PrismaVectorStore.

  • Creates a new PrismaVectorStore from the specified texts.

    Parameters

    • texts: string[]

      The texts to use to create the store.

    • metadatas: object[]

      The metadata for the texts.

    • embeddings: Embeddings

      The embeddings to use.

    • dbConfig: {
          columns: ModelColumns<Record<string, unknown>>;
          db: PrismaClient;
          prisma: PrismaNamespace;
          tableName: string;
          vectorColumnName: string;
      }

      The database configuration.

      • columns: ModelColumns<Record<string, unknown>>
      • db: PrismaClient
      • prisma: PrismaNamespace
      • tableName: string
      • vectorColumnName: string

    Returns Promise<DefaultPrismaVectorStore>

    A promise that resolves with the new PrismaVectorStore.

  • 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

  • Creates a new PrismaVectorStore with the specified model.

    Type Parameters

    • TModel extends Record<string, unknown>

    Parameters

    • db: PrismaClient

      The PrismaClient instance.

    Returns {
        create: (<TPrisma, TColumns, TFilters>(embeddings, config) => PrismaVectorStore<TModel, ModelName, TColumns, TFilters>);
        fromDocuments: (<TPrisma, TColumns, TFilters>(docs, embeddings, dbConfig) => Promise<PrismaVectorStore<TModel, ModelName, TColumns, TFilters>>);
        fromTexts: (<TPrisma, TColumns>(texts, metadatas, embeddings, dbConfig) => Promise<DefaultPrismaVectorStore>);
    }

    An object with create, fromTexts, and fromDocuments methods.

    • create: (<TPrisma, TColumns, TFilters>(embeddings, config) => PrismaVectorStore<TModel, ModelName, TColumns, TFilters>)
        • <TPrisma, TColumns, TFilters>(embeddings, config): PrismaVectorStore<TModel, ModelName, TColumns, TFilters>
        • Type Parameters

          • TPrisma extends PrismaNamespace

          • TColumns extends ModelColumns<TModel>

          • TFilters extends PrismaSqlFilter<TModel>

          Parameters

          • embeddings: Embeddings
          • config: {
                columns: TColumns;
                prisma: TPrisma;
                tableName: keyof TPrisma["ModelName"] & string;
                vectorColumnName: string;
                filter?: TFilters;
            }
            • columns: TColumns
            • prisma: TPrisma
            • tableName: keyof TPrisma["ModelName"] & string
            • vectorColumnName: string
            • Optional filter?: TFilters

          Returns PrismaVectorStore<TModel, ModelName, TColumns, TFilters>

    • fromDocuments: (<TPrisma, TColumns, TFilters>(docs, embeddings, dbConfig) => Promise<PrismaVectorStore<TModel, ModelName, TColumns, TFilters>>)
        • <TPrisma, TColumns, TFilters>(docs, embeddings, dbConfig): Promise<PrismaVectorStore<TModel, ModelName, TColumns, TFilters>>
        • Type Parameters

          • TPrisma extends PrismaNamespace

          • TColumns extends ModelColumns<TModel>

          • TFilters extends PrismaSqlFilter<TModel>

          Parameters

          • docs: Document<TModel>[]
          • embeddings: Embeddings
          • dbConfig: {
                columns: TColumns;
                prisma: TPrisma;
                tableName: keyof TPrisma["ModelName"] & string;
                vectorColumnName: string;
            }
            • columns: TColumns
            • prisma: TPrisma
            • tableName: keyof TPrisma["ModelName"] & string
            • vectorColumnName: string

          Returns Promise<PrismaVectorStore<TModel, ModelName, TColumns, TFilters>>

    • fromTexts: (<TPrisma, TColumns>(texts, metadatas, embeddings, dbConfig) => Promise<DefaultPrismaVectorStore>)
        • <TPrisma, TColumns>(texts, metadatas, embeddings, dbConfig): Promise<DefaultPrismaVectorStore>
        • Type Parameters

          • TPrisma extends PrismaNamespace

          • TColumns extends ModelColumns<TModel>

          Parameters

          • texts: string[]
          • metadatas: TModel[]
          • embeddings: Embeddings
          • dbConfig: {
                columns: TColumns;
                prisma: TPrisma;
                tableName: keyof TPrisma["ModelName"] & string;
                vectorColumnName: string;
            }
            • columns: TColumns
            • prisma: TPrisma
            • tableName: keyof TPrisma["ModelName"] & string
            • vectorColumnName: string

          Returns Promise<DefaultPrismaVectorStore>

Generated using TypeDoc