RayanMLK commited on
Commit
6c1adc7
·
1 Parent(s): 998d845

fix: guard empty chunks in stream (list index out of range)

Browse files
Files changed (1) hide show
  1. app.py +3 -0
app.py CHANGED
@@ -71,6 +71,9 @@ def respond_streaming(user_message: str, history: list):
71
  temperature=0.3,
72
  stream=True,
73
  ):
 
 
 
74
  delta = chunk.choices[0].delta.content
75
  if delta:
76
  partial += delta
 
71
  temperature=0.3,
72
  stream=True,
73
  ):
74
+ # Guard against empty chunks at end of stream
75
+ if not chunk.choices:
76
+ continue
77
  delta = chunk.choices[0].delta.content
78
  if delta:
79
  partial += delta