AzureTextEmbedding Class

Azure Text Embedding class.

Note: This class is experimental and may change in the future.

Initialize an AzureTextEmbedding service.

service_id: The service ID. (Optional) api_key {str | None}: The optional api key. If provided, will override the value in the

env vars or .env file.

deployment_name {str | None}: The optional deployment. If provided, will override the value (text_deployment_name) in the env vars or .env file.

endpoint {str | None}: The optional deployment endpoint. If provided will override the value in the env vars or .env file.

base_url {str | None}: The optional deployment base_url. If provided will override the value in the env vars or .env file.

api_version {str | None}: The optional deployment api version. If provided will override the value in the env vars or .env file.

ad_token {str | None}: The Azure AD token for authentication. (Optional) ad_auth {AsyncAzureADTokenProvider | None}: Whether to use Azure Active Directory authentication.

(Optional) The default value is False.

default_headers: The default headers mapping of string keys to string values for HTTP requests. (Optional)

async_client (Optional[AsyncAzureOpenAI]): An existing client to use. (Optional) env_file_path (str | None): Use the environment settings file as a fallback to

environment variables. (Optional)

Inheritance
AzureTextEmbedding
AzureTextEmbedding

Constructor

AzureTextEmbedding(service_id: str | None = None, api_key: str | None = None, deployment_name: str | None = None, endpoint: str | None = None, base_url: str | None = None, api_version: str | None = None, ad_token: str | None = None, ad_token_provider: Callable[[], str | Awaitable[str]] | None = None, default_headers: Mapping[str, str] | None = None, async_client: AsyncAzureOpenAI | None = None, env_file_path: str | None = None)

Parameters

Name Description
service_id
Default value: None
api_key
Default value: None
deployment_name
Default value: None
endpoint
Default value: None
base_url
Default value: None
api_version
Default value: None
ad_token
Default value: None
ad_token_provider
Default value: None
default_headers
Default value: None
async_client
Default value: None
env_file_path
Default value: None

Methods

from_dict

Initialize an Azure OpenAI service from a dictionary of settings.

from_dict

Initialize an Azure OpenAI service from a dictionary of settings.

from_dict(settings: dict[str, Any]) -> AzureTextEmbedding

Parameters

Name Description
settings
Required

A dictionary of settings for the service. should contain keys: deployment_name, endpoint, api_key and optionally: api_version, ad_auth

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_id': FieldInfo(annotation=str, required=True, metadata=[StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)]), '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), 'service_id': FieldInfo(annotation=str, required=False, default=''), 'total_tokens': FieldInfo(annotation=int, required=False, default=0)}

ai_model_type

ai_model_type: OpenAIModelTypes

client

client: AsyncOpenAI

completion_tokens

completion_tokens: int

is_experimental

is_experimental = True

prompt_tokens

prompt_tokens: int

total_tokens

total_tokens: int