Commit e56aaca
committed
fix(textGeneration): finalize empty truncated generations
Gate the completion handling on `generated_text != null` instead of truthiness
so a terminal output with empty text is still finalized. A model can hit
finish_reason "length" before emitting any visible content (hidden-reasoning
models, very small budgets); previously that output was skipped (the special
token was ignored) and the truncation warning never fired. Now the truncation
is flagged + logged for the empty case too.
Note: a genuinely empty body still surfaces as a "no output" error downstream
(content equals the initial empty content), which is the appropriate UX; this
change is about observability and a consistent interrupted flag, not changing
that outcome.
Adds an adapter test for the empty length-terminated stream.1 parent 65c9feb commit e56aaca
2 files changed
Lines changed: 20 additions & 2 deletions
File tree
- src/lib/server
- endpoints/openai
- textGeneration
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
42 | 57 | | |
43 | 58 | | |
44 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
91 | 94 | | |
92 | 95 | | |
93 | 96 | | |
| |||
0 commit comments