Commit 2f9c043
authored
fix(openai): reask functionality broken in JSON mode since v1.9.0 (#1793)
Since v1.9.0, from this PR:
#1549, the reask
functionality with JSON mode is broken.
Irrespective of whether the underlying error is a `JSONDecodeError` or
`ValidationError`, both are being wrapped under
`instructor.core.exceptions.ValidationError`
Hence in `retry_sync`/`retry_async` of `instructor/core/retry.py`, these
wrapped errors are always caught by the generic `Exception` block
instead of the specific `(ValidationError, JSONDecodeError)` block, even
when those specific exception types should trigger retries with error
messages included
<!-- ELLIPSIS_HIDDEN -->
----
> [!IMPORTANT]
> Fixes reask functionality in JSON mode by removing exception wrapping
in `_validate_model_from_json()` to allow specific exception handling.
>
> - **Behavior**:
> - Fixes reask functionality in JSON mode by removing exception
wrapping in `_validate_model_from_json()` in `function_calls.py`.
> - Allows `JSONDecodeError` and `ValidationError` to be caught
specifically in `retry_sync`/`retry_async` in `retry.py`.
> - **Exceptions**:
> - Removes wrapping of exceptions in
`instructor.core.exceptions.ValidationError` in
`_validate_model_from_json()`.
> - **Logging**:
> - Retains debug logging for JSON decode and model validation errors in
`_validate_model_from_json()`.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=567-labs%2Finstructor&utm_source=github&utm_medium=referral)<sup>
for b6a47d9. You can
[customize](https://app.ellipsis.dev/567-labs/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>
<!-- ELLIPSIS_HIDDEN -->1 file changed
+1
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
| 98 | + | |
104 | 99 | | |
105 | 100 | | |
106 | 101 | | |
| |||
0 commit comments