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 (view full)

Constructors

Properties

FilterType: TFilterModel
contentColumn: keyof TModel & string
idColumn: keyof TModel & string
filter?: TFilterModel
ContentColumn: typeof ContentColumnSymbol = ContentColumnSymbol
IdColumn: typeof IdColumnSymbol = IdColumnSymbol
Prisma: PrismaNamespace
db: PrismaClient
selectColumns: string[]
tableName: string
vectorColumnName: string

Methods

  • 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 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.

    Returns Promise<any>

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

  • Creates a new PrismaVectorStore from the specified documents.

    Parameters

    • docs: Document[]

      The documents to use to create the store.

    • embeddings: EmbeddingsInterface

      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: EmbeddingsInterface

      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.

Generated using TypeDoc