Commit 8f11896
Related issue: #905
## Problem
The final chunk yielded by `complete_streaming_chat` can carry an empty
`choices` list. The documented example in `chat_client.py` and the
streaming samples indexed `chunk.choices[0]` unconditionally, raising
`IndexError` **after** the full response had already been produced.
## Fix
Guard with `if not chunk.choices: continue` in:
- `samples/python/native-chat-completions/src/app.py`
- `samples/python/tutorial-chat-assistant/src/app.py`
## Testing
Reproduced on macOS (arm64), Python 3.13, `foundry-local-sdk` 1.2.3,
model `qwen2.5-0.5b` via the WebGPU EP. After the fix, streaming
completes cleanly with no exception — verified with the interactive
`app.py` over a 3-turn conversation and a single-prompt run.
Co-authored-by: Prathik Rao <prathikrao@microsoft.com>
1 parent eabb3c8 commit 8f11896
2 files changed
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
| |||
0 commit comments