fix: prevent invalid returned ai completion object errors (#5564)

This commit is contained in:
HugoCasa
2025-04-03 16:32:11 +02:00
committed by GitHub
parent 1e25c28183
commit f12bbf47c8

View File

@@ -443,7 +443,7 @@ export async function getNonStreamingCompletion(
})
: workspaceAIClients.getOpenaiClient()
const completion = await openaiClient.chat.completions.create(config, fetchOptions)
response = completion.choices[0]?.message.content || ''
response = completion.choices?.[0]?.message.content || ''
return response
}
@@ -464,7 +464,7 @@ export async function getCompletion(
}
export function getResponseFromEvent(part: OpenAI.Chat.Completions.ChatCompletionChunk): string {
return part.choices[0]?.delta?.content || ''
return part.choices?.[0]?.delta?.content || ''
}
export async function copilot(