Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warnings for deprecated azure oai config changes #4317

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In AzureOpenAIChatCompletionClient constructor model argument is still checked:

        if "model" not in kwargs:
            raise ValueError("model is required for OpenAIChatCompletionClient")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to update the API documentation by changing the example in the doc string.

Copy link
Collaborator

@ekzhu ekzhu Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to update usage of AzureOpenAIChatCompletionClient in the documentation to change model to azure_deployment. Can be do a separate PR after creating an issue for it.


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
Expand Down
Loading