diff --git a/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/openai.py b/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/openai.py index cdd2130ea..30bfd628f 100644 --- a/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/openai.py +++ b/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/openai.py @@ -83,7 +83,9 @@ class AzureChatOpenAIProvider(BaseProvider, AzureChatOpenAI): pypi_package_deps = ["langchain_openai"] # Confusingly, langchain uses both OPENAI_API_KEY and AZURE_OPENAI_API_KEY for azure # https://github.com/langchain-ai/langchain/blob/f2579096993ae460516a0aae1d3e09f3eb5c1772/libs/partners/openai/langchain_openai/llms/azure.py#L85 - auth_strategy = EnvAuthStrategy(name="AZURE_OPENAI_API_KEY", keyword_param="openai_api_key") + auth_strategy = EnvAuthStrategy( + name="AZURE_OPENAI_API_KEY", keyword_param="openai_api_key" + ) registry = True fields = [ diff --git a/packages/jupyter-ai-magics/jupyter_ai_magics/providers.py b/packages/jupyter-ai-magics/jupyter_ai_magics/providers.py index 485a56e76..1bbc4ce57 100644 --- a/packages/jupyter-ai-magics/jupyter_ai_magics/providers.py +++ b/packages/jupyter-ai-magics/jupyter_ai_magics/providers.py @@ -33,10 +33,7 @@ from langchain.schema.output_parser import StrOutputParser from langchain.schema.runnable import Runnable from langchain.utils import get_from_dict_or_env -from langchain_community.chat_models import ( - BedrockChat, - QianfanChatEndpoint, -) +from langchain_community.chat_models import BedrockChat, QianfanChatEndpoint from langchain_community.llms import ( AI21, Bedrock, diff --git a/packages/jupyter-ai/jupyter_ai/config_manager.py b/packages/jupyter-ai/jupyter_ai/config_manager.py index 32e72b86c..d7674c5a2 100644 --- a/packages/jupyter-ai/jupyter_ai/config_manager.py +++ b/packages/jupyter-ai/jupyter_ai/config_manager.py @@ -448,7 +448,10 @@ def _provider_params(self, key, listing): _, Provider = get_em_provider(gid, listing) authn_fields = {} if Provider.auth_strategy and Provider.auth_strategy.type == "env": - keyword_param = Provider.auth_strategy.keyword_param or Provider.auth_strategy.name.lower() + keyword_param = ( + Provider.auth_strategy.keyword_param + or Provider.auth_strategy.name.lower() + ) key_name = Provider.auth_strategy.name authn_fields[keyword_param] = config.api_keys[key_name]