@@ -268,7 +268,7 @@ class Joke(BaseModel):
268
268
max_tokens : Optional [int ] = None
269
269
"""Max tokens to generate."""
270
270
271
- stop_sequences : Optional [List [str ]] = Field (default = None , alias = "stop" )
271
+ stop_sequences : Optional [List [str ]] = Field (None , alias = "stop" )
272
272
"""Stop generation if any of these substrings occurs."""
273
273
274
274
temperature : Optional [float ] = None
@@ -308,12 +308,17 @@ class Joke(BaseModel):
308
308
have an ARN associated with them.
309
309
"""
310
310
311
- endpoint_url : Optional [str ] = Field (default = None , alias = "base_url" )
311
+ endpoint_url : Optional [str ] = Field (None , alias = "base_url" )
312
312
"""Needed if you don't want to default to us-east-1 endpoint"""
313
313
314
314
config : Any = None
315
315
"""An optional botocore.config.Config instance to pass to the client."""
316
316
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
+
317
322
class Config :
318
323
"""Configuration for this pydantic object."""
319
324
@@ -413,7 +418,8 @@ def bind_tools(
413
418
) -> Runnable [LanguageModelInput , BaseMessage ]:
414
419
if tool_choice :
415
420
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 )
417
423
418
424
def with_structured_output (
419
425
self ,
@@ -467,7 +473,7 @@ def _converse_params(
467
473
}
468
474
if not toolConfig and tools :
469
475
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 }
471
477
return _drop_none (
472
478
{
473
479
"modelId" : modelId or self .model_id ,
0 commit comments