|
3 | 3 | from aisuite.framework import ChatCompletionResponse
|
4 | 4 |
|
5 | 5 |
|
6 |
| -# Used to call the AWS Bedrock converse API |
7 |
| -# Converse API provides consistent API, that works with all Amazon Bedrock models that support messages. |
8 |
| -# Eg: anthropic.claude-v2, |
9 |
| -# meta.llama3-70b-instruct-v1:0, |
10 |
| -# mistral.mixtral-8x7b-instruct-v0:1 |
11 |
| -# The model value can be a baseModelId or provisionedModelArn. |
12 |
| -# Using a base model id gives on-demand throughput. |
13 |
| -# Use CreateProvisionedModelThroughput API to get provisionedModelArn for higher throughput. |
14 |
| -# https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids.html |
15 | 6 | class AWSBedrockProvider(Provider):
|
16 | 7 | def __init__(self, **config):
|
17 | 8 | """
|
18 | 9 | Initialize the AWS Bedrock provider with the given configuration.
|
19 |
| - Pass the entire configuration dictionary to the Anthropic Bedrock client constructor. |
| 10 | +
|
| 11 | + This class uses the AWS Bedrock converse API, which provides a consistent interface |
| 12 | + for all Amazon Bedrock models that support messages. Examples include: |
| 13 | + - anthropic.claude-v2 |
| 14 | + - meta.llama3-70b-instruct-v1:0 |
| 15 | + - mistral.mixtral-8x7b-instruct-v0:1 |
| 16 | +
|
| 17 | + The model value can be a baseModelId for on-demand throughput or a provisionedModelArn |
| 18 | + for higher throughput. To obtain a provisionedModelArn, use the CreateProvisionedModelThroughput API. |
| 19 | +
|
| 20 | + For more information on model IDs, see: |
| 21 | + https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids.html |
| 22 | +
|
| 23 | + Note: |
| 24 | + - The Anthropic Bedrock client uses default AWS credential providers, such as |
| 25 | + ~/.aws/credentials or the "AWS_SECRET_ACCESS_KEY" and "AWS_ACCESS_KEY_ID" environment variables. |
| 26 | + - If the region is not set, it defaults to us-west-1, which may lead to a |
| 27 | + "Could not connect to the endpoint URL" error. |
| 28 | + - The client constructor does not accept additional parameters. |
| 29 | +
|
| 30 | + Args: |
| 31 | + **config: Configuration options for the provider. |
| 32 | +
|
20 | 33 | """
|
21 |
| - # Anthropic Bedrock client will use the default AWS credential providers, such as |
22 |
| - # using ~/.aws/credentials or the "AWS_SECRET_ACCESS_KEY" and "AWS_ACCESS_KEY_ID" environment variables. |
23 |
| - # If region is not set, it will use a default to us-west-1 which can lead to error - |
24 |
| - # "Could not connect to the endpoint URL" |
25 |
| - # It does not like parameters passed to the constructor. |
26 | 34 | self.client = boto3.client("bedrock-runtime", region_name="us-west-2")
|
27 |
| - # Maintain a list of Inference Parameters which Bedrock supports. |
28 |
| - # https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InferenceConfiguration.html |
29 | 35 | self.inference_parameters = [
|
30 | 36 | "maxTokens",
|
31 | 37 | "temperature",
|
|
0 commit comments