Skip to content

Commit

Permalink
fix(ai-help): destructure embedding response properly (mdn#9977)
Browse files Browse the repository at this point in the history
Resolves a `TypeError: undefined is not iterable`.
  • Loading branch information
caugner authored and gurezo committed Nov 11, 2023
1 parent 0b6df74 commit 189d751
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/ai-help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function updateEmbeddings(directory: string) {
// OpenAI recommends replacing newlines with spaces for best results (specific to embeddings)
const input = content.replace(/\n/g, " ");

let embeddingResponse;
let embeddingResponse: OpenAI.Embeddings.CreateEmbeddingResponse;
try {
embeddingResponse = await openai.embeddings.create({
model: "text-embedding-ada-002",
Expand All @@ -83,7 +83,7 @@ export async function updateEmbeddings(directory: string) {
const {
data: [{ embedding }],
usage: { total_tokens },
} = embeddingResponse.data;
} = embeddingResponse;

return {
total_tokens,
Expand Down

0 comments on commit 189d751

Please sign in to comment.