You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Simulate a Bedrock Converse response with a bash tool call
484
-
response_json= {
485
-
"additionalModelResponseFields": {},
486
-
"metrics": {"latencyMs": 100.0},
487
-
"output": {
488
-
"message": {
489
-
"role": "assistant",
490
-
"content": [
491
-
{
492
-
"toolUse": {
493
-
"toolUseId": "tooluse_456",
494
-
"name": "json_tool_call",
495
-
"input": {
496
-
"Current_Temperature": 62,
497
-
"Weather_Explanation": "San Francisco typically has mild, cool weather year-round due to its coastal location and marine influence. The city is known for its fog, moderate temperatures, and relatively stable climate with little seasonal variation."},
498
-
}
499
-
}
500
-
]
501
-
}
502
-
},
503
-
"stopReason": "tool_use",
504
-
"usage": {
505
-
"inputTokens": 8,
506
-
"outputTokens": 3,
507
-
"totalTokens": 11,
508
-
"cacheReadInputTokenCount": 0,
509
-
"cacheReadInputTokens": 0,
510
-
"cacheWriteInputTokenCount": 0,
511
-
"cacheWriteInputTokens": 0,
512
-
},
513
-
}
514
-
# Mock httpx.Response
515
-
classMockResponse:
516
-
defjson(self):
517
-
returnresponse_json
518
-
@property
519
-
deftext(self):
520
-
returnjson.dumps(response_json)
521
-
522
-
config=AmazonConverseConfig()
523
-
model_response=ModelResponse()
524
-
optional_params= {
525
-
"json_mode": True,
526
-
"tools": [
527
-
{
528
-
'type': 'function',
529
-
'function': {
530
-
'name': 'get_weather',
531
-
'description': 'Get the current weather in a given location',
532
-
'parameters': {
533
-
'type': 'object',
534
-
'properties': {
535
-
'location': {
536
-
'type': 'string',
537
-
'description': 'The city and state, e.g. San Francisco, CA'
# Check that the tool call is present in the returned message
586
-
assertresult.choices[0].message.tool_callsisNone
587
-
588
-
assertresult.choices[0].message.contentisnotNone
589
-
assertresult.choices[0].message.content=='{"Current_Temperature": 62, "Weather_Explanation": "San Francisco typically has mild, cool weather year-round due to its coastal location and marine influence. The city is known for its fog, moderate temperatures, and relatively stable climate with little seasonal variation."}'
0 commit comments