Skip to content

Commit

Permalink
Docstring improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert committed Dec 20, 2024
1 parent 5841de7 commit 4e30275
Showing 1 changed file with 47 additions and 24 deletions.
71 changes: 47 additions & 24 deletions chatlas/_anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,30 +518,6 @@ def ChatBedrockAnthropic(
<https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html>
:::
::: {.callout-note}
## AWS model errors
#### Access
Be sure to activate your model in the `aws_region=` that you are using. If `aws_region=None` (default), the region is (https://github.com/anthropics/anthropic-sdk-python/blob/93cbbbde964e244f02bf1bd2b579c5fabce4e267/src/anthropic/lib/bedrock/_client.py#L136) set to `os.environ.get("AWS_REGION") or "us-east-1"`.
This default value will **not** respect to your AWS config's default region.
If the model is not activated in the same region, a similar error will be thrown: `Error code: 403 - {'message': "You don't have access to the model with the specified model ID."}`
#### Cross region inference ID
Use the "Cross Region" ID for your model. For example, if my model ID is `anthropic.claude-3-5-sonnet-20240620-v1:0`, then my cross region ID is `us.anthropic.claude-3-5-sonnet-20240620-v1:0`.
If the model ID is used directly, a similar error will be thrown: `Error code: 400 - {'message': 'Invocation of model ID anthropic.claude-3-5-sonnet-20240620-v1:0 with on-demand throughput isn’t supported. Retry your request with the ID or ARN of an inference profile that contains this model.'}`
#### Valid
If an incorrect model name is used, a similar error will be thrown: `Error code: 400 - {'message': 'The provided model identifier is invalid.'}`
Please be sure to copy the correct model's cross region ID.
:::
::: {.callout-note}
## Python requirements
Expand Down Expand Up @@ -599,6 +575,53 @@ def ChatBedrockAnthropic(
Additional arguments to pass to the `anthropic.AnthropicBedrock()`
client constructor.
Troubleshooting
---------------
If you encounter 400 or 403 errors when trying to use the model, keep the
following in mind:
::: {.callout-note}
#### Incorrect model name
If the model name is completely incorrect, you'll see an error like
`Error code: 400 - {'message': 'The provided model identifier is invalid.'}`
Make sure the model name is correct and active in the specified region.
:::
::: {.callout-note}
#### Models are region specific
If you encounter errors similar to `Error code: 403 - {'message': "You don't
have access to the model with the specified model ID."}`, make sure your
model is active in the relevant `aws_region`.
Keep in mind, if `aws_region` is not specified, and AWS_REGION is not set,
the region defaults to us-east-1, which may not match to your AWS config's
default region.
:::
::: {.callout-note}
#### Cross region inference ID
In some cases, even if you have the right model and the right region, you
may still encounter an error like `Error code: 400 - {'message':
'Invocation of model ID anthropic.claude-3-5-sonnet-20240620-v1:0 with
on-demand throughput isn't supported. Retry your request with the ID or ARN
of an inference profile that contains this model.'}`
In this case, you'll need to look up the 'cross region inference ID' for
your model. This might required opening your `aws-console` and navigating to
the 'Anthropic Bedrock' service page. From there, go to the 'cross region
inference' tab and copy the relevant ID.
For example, if the desired model ID is
`anthropic.claude-3-5-sonnet-20240620-v1:0`, the cross region ID might look
something like `us.anthropic.claude-3-5-sonnet-20240620-v1:0`.
:::
Returns
-------
Chat
Expand Down

0 comments on commit 4e30275

Please sign in to comment.