Skip to content

Commit 7cb0116

Browse files
authored
fix(js/plugins/firebase): properly await embedding promise (#1750)
1 parent 9a88617 commit 7cb0116

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

js/plugins/firebase/src/firestoreRetriever.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,7 @@ export function defineFirestoreRetriever(
122122
collection: z.string().optional(),
123123
}),
124124
},
125-
async (input, options) => {
126-
// Single embedding for text input
127-
const embedding = await ai.embed({ embedder, content: input })[0]
128-
.embedding;
125+
async (content, options) => {
129126
if (!options.collection && !collection) {
130127
throw new Error(
131128
'Must specify a collection to query in Firestore retriever.'
@@ -137,6 +134,9 @@ export function defineFirestoreRetriever(
137134
for (const field in options.where || {}) {
138135
query = query.where(field, '==', options.where![field]);
139136
}
137+
// Single embedding for text input
138+
const embeddings = await ai.embed({ embedder, content });
139+
const embedding = embeddings[0].embedding;
140140
const result = await query
141141
.findNearest(vectorField, embedding, {
142142
limit: options.limit || 10,

0 commit comments

Comments
 (0)