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
Select this option if this issue appears to be a regression.
Expected Behavior
The code returns the response from the Nova model without any errors returned.
Current Behavior
This error will be returned instead
An error occurred (ValidationException) when calling the InvokeModel operation: Malformed input request: #/messages/0/content/1: required key [toolUse] not found, please reformat your input and try again.
Reproduction Steps
with open(video_filepath, "rb") as video_file:
base64_text = base64.b64encode(video_file.read()).decode("utf-8")
try:
bedrock = boto3.client(service_name="bedrock-runtime", region_name=os.getenv('BEDROCK_REGION'))
body = [{
"role": "user",
"content": [
{
"text": "Can you get me the title for this video?"
},
{
"video": {
"format": "mp4",
"bytes": base64_text
}
}
]
}]
inf_params = {"maxTokens": 300, "topP": 0.9, "temperature": 0.7}
modelId = 'us.amazon.nova-lite-v1:0'
request_body = {
"schemaVersion": "messages-v1",
"messages": body,
"inferenceConfig": inf_params,
}
response = bedrock.invoke_model(modelId=modelId, body=json.dumps(request_body) )
print("response here")
print(response)
response_body = json.loads(response.get("body").read())
return response_body.get("content")
except Exception as e:
print(e)
exit()
logger.info("Claude Error:")
logger.info("Error: %s", e)
Another way to replicate the error is found here, but in this example it's uploading from S3 instead:
An error occurred (ValidationException) when calling the InvokeModel operation: Malformed input request: #/messages/0/content/1: required key [toolUse] not found, please reformat your input and try again.
is indeed confusing. In reality, the issue is not with a missing toolUse key, but rather with the incorrect structure of the request body.
The problem is that the source key is missing. Correcting this should resolve the issue.
Please note that this error message is generated by the endpoint itself, which means it is not specific to boto3; similar issues would occur with libraries in other languages as well.
This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
Describe the bug
I've hit an ValidationException error when trying to call the
invoke_model
function using boto3 and here's the code that I'm using currently:This example is based on the documentation provided in the Amazon Nova documentation.
Regression Issue
Expected Behavior
The code returns the response from the Nova model without any errors returned.
Current Behavior
This error will be returned instead
An error occurred (ValidationException) when calling the InvokeModel operation: Malformed input request: #/messages/0/content/1: required key [toolUse] not found, please reformat your input and try again.
Reproduction Steps
Another way to replicate the error is found here, but in this example it's uploading from S3 instead:
https://stackoverflow.com/questions/79364187/validationexception-malformed-input-request-when-using-invokemodel-with-amazon
Possible Solution
No response
Additional Information/Context
No response
SDK version used
1.34.62 (EDIT: Updated to 1.37.9, still facing the same issue)
Environment details (OS name and version, etc.)
Amazon Linux 2
The text was updated successfully, but these errors were encountered: