Help Needed: Error with Postgres Schema, OpenAI Embedding and Prisma
I'm currently working on saving OpenAI embeddings in a Postgres schema, and I'm encountering a TypeScript error. Below is the schema I'm using:
model SentenceEmbedding {
id String @id @default(cuid())
voiceNoteId String
voiceNote VoiceNote @relation(fields: [voiceNoteId], references: [id], onDelete: Cascade)
finalizedSentenceId String @unique
finalizedSentence FinalizedSentence @relation(fields: [finalizedSentenceId], references: [id], onDelete: Cascade)
userId String?
embedding Unsupported("vector(1536)")?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
I’m using OpenAI's embedding API to generate and save the embeddings. Here's the relevant code:
const { embedding } = await createTextEmbeddings(
"Hello World!",
);
await prisma.sentenceEmbedding.create({
data: {
voiceNoteId: noteId,
finalizedSentenceId: finalizedSentenceId,
embedding: embedding,
},
});
However, I’m encountering a TypeScript error when trying to save the embedding.
"Object literal may only specify known properties, and embedding does not exist in type:"
"Unknown argument
embedding
. Available options are marked with ?."
Could anyone assist with resolving this issue? Any advice would be appreciated!0 Replies