models
Model configuration classes and loading utilities.
This module defines configuration dataclasses used to describe provider-specific model settings for chat client creation. It includes base configuration behavior, OpenAI-compatible configuration, AWS Bedrock configuration, and a helper function for loading the appropriate configuration type from a dictionary.
BaseModelConfig
dataclass
Base configuration for provider model settings.
This class stores common configuration fields shared across provider implementations and defines the interface for validation and conversion into chat client keyword arguments.
Attributes:
| Name | Type | Description |
|---|---|---|
provider |
str
|
Name of the provider associated with the model configuration. |
model |
str
|
Requested model name. |
extra |
Dict[str, Any]
|
Additional provider-specific keyword arguments to pass to the chat client. |
Methods:
| Name | Description |
|---|---|
__post_init__ |
Expand environment variables in common configuration fields. |
validate |
Validate the configuration. |
to_client_kwargs |
Convert the configuration into keyword arguments for chat client construction. |
Source code in src/mada/core/config/models.py
__post_init__()
Expand environment variables in shared configuration fields.
to_client_kwargs()
Convert the configuration into chat client keyword arguments.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
A dictionary of keyword arguments for chat client construction. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Raised if the subclass does not implement this method. |
Source code in src/mada/core/config/models.py
validate()
Validate the configuration.
Subclasses should override this method to implement provider-specific validation rules.
BedrockModelConfig
dataclass
Bases: BaseModelConfig
Configuration for AWS Bedrock chat clients.
This configuration supports multiple authentication styles, including bearer-token authentication, AWS profile-based authentication, and direct AWS credential values.
Attributes:
| Name | Type | Description |
|---|---|---|
provider |
str
|
Name of the provider associated with the model configuration. |
model |
str
|
Requested model name. |
extra |
Dict[str, Any]
|
Additional provider-specific keyword arguments to pass to the chat client. |
region |
str
|
AWS region for the Bedrock service. |
bearer_token |
Optional[str]
|
Optional bearer token value, or path to a file containing the token. |
aws_profile |
Optional[str]
|
Optional AWS profile name. |
aws_access_key_id |
Optional[str]
|
Optional AWS access key ID. |
aws_secret_access_key |
Optional[str]
|
Optional AWS secret access key. |
aws_session_token |
Optional[str]
|
Optional AWS session token. |
override_env_credentials |
bool
|
Whether adapter setup may overwrite existing AWS credential-related environment variables. |
Methods:
| Name | Description |
|---|---|
__post_init__ |
Expand environment variables, resolve file-based bearer tokens, and validate the configuration. |
validate |
Validate required Bedrock region and authentication settings. |
to_client_kwargs |
Convert the configuration into keyword arguments for a Bedrock chat client. |
Source code in src/mada/core/config/models.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
__post_init__()
Expand environment variables, resolve file-based bearer tokens, and validate the configuration.
Source code in src/mada/core/config/models.py
to_client_kwargs()
Convert the configuration into Bedrock chat client keyword arguments.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
A dictionary of keyword arguments for Bedrock chat client |
Dict[str, Any]
|
construction. |
Source code in src/mada/core/config/models.py
validate()
Validate required Bedrock configuration values and authentication settings.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
Raised if |
Source code in src/mada/core/config/models.py
OpenAIModelConfig
dataclass
Bases: BaseModelConfig
Configuration for OpenAI-compatible chat clients.
This configuration supports literal API keys, environment-variable-expanded values, or file paths containing API keys, along with the base URL for the target service.
Attributes:
| Name | Type | Description |
|---|---|---|
provider |
str
|
Name of the provider associated with the model configuration. |
model |
str
|
Requested model name. |
extra |
Dict[str, Any]
|
Additional provider-specific keyword arguments to pass to the chat client. |
api_key |
str
|
API key value, environment-expanded string, or path to a file containing the API key. |
base_url |
str
|
Base URL for the OpenAI-compatible endpoint. |
Methods:
| Name | Description |
|---|---|
__post_init__ |
Expand environment variables, resolve file-based API keys, and validate the configuration. |
validate |
Validate that required OpenAI-compatible settings are present. |
to_client_kwargs |
Convert the configuration into keyword arguments for an OpenAI-compatible chat client. |
Source code in src/mada/core/config/models.py
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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
__post_init__()
Expand environment variables, resolve file-based API keys, and validate the configuration.
Source code in src/mada/core/config/models.py
to_client_kwargs()
Convert the configuration into OpenAI-compatible chat client keyword arguments.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
A dictionary of keyword arguments for OpenAI-compatible chat client |
Dict[str, Any]
|
construction. |
Source code in src/mada/core/config/models.py
validate()
Validate required OpenAI-compatible configuration values.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
Raised if |
Source code in src/mada/core/config/models.py
load_model_config(config_dict)
Load a provider-specific model configuration object from a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_dict
|
Dict[str, Any]
|
Dictionary containing serialized model configuration values. |
required |
Returns:
| Type | Description |
|---|---|
ModelConfig
|
An initialized provider-specific model configuration instance. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Raised if |