@@ -122,9 +122,9 @@ def _get_prompt_runnable(prompt: Prompt | None) -> Runnable:
122
122
lambda state : _get_state_value (state , "messages" ), name = PROMPT_RUNNABLE_NAME
123
123
)
124
124
elif isinstance (prompt , str ):
125
- _system_message : BaseMessage = SystemMessage (content = prompt )
125
+ system_message : BaseMessage = SystemMessage (content = prompt )
126
126
prompt_runnable = RunnableCallable (
127
- lambda state : [_system_message , * _get_state_value (state , "messages" )],
127
+ lambda state : [system_message , * _get_state_value (state , "messages" )],
128
128
name = PROMPT_RUNNABLE_NAME ,
129
129
)
130
130
elif isinstance (prompt , SystemMessage ):
@@ -220,7 +220,7 @@ def __init__(
220
220
"The `model` parameter should not have pre-bound tools, "
221
221
"simply pass the model and tools separately."
222
222
)
223
- raise ValueError (msg )
223
+ raise TypeError (msg )
224
224
225
225
self ._setup_tools ()
226
226
self ._setup_state_schema ()
@@ -397,13 +397,13 @@ def _handle_single_structured_output(
397
397
"structured_response" : structured_response ,
398
398
}
399
399
)
400
- except Exception as exc : # noqa: BLE001
400
+ except Exception as exc :
401
401
exception = StructuredOutputValidationError (tool_call ["name" ], exc )
402
402
403
403
should_retry , error_message = self ._handle_structured_output_error (exception )
404
404
405
405
if not should_retry :
406
- raise exception
406
+ raise exception from exc
407
407
408
408
return Command (
409
409
update = {
@@ -583,7 +583,7 @@ def _are_more_steps_needed(state: StateT, response: BaseMessage) -> bool:
583
583
remaining_steps is not None # type: ignore[return-value]
584
584
and (
585
585
(remaining_steps < 1 and all_tools_return_direct )
586
- or (remaining_steps < 2 and has_tool_calls )
586
+ or (remaining_steps < 2 and has_tool_calls ) # noqa: PLR2004
587
587
)
588
588
)
589
589
@@ -1188,7 +1188,7 @@ def check_weather(location: str) -> str:
1188
1188
response_format = ToolStrategy (
1189
1189
schema = response_format ,
1190
1190
)
1191
- elif isinstance (response_format , tuple ) and len (response_format ) == 2 :
1191
+ elif isinstance (response_format , tuple ) and len (response_format ) == 2 : # noqa: PLR2004
1192
1192
msg = "Passing a 2-tuple as response_format is no longer supported. "
1193
1193
raise ValueError (msg )
1194
1194
0 commit comments