Skip to content

Commit 582a011

Browse files
authored
fix: error with undefined choices in new conversations (closes #202)
-Added safe navigation to an object that might be undefined on an empty conversation. -Fixes #201
1 parent 8fe7be6 commit 582a011

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/search/src/lib/approaches/chat-read-retrieve-read.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ export class ChatReadRetrieveRead extends ApproachBase implements ChatApproach {
107107
{
108108
index: 0,
109109
delta: {
110-
content: chunk.choices[0].delta.content ?? '',
110+
content: chunk.choices[0]?.delta.content ?? '',
111111
role: 'assistant' as const,
112112
context: {
113113
data_points: id === 0 ? { text: dataPoints } : undefined,
114114
thoughts: id === 0 ? thoughts : undefined,
115115
},
116116
},
117-
finish_reason: chunk.choices[0].finish_reason,
117+
finish_reason: chunk.choices[0]?.finish_reason,
118118
},
119119
],
120120
object: 'chat.completion.chunk' as const,

0 commit comments

Comments
 (0)