You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
awaitclient.query('INSERT INTO documents (content, embedding) VALUES ($1, $2)',[content,pgvector.toSql(embedding)]);
26
+
constembeddings=awaitembed(input);
27
+
for(let[i,content]ofinput.entries()){
28
+
awaitclient.query('INSERT INTO documents (content, embedding) VALUES ($1, $2)',[content,pgvector.toSql(embeddings[i])]);
26
29
}
27
30
28
-
constdocumentId=2;
29
-
const{ rows }=awaitclient.query('SELECT * FROM documents WHERE id != $1 ORDER BY embedding <=> (SELECT embedding FROM documents WHERE id = $1) LIMIT 5',[documentId]);
31
+
constquery='forest';
32
+
constqueryEmbedding=(awaitembed([query]))[0];
33
+
const{ rows }=awaitclient.query('SELECT content FROM documents ORDER BY embedding <=> $1 LIMIT 5',[pgvector.toSql(queryEmbedding)]);
0 commit comments