Commit fd6268b
authored
Fix AttributeError: 'NoneType' object has no attribute 'lower' that
occurs when model_name is None (common with Azure OpenAI deployments).
The issue manifests when a None model_name propagates to langchain's
standardize_model_name() which calls .lower() on it without null-checking.
Changes:
- handle_wrapped_call: Check bindings.arguments as fallback, fall back
to response.model when model is None
- _handle_response: Guard model_name to ensure it is always a string
- handle_generation_chunk: Guard response.model with 'or empty string'
- OpenAICostComputer.handle_response: Guard first_chunk.model
Add 11 unit tests covering both non-OTEL and OTEL code paths.
Co-authored-by: sfc-gh-jreini <sfc-gh-jreini@users.noreply.github.com>
1 parent 0e2964b commit fd6268b
File tree
2 files changed
+491
-2
lines changed- src/providers/openai/trulens/providers/openai
- tests/unit
2 files changed
+491
-2
lines changedLines changed: 17 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
334 | | - | |
| 334 | + | |
| 335 | + | |
335 | 336 | | |
336 | 337 | | |
337 | 338 | | |
| |||
455 | 456 | | |
456 | 457 | | |
457 | 458 | | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
458 | 468 | | |
459 | 469 | | |
460 | 470 | | |
| |||
474 | 484 | | |
475 | 485 | | |
476 | 486 | | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
477 | 492 | | |
478 | 493 | | |
479 | 494 | | |
| |||
0 commit comments