@@ -268,7 +268,7 @@ class Joke(BaseModel):
268268 max_tokens : Optional [int ] = None
269269 """Max tokens to generate."""
270270
271- stop_sequences : Optional [List [str ]] = Field (default = None , alias = "stop" )
271+ stop_sequences : Optional [List [str ]] = Field (None , alias = "stop" )
272272 """Stop generation if any of these substrings occurs."""
273273
274274 temperature : Optional [float ] = None
@@ -290,7 +290,7 @@ class Joke(BaseModel):
290290 in case it is not provided here.
291291 """
292292
293- credentials_profile_name : Optional [str ] = Field (default = None , exclude = True )
293+ credentials_profile_name : Optional [str ] = Field (None , exclude = True )
294294 """The name of the profile in the ~/.aws/credentials or ~/.aws/config files.
295295
296296 Profile should either have access keys or role information specified.
@@ -314,6 +314,11 @@ class Joke(BaseModel):
314314 config : Any = None
315315 """An optional botocore.config.Config instance to pass to the client."""
316316
317+ formatted_tools : List [
318+ Dict [Literal ["toolSpec" ], Dict [str , Union [Dict [str , Any ], str ]]]
319+ ] = Field (default_factory = list , exclude = True )
320+ """"Formatted tools to be stored and used in the toolConfig parameter."""
321+
317322 class Config :
318323 """Configuration for this pydantic object."""
319324
@@ -413,7 +418,8 @@ def bind_tools(
413418 ) -> Runnable [LanguageModelInput , BaseMessage ]:
414419 if tool_choice :
415420 kwargs ["tool_choice" ] = _format_tool_choice (tool_choice )
416- return self .bind (tools = _format_tools (tools ), ** kwargs )
421+ self .formatted_tools = _format_tools (tools )
422+ return self .bind (tools = self .formatted_tools , ** kwargs )
417423
418424 def with_structured_output (
419425 self ,
@@ -467,7 +473,7 @@ def _converse_params(
467473 }
468474 if not toolConfig and tools :
469475 toolChoice = _format_tool_choice (toolChoice ) if toolChoice else None
470- toolConfig = {"tools" : _format_tools ( tools ) , "toolChoice" : toolChoice }
476+ toolConfig = {"tools" : self . formatted_tools , "toolChoice" : toolChoice }
471477 return _drop_none (
472478 {
473479 "modelId" : modelId or self .model_id ,
0 commit comments