Commit dab83c2
ebarkhordar
fix(sambanova): emit empty delta on usage-only final stream chunk
SambaNovaCloud enables stream_options={'include_usage': True} by default,
so the stream ends with a usage-only chunk where choices == []. That chunk
takes the else branch, which never reassigns content_delta, so the final
yield re-emits the previous chunk's token as its delta. This breaks the
streaming invariant that ''.join(deltas) equals the final message.content.
Set content_delta to '' on the usage-only chunk. Adds a regression test
that stubs the streaming request and asserts the concatenated deltas equal
the final content.1 parent 67514f6 commit dab83c2
4 files changed
Lines changed: 35 additions & 2 deletions
File tree
- llama-index-integrations/llms/llama-index-llms-sambanovasystems
- llama_index/llms/sambanovasystems
- tests
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
551 | 551 | | |
552 | 552 | | |
553 | 553 | | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
554 | 558 | | |
555 | 559 | | |
556 | 560 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
217 | 246 | | |
218 | 247 | | |
219 | 248 | | |
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments