@@ -221,30 +221,27 @@ async def _handle_structured_output(
221221 self , input : ChatPromptValue , model_params : ModelParams , ** kwargs : Any
222222 ) -> Optional [ModelResponse ]:
223223 """Handle structured output generation"""
224- lock = await self ._get_lock ()
225- # Re-entry prevention using asyncio locking
226- async with lock :
227- pydantic_model = self .structured_output .get_pydantic_model ()
228- if not pydantic_model :
229- logger .warning (
230- "Structured output enabled but no valid schema found, falling back to regular generation"
231- )
232- # Return a flag to signal that regular generation should be used
233- return None
224+ pydantic_model = self .structured_output .get_pydantic_model ()
225+ if not pydantic_model :
226+ logger .warning (
227+ "Structured output enabled but no valid schema found, falling back to regular generation"
228+ )
229+ # Return a flag to signal that regular generation should be used
230+ return None
234231
235- # Check if model supports native structured output
236- if self ._supports_native_structured_output ():
237- logger .info (f"Using native structured output for { self .name ()} " )
238- return await self ._generate_native_structured_output (
239- input , model_params , pydantic_model , ** kwargs
240- )
241- else :
242- logger .info (f"Using fallback structured output for { self .name ()} " )
243- # Get response from fallback method
244- model_response : ModelResponse = await self ._generate_fallback_structured_output (
245- input , model_params , pydantic_model , ** kwargs
246- )
247- return model_response
232+ # Check if model supports native structured output
233+ if self ._supports_native_structured_output ():
234+ logger .info (f"Using native structured output for { self .name ()} " )
235+ return await self ._generate_native_structured_output (
236+ input , model_params , pydantic_model , ** kwargs
237+ )
238+ else :
239+ logger .info (f"Using fallback structured output for { self .name ()} " )
240+ # Get response from fallback method
241+ model_response : ModelResponse = await self ._generate_fallback_structured_output (
242+ input , model_params , pydantic_model , ** kwargs
243+ )
244+ return model_response
248245
249246 def _supports_native_structured_output (self ) -> bool :
250247 """Check if the model supports native structured output"""
0 commit comments