Share via


open_ai Package

Packages

exceptions
prompt_execution_settings
services
settings

Modules

const

Classes

ApiKeyAuthentication

API key authentication.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

AzureAISearchDataSource

Azure AI Search data source.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

AzureAISearchDataSourceParameters

Azure AI Search data source parameters.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

AzureAudioToText

Azure audio to text service.

Initialize an AzureAudioToText service.

AzureChatCompletion

Azure Chat completion class.

Initialize an AzureChatCompletion service.

AzureChatPromptExecutionSettings

Specific settings for the Azure OpenAI Chat Completion endpoint.

Initialize the prompt execution settings.

AzureCosmosDBDataSource

Azure Cosmos DB data source.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

AzureCosmosDBDataSourceParameters

Azure Cosmos DB data source parameters.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

AzureDataSourceParameters

Azure data source parameters.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

AzureEmbeddingDependency

Azure embedding dependency.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

AzureOpenAISettings

AzureOpenAI model settings.

The settings are first loaded from environment variables with the prefix '>>AZURE_OPENAI_<<'. If the environment variables are not found, the settings can be loaded from a .env file with the encoding 'utf-8'. If the settings are not found in the .env file, the settings are ignored; however, validation will fail alerting that the settings are missing.

Optional settings for prefix '>>AZURE_OPENAI_<<' are:

  • chat_deployment_name: str - The name of the Azure Chat deployment. This value

    will correspond to the custom name you chose for your deployment when you deployed a model. This value can be found under Resource Management > Deployments in the Azure portal or, alternatively, under Management > Deployments in Azure OpenAI Studio. (Env var AZURE_OPENAI_CHAT_DEPLOYMENT_NAME)

  • text_deployment_name: str - The name of the Azure Text deployment. This value

    will correspond to the custom name you chose for your deployment when you deployed a model. This value can be found under Resource Management > Deployments in the Azure portal or, alternatively, under Management > Deployments in Azure OpenAI Studio. (Env var AZURE_OPENAI_TEXT_DEPLOYMENT_NAME)

  • embedding_deployment_name: str - The name of the Azure Embedding deployment. This value

    will correspond to the custom name you chose for your deployment when you deployed a model. This value can be found under Resource Management > Deployments in the Azure portal or, alternatively, under Management > Deployments in Azure OpenAI Studio. (Env var AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME)

  • text_to_image_deployment_name: str - The name of the Azure Text to Image deployment. This

    value will correspond to the custom name you chose for your deployment when you deployed a model. This value can be found under Resource Management > Deployments in the Azure portal or, alternatively, under Management > Deployments in Azure OpenAI Studio. (Env var AZURE_OPENAI_TEXT_TO_IMAGE_DEPLOYMENT_NAME)

  • audio_to_text_deployment_name: str - The name of the Azure Audio to Text deployment. This

    value will correspond to the custom name you chose for your deployment when you deployed a model. This value can be found under Resource Management > Deployments in the Azure portal or, alternatively, under Management > Deployments in Azure OpenAI Studio. (Env var AZURE_OPENAI_AUDIO_TO_TEXT_DEPLOYMENT_NAME)

  • text_to_audio_deployment_name: str - The name of the Azure Text to Audio deployment. This

    value will correspond to the custom name you chose for your deployment when you deployed a model. This value can be found under Resource Management > Deployments in the Azure portal or, alternatively, under Management > Deployments in Azure OpenAI Studio. (Env var AZURE_OPENAI_TEXT_TO_AUDIO_DEPLOYMENT_NAME)

  • api_key: SecretStr - The API key for the Azure deployment. This value can be

    found in the Keys & Endpoint section when examining your resource in the Azure portal. You can use either KEY1 or KEY2. (Env var AZURE_OPENAI_API_KEY)

  • base_url: HttpsUrl | None - base_url: The url of the Azure deployment. This value

    can be found in the Keys & Endpoint section when examining your resource from the Azure portal, the base_url consists of the endpoint, followed by /openai/deployments/{deployment_name}/, use endpoint if you only want to supply the endpoint. (Env var AZURE_OPENAI_BASE_URL)

  • endpoint: HttpsUrl - The endpoint of the Azure deployment. This value

    can be found in the Keys & Endpoint section when examining your resource from the Azure portal, the endpoint should end in openai.azure.com. If both base_url and endpoint are supplied, base_url will be used. (Env var AZURE_OPENAI_ENDPOINT)

  • api_version: str | None - The API version to use. The default value is "2024-02-01".

    (Env var AZURE_OPENAI_API_VERSION)

  • token_endpoint: str - The token endpoint to use to retrieve the authentication token.

    The default value is "https://cognitiveservices.azure.com/.default". (Env var AZURE_OPENAI_TOKEN_ENDPOINT)

AzureTextCompletion

Azure Text Completion class.

Initialize an AzureTextCompletion service.

AzureTextEmbedding

Azure Text Embedding class.

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

Initialize an AzureTextEmbedding service.

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

env vars or .env file.

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

endpoint: The optional deployment endpoint. If provided will override the value in the env vars or .env file.

base_url: The optional deployment base_url. If provided will override the value in the env vars or .env file.

api_version: The optional deployment api version. If provided will override the value in the env vars or .env file.

ad_token: The Azure AD token for authentication. (Optional) ad_token_provider: Whether to use Azure Active Directory authentication.

(Optional) The default value is False.

token_endpoint: The Azure AD token endpoint. (Optional) 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)

AzureTextToAudio

Azure text to audio service.

Initialize an AzureTextToAudio service.

AzureTextToImage

Azure Text to Image service.

Initialize an AzureTextToImage service.

ConnectionStringAuthentication

Connection string authentication.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

DataSourceFieldsMapping

Data source fields mapping.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

ExtraBody

Extra body for the Azure Chat Completion endpoint.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

OpenAIAudioToText

OpenAI Text to Image service.

Initializes a new instance of the OpenAIAudioToText class.

OpenAIAudioToTextExecutionSettings

Request settings for OpenAI audio to text services.

Initialize the prompt execution settings.

OpenAIChatCompletion

OpenAI Chat completion class.

Initialize an OpenAIChatCompletion service.

OpenAIChatPromptExecutionSettings

Specific settings for the Chat Completion endpoint.

Initialize the prompt execution settings.

OpenAIEmbeddingPromptExecutionSettings

Specific settings for the text embedding endpoint.

Initialize the prompt execution settings.

OpenAIPromptExecutionSettings

Common request settings for (Azure) OpenAI services.

Initialize the prompt execution settings.

OpenAISettings

OpenAI model settings.

The settings are first loaded from environment variables with the prefix '>>OPENAI_<<'. If the environment variables are not found, the settings can be loaded from a .env file with the encoding 'utf-8'. If the settings are not found in the .env file, the settings are ignored; however, validation will fail alerting that the settings are missing.

Optional settings for prefix '>>OPENAI_<<' are:

  • org_id: str | None - This is usually optional unless your account belongs to multiple organizations.

    (Env var OPENAI_ORG_ID)

  • chat_model_id: str | None - The OpenAI chat model ID to use, for example, gpt-3.5-turbo or gpt-4.

    (Env var OPENAI_CHAT_MODEL_ID)

  • text_model_id: str | None - The OpenAI text model ID to use, for example, gpt-3.5-turbo-instruct.

    (Env var OPENAI_TEXT_MODEL_ID)

  • embedding_model_id: str | None - The OpenAI embedding model ID to use, for example, text-embedding-ada-002.

    (Env var OPENAI_EMBEDDING_MODEL_ID)

  • text_to_image_model_id: str | None - The OpenAI text to image model ID to use, for example, dall-e-3.

    (Env var OPENAI_TEXT_TO_IMAGE_MODEL_ID)

  • audio_to_text_model_id: str | None - The OpenAI audio to text model ID to use, for example, whisper-1.

    (Env var OPENAI_AUDIO_TO_TEXT_MODEL_ID)

  • text_to_audio_model_id: str | None - The OpenAI text to audio model ID to use, for example, jukebox-1.

    (Env var OPENAI_TEXT_TO_AUDIO_MODEL_ID)

  • env_file_path: str | None - if provided, the .env settings are read from this file path location

OpenAITextCompletion

OpenAI Text Completion class.

Initialize an OpenAITextCompletion service.

OpenAITextEmbedding

OpenAI Text Embedding class.

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

Initializes a new instance of the OpenAITextCompletion class.

OpenAITextPromptExecutionSettings

Specific settings for the completions endpoint.

Initialize the prompt execution settings.

OpenAITextToAudio

OpenAI Text to Image service.

Initializes a new instance of the OpenAITextToAudio class.

OpenAITextToAudioExecutionSettings

Request settings for OpenAI text to audio services.

Initialize the prompt execution settings.

OpenAITextToImage

OpenAI Text to Image service.

Initializes a new instance of the OpenAITextToImage class.

OpenAITextToImageExecutionSettings

Request settings for OpenAI text to image services.

Initialize the prompt execution settings.