aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
3.03k stars 569 forks source link

InvokeModelCommand does not accept anthropic.claude-v2:1:200k as a model ID #5665

Closed ataylorme closed 8 months ago

ataylorme commented 8 months ago

Checkboxes for prior research

Describe the bug

When calling the InvokeModelCommand command with modelId: anthropic.claude-v2:1:200k a validation error is returned

Error invoking the Claude model with AWS Bedrock ValidationException: 1 validation error detected: Value 'anthropic.claude-v2:1:200k' at 'modelId' failed to satisfy constraint: Member must satisfy regular expression pattern: (arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:(([0-9]{12}:custom-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}/[a-z0-9]{12})|(:foundation-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))|([0-9]{12}:provisioned-model/[a-z0-9]{12})))|([a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))|(([0-9a-zA-Z][_-]?)+)

anthropic.claude-v2:1:200k is in the list of models when calling list foundational models from AWS Bedrock

SDK version number

@aws-sdk/client-bedrock-runtime@3.489.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v18.16.1

Reproduction Steps

const params: InvokeModelCommandInputType = {
   body,
   modelId: 'anthropic.claude-v2:1:200k',
   contentType: 'application/json',
  accept: 'application/json',
}
const command = new InvokeModelCommand(params)
const data = await client.send(command)

Observed Behavior

Error invoking the Claude model with AWS Bedrock ValidationException: 1 validation error detected: Value 'anthropic.claude-v2:1:200k' at 'modelId' failed to satisfy constraint: Member must satisfy regular expression pattern: (arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:(([0-9]{12}:custom-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}/[a-z0-9]{12})|(:foundation-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))|([0-9]{12}:provisioned-model/[a-z0-9]{12})))|([a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))|(([0-9a-zA-Z][_-]?)+)

Expected Behavior

The command is successful

Possible Solution

No response

Additional Information/Context

No response

aBurmeseDev commented 8 months ago

Hi @ataylorme - thanks for reaching out!

It looks like you're getting service exception around modelID param and according to the docs on the list of base model available, you might be using Anthropic Claude v2 model. In that case, you'd use anthropic.claude-v2 as model ID param, also shown in the table.

Please refer to the docs on other type of models.

The modelId to provide in the header depends on the type of model that you use.

If you use a base model, specify the model ID or its ARN.

If you use a provisioned model, specify the provisionedModelName or the provisionedModelArn that was returned from the creation of the Provisioned Throughput.

If you use a custom model, first purchase Provisioned Throughput for it (for more information, see Provisioned throughput in the Amazon Bedrock User Guide). Then specify the provisionedModelName or the provisionedModelArn that was returned from the creation of the Provisioned Throughput.

Hope it helps, John

ataylorme commented 8 months ago

Thanks for the response John! I didn’t realize provisioned throughout models had to be created and then the ARN sent instead of a model ID.

I will give that a try and re-open this issue if it isn’t working.

github-actions[bot] commented 7 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.