bedrock_adapter
AWS Bedrock provider adapter implementation.
This module defines BedrockAdapter,
a ProviderAdapter implementation
for AWS Bedrock chat models. It validates that incoming model configuration objects are
instances of BedrockModelConfig and prepares
AWS authentication environment variables before chat client creation.
BedrockAdapter
Bases: ProviderAdapter
Provider adapter for AWS Bedrock chat models.
This adapter validates Bedrock-specific model configuration objects and sets AWS credential-related environment variables before constructing a chat client.
Attributes:
| Name | Type | Description |
|---|---|---|
provider_name |
Name of the provider handled by this adapter. |
|
chat_client |
Chat client class used to create Bedrock chat clients. |
Methods:
| Name | Description |
|---|---|
validate_model_config |
Validate that |
_set_env_if_allowed |
Set an environment variable if permitted by the current configuration. |
pre_create |
Apply environment-based credential configuration before client creation. |
Source code in src/mada/core/chat_clients/bedrock_adapter.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
pre_create(model_config)
Prepare AWS credential environment variables before client creation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_config
|
BedrockModelConfig
|
Bedrock model configuration containing credential values and override settings. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
Raised if an existing environment variable would be overwritten without permission. |
Source code in src/mada/core/chat_clients/bedrock_adapter.py
validate_model_config(model_config)
Validate that model_config is compatible with the Bedrock adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_config
|
BaseModelConfig
|
Model configuration to validate. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised if |