langchain.js
    Preparing search index...

    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 Summary)

    Index

    Constructors

    Properties

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

    Methods

    • Returns string

    • Adds the specified documents to the store.

      Parameters

      • documents: Document<TModel>[]

        The documents to add.

      Returns Promise<void>

      A promise that resolves when the documents have been added.

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

    • Parameters

      Returns null | Sql

    • 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 | TFilterModel = undefined

      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.

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

      • Optionalk: number

        The number of results to return.

      • Optionalfilter: TFilterModel

        The filter to apply to the results.

      Returns Promise<[DocumentInterface<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[]

        The documents to use to create the store.

      • embeddings: EmbeddingsInterface

        The embeddings to use.

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

        The database configuration.

      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>>;
            columnTypes?: ColumnTypeConfig;
            db: PrismaClient;
            prisma: PrismaNamespace;
            tableName: string;
            vectorColumnName: string;
        }

        The database configuration.

      Returns Promise<DefaultPrismaVectorStore>

      A promise that resolves with the new PrismaVectorStore.

    • Creates a new PrismaVectorStore with the specified model.

      Type Parameters

      • TModel extends Record<string, unknown>

      Parameters

      • db: PrismaClient

        The PrismaClient instance.

      Returns {
          create: <
              TPrisma extends PrismaNamespace,
              TColumns extends ModelColumns<TModel>,
              TFilters extends PrismaSqlFilter<TModel>,
          >(
              embeddings: EmbeddingsInterface,
              config: {
                  columns: TColumns;
                  columnTypes?: ColumnTypeConfig;
                  filter?: TFilters;
                  prisma: TPrisma;
                  tableName: keyof TPrisma["ModelName"] & string;
                  vectorColumnName: string;
              },
          ) => PrismaVectorStore<TModel, ModelName, TColumns, TFilters>;
          fromDocuments: <
              TPrisma extends PrismaNamespace,
              TColumns extends ModelColumns<TModel>,
              TFilters extends PrismaSqlFilter<TModel>,
          >(
              docs: Document<TModel>[],
              embeddings: EmbeddingsInterface,
              dbConfig: {
                  columns: TColumns;
                  columnTypes?: ColumnTypeConfig;
                  prisma: TPrisma;
                  tableName: keyof TPrisma["ModelName"] & string;
                  vectorColumnName: string;
              },
          ) => Promise<PrismaVectorStore<TModel, ModelName, TColumns, TFilters>>;
          fromTexts: <
              TPrisma extends PrismaNamespace,
              TColumns extends ModelColumns<TModel>,
          >(
              texts: string[],
              metadatas: TModel[],
              embeddings: EmbeddingsInterface,
              dbConfig: {
                  columns: TColumns;
                  columnTypes?: ColumnTypeConfig;
                  prisma: TPrisma;
                  tableName: keyof TPrisma["ModelName"] & string;
                  vectorColumnName: string;
              },
          ) => Promise<DefaultPrismaVectorStore>;
      }

      An object with create, fromTexts, and fromDocuments methods.