Skip to content

Commit

Permalink
fix(community): Update PrismaVectorStore to execute raw SQL with `Pri…
Browse files Browse the repository at this point in the history
…sma.sql` tagged template (#6889)

Co-authored-by: jacoblee93 <[email protected]>
  • Loading branch information
hmShuvo314 and jacoblee93 authored Sep 30, 2024
1 parent a4588a0 commit 4b00f3e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions libs/langchain-community/src/vectorstores/prisma.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Document } from "@langchain/core/documents";
import type { EmbeddingsInterface } from "@langchain/core/embeddings";
import { VectorStore } from "@langchain/core/vectorstores";
import { Document } from "@langchain/core/documents";

const IdColumnSymbol = Symbol("id");
const ContentColumnSymbol = Symbol("content");
Expand Down Expand Up @@ -306,12 +306,13 @@ export class PrismaVectorStore<
const vectorColumnRaw = this.Prisma.raw(`"${this.vectorColumnName}"`);

await this.db.$transaction(
vectors.map(
(vector, idx) => this.db.$executeRaw`
UPDATE ${tableNameRaw}
SET ${vectorColumnRaw} = ${`[${vector.join(",")}]`}::vector
WHERE ${idColumnRaw} = ${documents[idx].metadata[this.idColumn]}
`
vectors.map((vector, idx) =>
this.db.$executeRaw(
this.Prisma.sql`UPDATE ${tableNameRaw}
SET ${vectorColumnRaw} = ${`[${vector.join(",")}]`}::vector
WHERE ${idColumnRaw} = ${documents[idx].metadata[this.idColumn]}
`
)
)
);
}
Expand Down

0 comments on commit 4b00f3e

Please sign in to comment.