Skip to content

Commit a80a0d6

Browse files
authored
fix(ai-help): destructure embedding response properly (#9977)
Resolves a `TypeError: undefined is not iterable`.
1 parent 3544491 commit a80a0d6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: scripts/ai-help.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export async function updateEmbeddings(directory: string) {
5656
// OpenAI recommends replacing newlines with spaces for best results (specific to embeddings)
5757
const input = content.replace(/\n/g, " ");
5858

59-
let embeddingResponse;
59+
let embeddingResponse: OpenAI.Embeddings.CreateEmbeddingResponse;
6060
try {
6161
embeddingResponse = await openai.embeddings.create({
6262
model: "text-embedding-ada-002",
@@ -83,7 +83,7 @@ export async function updateEmbeddings(directory: string) {
8383
const {
8484
data: [{ embedding }],
8585
usage: { total_tokens },
86-
} = embeddingResponse.data;
86+
} = embeddingResponse;
8787

8888
return {
8989
total_tokens,

0 commit comments

Comments
 (0)