Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation Exception : Invalid Request when calling start_async_invoke [bedrock-runtime] #4382

Open
1 task
gshr opened this issue Jan 3, 2025 · 0 comments
Open
1 task
Labels
bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged.

Comments

@gshr
Copy link

gshr commented Jan 3, 2025

Describe the bug

I am using boto3 to connect bedrock-runtime and invoke model mistral.mistral-small-2402-v1:0 using start_async_invoke. However , the error message occur when i execute the code

ERROR:root:Failed to start async invoke: An error occurred (ValidationException) when calling the StartAsyncInvoke operation: The provided request is not valid
ERROR:root:An error occurred: An error occurred (ValidationException) when calling the StartAsyncInvoke operation: The provided request is not valid

And this is my implementation:

import boto3
import json
import uuid
import logging

logging.basicConfig(level=logging.INFO)

def invoke_async(prompt: str, s3_uri: str):
    try:
        client = boto3.client('bedrock-runtime', region_name='us-east-1')
        request_token = str(uuid.uuid4())

        model_input = {
            "prompt": f"<s>[INST] {prompt} [/INST]",
            "max_tokens": 200
        }


        response = client.start_async_invoke(
            clientRequestToken=request_token,
            modelId="mistral.mistral-small-2402-v1:0",
            modelInput=json.dumps(model_input),
            outputDataConfig={
                's3OutputDataConfig': {
                    's3Uri': s3_uri
                }
            }
        )
        print(response)

        logging.info(f"Task started. Request token: {request_token}")
        return request_token
    except Exception as e:
        logging.error(f"Failed to start async invoke: {e}")
        raise

if __name__ == "__main__":
    try:
        invoke_async(
            prompt="What is artificial intelligence?",
            s3_uri="s3://bucket-name/"
        )
    except Exception as e:
        logging.error(f"An error occurred: {e}")

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

Success Response from api

Current Behavior

INFO:botocore.credentials:Found credentials in shared credentials file: ~/.aws/credentials
ERROR:root:Failed to start async invoke: An error occurred (ValidationException) when calling the StartAsyncInvoke operation: The provided request is not valid
ERROR:root:An error occurred: An error occurred (ValidationException) when calling the StartAsyncInvoke operation: The provided request is not valid

Reproduction Steps

Replace s3_uri with your bucket in implementation above

Possible Solution

No response

Additional Information/Context

No response

SDK version used

1.35.91

Environment details (OS name and version, etc.)

macOS

@gshr gshr added bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged. labels Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant