From 5841de70254c22989864f52978c6d2e6ce88e131 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Fri, 20 Dec 2024 12:39:42 -0500 Subject: [PATCH 1/2] Add more FAQ content on error messages --- chatlas/_anthropic.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/chatlas/_anthropic.py b/chatlas/_anthropic.py index bdb6cbb6..500c1f23 100644 --- a/chatlas/_anthropic.py +++ b/chatlas/_anthropic.py @@ -518,6 +518,30 @@ def ChatBedrockAnthropic( ::: + ::: {.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 From 4e302757fc365f3903bfebfbfda40c7345d8dc62 Mon Sep 17 00:00:00 2001 From: Carson Date: Fri, 20 Dec 2024 17:43:57 -0600 Subject: [PATCH 2/2] Docstring improvements --- chatlas/_anthropic.py | 71 ++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/chatlas/_anthropic.py b/chatlas/_anthropic.py index 500c1f23..8c9294ad 100644 --- a/chatlas/_anthropic.py +++ b/chatlas/_anthropic.py @@ -518,30 +518,6 @@ def ChatBedrockAnthropic( ::: - ::: {.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 @@ -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