Skip to content

Commit c64f905

Browse files
feat: add validation checking for azure deployment config
1 parent efda34b commit c64f905

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

redisvl/utils/vectorize/text/azureopenai.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def __init__(
6161
'Deployment name' not the 'Model name'. Defaults to
6262
'text-embedding-ada-002'.
6363
api_config (Optional[Dict], optional): Dictionary containing the
64-
API key, API version, Azure endpoint, and any other API options.
64+
API key, API version, Azure endpoint, Azure deployment, and any other API options.
6565
Defaults to None.
6666
6767
Raises:
@@ -127,6 +127,19 @@ def _initialize_clients(self, api_config: Optional[Dict]):
127127
"Provide it in api_config or set the AZURE_OPENAI_API_KEY\
128128
environment variable."
129129
)
130+
131+
azure_deployment = (
132+
api_config.pop("azure_deployment")
133+
if api_config
134+
else os.getenv("AZURE_OPENAI_DEPLOYMENT")
135+
)
136+
137+
if not azure_deployment:
138+
raise ValueError(
139+
"AzureOpenAI API deployment is required. "
140+
"Provide it in api_config or set the AZURE_OPENAI_DEPLOYMENT\
141+
environment variable."
142+
)
130143

131144
self._client = AzureOpenAI(
132145
api_key=api_key,

0 commit comments

Comments
 (0)