From df73f35e35e489e10f31d3efd289b7135d0157ab Mon Sep 17 00:00:00 2001 From: Jack Gerrits Date: Fri, 22 Nov 2024 11:29:08 -0500 Subject: [PATCH] Add warnings for deprecated azure oai config changes --- .../models/_openai/_openai_client.py | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/python/packages/autogen-ext/src/autogen_ext/models/_openai/_openai_client.py b/python/packages/autogen-ext/src/autogen_ext/models/_openai/_openai_client.py index 7faefa44c4a..1b6ba62f2a3 100644 --- a/python/packages/autogen-ext/src/autogen_ext/models/_openai/_openai_client.py +++ b/python/packages/autogen-ext/src/autogen_ext/models/_openai/_openai_client.py @@ -86,10 +86,29 @@ def _azure_openai_client_from_config(config: Mapping[str, Any]) -> AsyncAzureOpe # Take a copy copied_config = dict(config).copy() + import warnings + + if "azure_deployment" not in copied_config and "model" in copied_config: + warnings.warn( + "Previous behavior of using the model name as the deployment name is deprecated and will be removed in 0.4", + stacklevel=2, + ) + + if "azure_endpoint" not in copied_config and "base_url" in copied_config: + warnings.warn( + "Previous behavior of using the base_url as the endpoint is deprecated and will be removed in 0.4", + stacklevel=2, + ) + # Do some fixups copied_config["azure_deployment"] = copied_config.get("azure_deployment", config.get("model")) if copied_config["azure_deployment"] is not None: - copied_config["azure_deployment"] = copied_config["azure_deployment"].replace(".", "") + if "." in copied_config["azure_deployment"]: + warnings.warn( + "Previous behavior stripping '.' from the deployment name is deprecated and will be removed in 0.4", + stacklevel=2, + ) + copied_config["azure_deployment"] = copied_config["azure_deployment"].replace(".", "") copied_config["azure_endpoint"] = copied_config.get("azure_endpoint", copied_config.pop("base_url", None)) # Shave down the config to just the AzureOpenAIChatCompletionClient kwargs