I try to call AzureChatOpenAI() from langchain. Normally I would do:
model = AzureChatOpenAI(
openai_api_base=os.getenv("OPENAI_API_BASE"),
openai_api_version="2023-03-15-preview",
deployment_name=os.getenv("GPT_DEPLOYMENT_NAME"),
openai_api_key=os.getenv("OPENAI_API_KEY"),
openai_api_type="azure",
)
But I get the warnings
python3.9/site-packages/langchain/chat_models/azure_openai.py:155: UserWarning: As of openai>=1.0.0, Azure endpoints should be specified via the `azure_endpoint` param not `openai_api_base` (or alias `base_url`). Updating `openai_api_base` from https://xxxx.openai.azure.com/ to https://xxxx.openai.azure.com/openai.
warnings.warn(
python3.9/site-packages/langchain/chat_models/azure_openai.py:162: UserWarning: As of openai>=1.0.0, if `deployment_name` (or alias `azure_deployment`) is specified then `openai_api_base` (or alias `base_url`) should not be. Instead use `deployment_name` (or alias `azure_deployment`) and `azure_endpoint`.
warnings.warn(
python3.9/site-packages/langchain/chat_models/azure_openai.py:170: UserWarning: As of openai>=1.0.0, if `openai_api_base` (or alias `base_url`) is specified it is expected to be of the form https://example-resource.azure.openai.com/openai/deployments/example-deployment. Updating https://xxxx.openai.azure.com/ to https://xxxx.openai.azure.com/openai.
warnings.warn(
But if I follow the instructions and change it to:
model = AzureChatOpenAI(
azure_endpoint=os.getenv("OPENAI_API_BASE"),
openai_api_version="2023-03-15-preview",
azure_deployment=os.getenv("GPT_DEPLOYMENT_NAME"),
openai_api_key=os.getenv("OPENAI_API_KEY"),
openai_api_type="azure",
)
I get the error
ValidationError: 1 validation error for AzureChatOpenAI
__root__
base_url and azure_endpoint are mutually exclusive (type=value_error)
What am I doing wrong?
OPENAI_API_BASE
. You need to useAZURE_OPENAI_ENDPOINT
, instead ofOPENAI_API_BASE
. The value forAZURE_OPENAI_ENDPOINT
can be fetched from your azure subscription (portal); Under Resource=>Keys and Endpoints=>Endpoint. Set this value in your environment. The errorbase_url and azure_endpoint are mutually exclusive
indicates that you are trying to set value forbase_url
viaOPEN_API_BASE
in azure_endpoint. – Phelps