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

Update utils.py- Fix error when using AzureOpenAI services #4254

Open
wants to merge 7 commits 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 @@ -50,7 +50,7 @@ def create_completion_client_from_env(env: Dict[str, str] | None = None, **kwarg

# Load the kwargs, and override with provided kwargs
_kwargs = json.loads(env.get(ENVIRON_KEY_CHAT_COMPLETION_KWARGS_JSON, "{}"))
_kwargs.update(kwargs)


# If model capabilities were provided, deserialize them as well
if "model_capabilities" in _kwargs:
Expand All @@ -62,9 +62,10 @@ def create_completion_client_from_env(env: Dict[str, str] | None = None, **kwarg

# Figure out what provider we are using. Default to OpenAI
_provider = env.get(ENVIRON_KEY_CHAT_COMPLETION_PROVIDER, "openai").lower().strip()

# Instantiate the correct client
if _provider == "openai":
_kwargs.update(kwargs)
return OpenAIChatCompletionClient(**_kwargs) # type: ignore
elif _provider == "azure":
if _kwargs.get("azure_ad_token_provider", "").lower() == "default":
Expand Down
Loading