Skip to content

Commit c9003bc

Browse files
committed
fix(process_response): use issubclass instead of isinstance for ParallelBase 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 #2049
1 parent c6f9ef5 commit c9003bc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

instructor/processing/response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ async def process_response_async(
263263
raw_response=response,
264264
)
265265

266-
if isinstance(response_model, ParallelBase):
266+
if inspect.isclass(response_model) and issubclass(response_model, ParallelBase):
267267
logger.debug(f"Returning model from ParallelBase")
268268
model._raw_response = response
269269
return model
@@ -381,7 +381,7 @@ class to parse the response into. Special DSL types supported:
381381
raw_response=response,
382382
)
383383

384-
if isinstance(response_model, ParallelBase):
384+
if inspect.isclass(response_model) and issubclass(response_model, ParallelBase):
385385
logger.debug(f"Returning model from ParallelBase")
386386
model._raw_response = response
387387
return model

0 commit comments

Comments
 (0)