Skip to content

Commit

Permalink
fix: error with undefined choices in new conversations (closes #202)
Browse files Browse the repository at this point in the history
-Added safe navigation to an object that might be undefined on an empty conversation.
-Fixes #201
  • Loading branch information
tebayoso committed May 16, 2024
1 parent 8fe7be6 commit 582a011
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/search/src/lib/approaches/chat-read-retrieve-read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ export class ChatReadRetrieveRead extends ApproachBase implements ChatApproach {
{
index: 0,
delta: {
content: chunk.choices[0].delta.content ?? '',
content: chunk.choices[0]?.delta.content ?? '',
role: 'assistant' as const,
context: {
data_points: id === 0 ? { text: dataPoints } : undefined,
thoughts: id === 0 ? thoughts : undefined,
},
},
finish_reason: chunk.choices[0].finish_reason,
finish_reason: chunk.choices[0]?.finish_reason,
},
],
object: 'chat.completion.chunk' as const,
Expand Down

0 comments on commit 582a011

Please sign in to comment.