fix(openai): update AzureOpenAIEmbeddings validation logic for openai_api_base (#31782)

This commit is contained in:
Aasish
2025-09-11 00:23:30 +05:30
committed by GitHub
parent 67e651b592
commit 9c7d262ff4

View File

@@ -173,13 +173,15 @@ class AzureOpenAIEmbeddings(OpenAIEmbeddings): # type: ignore[override]
# between azure_endpoint and base_url (openai_api_base).
openai_api_base = self.openai_api_base
if openai_api_base and self.validate_base_url:
if "/openai" not in openai_api_base:
self.openai_api_base = cast(str, self.openai_api_base) + "/openai"
raise ValueError(
"As of openai>=1.0.0, Azure endpoints should be specified via "
"the `azure_endpoint` param not `openai_api_base` "
"(or alias `base_url`). "
)
# Only validate openai_api_base if azure_endpoint is not provided
if not self.azure_endpoint:
if "/openai" not in openai_api_base:
self.openai_api_base = cast(str, self.openai_api_base) + "/openai"
raise ValueError(
"As of openai>=1.0.0, Azure endpoints should be specified via "
"the `azure_endpoint` param not `openai_api_base` "
"(or alias `base_url`). "
)
if self.deployment:
raise ValueError(
"As of openai>=1.0.0, if `deployment` (or alias "