Spaces:
Sleeping
Sleeping
fix: guard empty chunks in stream (list index out of range)
Browse files
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
|