fix: prevent invalid returned ai completion object errors (#5564)
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user