provider_adapter
Provider adapter abstractions.
This module defines the shared abstract base class used to implement provider-specific chat client adapters.
A provider adapter is responsible for:
- validating that a model configuration object is compatible with the provider
- performing any provider-specific setup before client creation
- constructing a Microsoft Agent Framework chat client instance directly from the user-supplied model configuration
ProviderAdapter
Bases: ABC
Abstract base class for provider-specific chat client adapters.
Attributes:
| Name | Type | Description |
|---|---|---|
provider_name |
str
|
Name of the provider handled by the adapter. |
chat_client |
Type[BaseChatClient]
|
Chat client class used to instantiate provider-specific clients. |
Methods:
| Name | Description |
|---|---|
validate_model_config |
Validate a model configuration before client creation. |
pre_create |
Perform provider-specific setup before client creation. |
create_client |
Validate configuration and create a chat client instance. |
Source code in src/mada/core/chat_clients/provider_adapter.py
create_client(model_config)
Create a provider-specific chat client from a model configuration.
This method validates the configuration, executes any provider-specific pre-creation hook, and instantiates the configured chat client using the exact user-supplied model name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_config
|
BaseModelConfig
|
Model configuration used to build the client. |
required |
Returns:
| Type | Description |
|---|---|
BaseChatClient
|
An initialized provider-specific chat client. |
Source code in src/mada/core/chat_clients/provider_adapter.py
pre_create(model_config)
Run provider-specific logic before constructing the chat client.
This hook allows subclasses to inspect configuration or perform setup before the client instance is created.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_config
|
BaseModelConfig
|
Model configuration being used to create the client. |
required |
Source code in src/mada/core/chat_clients/provider_adapter.py
validate_model_config(model_config)
abstractmethod
Validate a model configuration for this provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_config
|
BaseModelConfig
|
Model configuration to validate. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the configuration is invalid for the provider. |