diff --git a/frontend/src/lib/components/copilot/lib.ts b/frontend/src/lib/components/copilot/lib.ts index 9aa8c80d29..5e7f263dca 100644 --- a/frontend/src/lib/components/copilot/lib.ts +++ b/frontend/src/lib/components/copilot/lib.ts @@ -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(