Commit b2abc0d
committed
fix(core): ensure llm_output is always dict in LLMResult, never None
This commit comprehensively fixes issue #34057 where streaming mode
was returning LLMResult with llm_output: None instead of llm_output: {}.
Root cause: Multiple code paths were creating ChatResult/LLMResult
without explicitly setting llm_output={}, causing it to default to None.
Changes:
- chat_models.py: Added llm_output={} to cache retrieval paths (sync/async),
generate_from_stream(), and SimpleChatModel._generate()
- llms.py: Added llm_output={} to SimpleLLM._generate() and _agenerate()
- fake_chat_models.py: Fixed all 4 fake model _generate() methods
- event_stream.py: Improved llm_output serialization in on_llm_end()
- test_runnable_events_v1.py: Updated test expectations
Tests:
- test_astream_events_from_model: PASSED ✓
- test_event_stream_with_simple_chain: PASSED ✓
- All linting checks: PASSED ✓1 parent b904b4a commit b2abc0d
File tree
5 files changed
+31
-18
lines changed- libs/core
- langchain_core
- language_models
- tracers
- tests/unit_tests/runnables
5 files changed
+31
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
209 | | - | |
| 209 | + | |
| 210 | + | |
210 | 211 | | |
211 | 212 | | |
212 | 213 | | |
| |||
1135 | 1136 | | |
1136 | 1137 | | |
1137 | 1138 | | |
1138 | | - | |
| 1139 | + | |
1139 | 1140 | | |
1140 | 1141 | | |
1141 | 1142 | | |
| |||
1253 | 1254 | | |
1254 | 1255 | | |
1255 | 1256 | | |
1256 | | - | |
| 1257 | + | |
1257 | 1258 | | |
1258 | 1259 | | |
1259 | 1260 | | |
| |||
1742 | 1743 | | |
1743 | 1744 | | |
1744 | 1745 | | |
1745 | | - | |
| 1746 | + | |
1746 | 1747 | | |
1747 | 1748 | | |
1748 | 1749 | | |
| |||
Lines changed: 6 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
216 | | - | |
| 216 | + | |
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
264 | | - | |
| 264 | + | |
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
389 | | - | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
390 | 392 | | |
391 | 393 | | |
392 | 394 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1504 | 1504 | | |
1505 | 1505 | | |
1506 | 1506 | | |
1507 | | - | |
| 1507 | + | |
1508 | 1508 | | |
1509 | 1509 | | |
1510 | 1510 | | |
| |||
1522 | 1522 | | |
1523 | 1523 | | |
1524 | 1524 | | |
1525 | | - | |
| 1525 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
486 | 486 | | |
487 | 487 | | |
488 | 488 | | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
496 | 506 | | |
497 | 507 | | |
498 | 508 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1809 | 1809 | | |
1810 | 1810 | | |
1811 | 1811 | | |
1812 | | - | |
| 1812 | + | |
1813 | 1813 | | |
1814 | 1814 | | |
1815 | 1815 | | |
| |||
0 commit comments