This PR addresses the following problems found while testing the new converse endpoint with anthropic tools:
Found some fields that might have been typos (e.g., toolUseID vs toolUseId) boto3 docs
Found an issue where bedrock returns the input values for the tool as string instead of a JSON (dict), added a function to attempt to convert it and on JSON decode error, return the original value.
Found another issue where the current _snake_to_camel_keys function will attempt to convert the input values for the tool. The problem seems to be that we are calling the _format_tools twice. An easy way to fix it is to add a property to the ChatBedrockConverse so we keep the formatted_tools, that way we only format them once. I have done that and marked the property as excluded from dumping to avoid any compatibility problems.
{
"input": "Take 3 to the fifth power and multiply that by the sum of twelve and three, then square the whole result",
"conversation_id": null,
"chat_history": [],
"output": [
{
"type": "text",
"text": "So the final result of taking 3 to the 5th power (243), multiplying by 12 + 3 (15) to get 3645, and then squaring that is 13286025.",
"index": 0
}
]
}
This PR addresses the following problems found while testing the new converse endpoint with anthropic tools:
toolUseID
vstoolUseId
) boto3 docs_snake_to_camel_keys
function will attempt to convert the input values for the tool. The problem seems to be that we are calling the_format_tools
twice. An easy way to fix it is to add a property to the ChatBedrockConverse so we keep the formatted_tools, that way we only format them once. I have done that and marked the property as excluded from dumping to avoid any compatibility problems.With these changes, I was able to run the https://python.langchain.com/v0.1/docs/use_cases/tool_use/multiple_tools/ example with bedrock, using anthropic.