From 325068bb53b849c4185111e6c41cbfca43c70d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9=20Antunes?= Date: Tue, 23 Jul 2024 17:22:21 -0300 Subject: [PATCH] community: Fix azure_openai.py (#24572) In some lines its trying to read a key that do not exists yet. In this cases I changed the direct access to dict.get() method - [ x] **Lint and test**: Run `make format`, `make lint` and `make test` from the root of the package(s) you've modified. See contribution guidelines for more: https://python.langchain.com/docs/contributing/ --- libs/community/langchain_community/embeddings/azure_openai.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/community/langchain_community/embeddings/azure_openai.py b/libs/community/langchain_community/embeddings/azure_openai.py index 2e021f88d6..489a81b939 100644 --- a/libs/community/langchain_community/embeddings/azure_openai.py +++ b/libs/community/langchain_community/embeddings/azure_openai.py @@ -65,10 +65,10 @@ class AzureOpenAIEmbeddings(OpenAIEmbeddings): or os.getenv("AZURE_OPENAI_API_KEY") or os.getenv("OPENAI_API_KEY") ) - values["openai_api_base"] = values["openai_api_base"] or os.getenv( + values["openai_api_base"] = values.get("openai_api_base") or os.getenv( "OPENAI_API_BASE" ) - values["openai_api_version"] = values["openai_api_version"] or os.getenv( + values["openai_api_version"] = values.get("openai_api_version") or os.getenv( "OPENAI_API_VERSION", default="2023-05-15" ) values["openai_api_type"] = get_from_dict_or_env(