AzureOpenAIConfigBase Class
Internal class for configuring a connection to an Azure OpenAI service.
Internal class for configuring a connection to an Azure OpenAI service.
The validate_call decorator is used with a configuration that allows arbitrary types. This is necessary for types like HttpsUrl and OpenAIModelTypes.
- Inheritance
-
AzureOpenAIConfigBase
Constructor
AzureOpenAIConfigBase(deployment_name: str, ai_model_type: OpenAIModelTypes, endpoint: Annotated[Url, UrlConstraints(max_length=2083, allowed_schemes=['https'], host_required=None, default_host=None, default_port=None, default_path=None)] | None = None, base_url: Annotated[Url, UrlConstraints(max_length=2083, allowed_schemes=['https'], host_required=None, default_host=None, default_port=None, default_path=None)] | None = None, api_version: str = '2024-06-01', service_id: str | None = None, api_key: str | None = None, ad_token: str | None = None, ad_token_provider: Callable[[], str | Awaitable[str]] | None = None, default_headers: Mapping[str, str] | None = None, client: AsyncAzureOpenAI | None = None)
Parameters
Name | Description |
---|---|
deployment_name
Required
|
Name of the deployment. |
ai_model_type
Required
|
<xref:semantic_kernel.connectors.ai.open_ai.services.azure_config_base.OpenAIModelTypes>
The type of OpenAI model to deploy. |
endpoint
|
<xref:semantic_kernel.connectors.ai.open_ai.services.azure_config_base.HttpsUrl>
The specific endpoint URL for the deployment. (Optional) Default value: None
|
base_url
|
<xref:semantic_kernel.connectors.ai.open_ai.services.azure_config_base.HttpsUrl>
The base URL for Azure services. (Optional) Default value: None
|
api_version
|
Azure API version. Defaults to the defined DEFAULT_AZURE_API_VERSION. Default value: 2024-06-01
|
service_id
|
Service ID for the deployment. (Optional) Default value: None
|
api_key
|
API key for Azure services. (Optional) Default value: None
|
ad_token
|
Azure AD token for authentication. (Optional) Default value: None
|
ad_token_provider
|
A callable or coroutine function providing Azure AD tokens. (Optional) Default value: None
|
default_headers
|
Default headers for HTTP requests. (Optional) Default value: None
|
client
|
<xref:semantic_kernel.connectors.ai.open_ai.services.azure_config_base.AsyncAzureOpenAI>
An existing client to use. (Optional) Default value: None
|
Methods
to_dict |
Convert the configuration to a dictionary. |
to_dict
Convert the configuration to a dictionary.
to_dict() -> dict[str, str]
Attributes
model_computed_fields
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
model_config
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'populate_by_name': True, 'validate_assignment': True}
model_fields
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.fields from Pydantic V1.
model_fields: ClassVar[Dict[str, FieldInfo]] = {'ai_model_type': FieldInfo(annotation=OpenAIModelTypes, required=False, default=<OpenAIModelTypes.CHAT: 'chat'>), 'client': FieldInfo(annotation=AsyncOpenAI, required=True), 'completion_tokens': FieldInfo(annotation=int, required=False, default=0), 'prompt_tokens': FieldInfo(annotation=int, required=False, default=0), 'total_tokens': FieldInfo(annotation=int, required=False, default=0)}
ai_model_type
ai_model_type: OpenAIModelTypes
client
client: AsyncOpenAI
completion_tokens
completion_tokens: int
prompt_tokens
prompt_tokens: int
total_tokens
total_tokens: int