fix(process_response): use issubclass instead of isinstance for ParallelBase check#2058
Open
Mr-Neutr0n wants to merge 1 commit into567-labs:mainfrom
Open
fix(process_response): use issubclass instead of isinstance for ParallelBase check#2058Mr-Neutr0n wants to merge 1 commit into567-labs:mainfrom
Mr-Neutr0n wants to merge 1 commit into567-labs:mainfrom
Conversation
…lelBase check The response_model parameter is a class (type), not an instance. Using isinstance() on a class checks if that class is an instance of a type, which always returns False for user-defined classes. Changed from: if isinstance(response_model, ParallelBase): To: if inspect.isclass(response_model) and issubclass(response_model, ParallelBase): This fixes the "'generator' object has no attribute '_raw_response'" error when using ParallelTools with models like Qwen3-VL. Fixes 567-labs#2049
Author
|
Friendly follow-up - is there anything I can improve in this PR? Happy to address any feedback. |
Author
|
Friendly bump! Let me know if there's anything I should update or improve to help move this forward. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the bug where ParallelTools fails with:
Root Cause
In
process_response.py, the code usesisinstance(response_model, ParallelBase)butresponse_modelis a class (type), not an instance. Usingisinstance()on a class type checks if that class object itself is an instance of a metaclass, which is not the intended behavior.Before (incorrect):
After (correct):
Changes
instructor/processing/response.py: Fixed both occurrences (line 266 and 384) of the incorrectisinstancecheckTest Plan
This should resolve the error when using ParallelTools with models like Qwen3-VL.
Fixes #2049