azure_openai
langroid/language_models/azure_openai.py
AzureConfig(**kwargs)
¶
Bases: OpenAIGPTConfig
Configuration for Azure OpenAI GPT.
Attributes:
Name | Type | Description |
---|---|---|
type |
str
|
should be |
api_version |
str
|
can be set in the |
deployment_name |
str
|
can be set in the |
model_name |
str
|
can be set in the |
model_version |
str
|
can be set in the |
Source code in langroid/language_models/openai_gpt.py
AzureGPT(config)
¶
Bases: OpenAIGPT
Class to access OpenAI LLMs via Azure. These env variables can be obtained from the
file .azure_env
. Azure OpenAI doesn't support completion
Attributes:
config (AzureConfig): AzureConfig object
api_key (str): Azure API key
api_base (str): Azure API base url
api_version (str): Azure API version
model_name (str): the name of gpt model in your deployment
model_version (str): the version of gpt model in your deployment
Source code in langroid/language_models/azure_openai.py
set_chat_model()
¶
Sets the chat model configuration based on the model name specified in the
.env
. This function checks the model_name
in the configuration and sets
the appropriate chat model in the config.chat_model
. It supports handling for
'35-turbo' and 'gpt-4' models. For 'gpt-4', it further delegates the handling
to handle_gpt4_model
method. If the model name does not match any predefined
models, it defaults to OpenAIChatModel.GPT4
.
Source code in langroid/language_models/azure_openai.py
handle_gpt4_model()
¶
Handles the setting of the GPT-4 model in the configuration.
This function checks the model_version
in the configuration.
If the version is not set, it raises a ValueError indicating
that the model version needs to be specified in the .env
file. It sets OpenAIChatMode.GPT4o
if the version is
one of those listed below, and
OpenAIChatModel.GPT4_TURBO
if
the version is '1106-Preview', otherwise, it defaults to
setting OpenAIChatModel.GPT4
.