I’m using Bedrock and accessing Claude for a RAG application via a lambda function written in Python. Feel like I’m missing a configuration step and wondered if someone has run into this. Summary is unless I truncate the input prompt to under 20,000 chars then I get the following error:
error occurred (ValidationException) when calling the InvokeModel operation: Input is too long for requested model.
Doesn’t make much sense as context window is 200K tokens for Claude which I’m using.
anthropic_payload = {
"anthropic_version": "bedrock-2023-05-31",
"max_tokens": 25000,
"temperature": 0.5,
"messages":promptMessages
}
anthropic_payload = {"anthropic_version": "bedrock-2023-05-31","max_tokens": 25000,"temperature": 0.5,"messages":promptMessages}
anthropic_modelid = "anthropic.claude-3-sonnet-20240229-v1:0"
response = client_bedrock.invoke_model(modelId=anthropic_modelid, contentType='application/json',accept='application/json',body=json.dumps(anthropic_payload))
Where “promptMessages” in an array of messages with the first message including a “<document> ….</document> that is a text representation of a number of different file formats uploaded to S3
I tried truncated string len and it worked. Full text fails.