mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
fix azure_openai.py: some keys do not exists (#24158)
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 Thank you for contributing to LangChain! - [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/
This commit is contained in:
parent
d895614d19
commit
20151384d7
@ -61,7 +61,7 @@ class AzureOpenAIEmbeddings(OpenAIEmbeddings):
|
|||||||
# TODO: Remove OPENAI_API_KEY support to avoid possible conflict when using
|
# TODO: Remove OPENAI_API_KEY support to avoid possible conflict when using
|
||||||
# other forms of azure credentials.
|
# other forms of azure credentials.
|
||||||
values["openai_api_key"] = (
|
values["openai_api_key"] = (
|
||||||
values["openai_api_key"]
|
values.get("openai_api_key")
|
||||||
or os.getenv("AZURE_OPENAI_API_KEY")
|
or os.getenv("AZURE_OPENAI_API_KEY")
|
||||||
or os.getenv("OPENAI_API_KEY")
|
or os.getenv("OPENAI_API_KEY")
|
||||||
)
|
)
|
||||||
@ -75,7 +75,7 @@ class AzureOpenAIEmbeddings(OpenAIEmbeddings):
|
|||||||
values, "openai_api_type", "OPENAI_API_TYPE", default="azure"
|
values, "openai_api_type", "OPENAI_API_TYPE", default="azure"
|
||||||
)
|
)
|
||||||
values["openai_organization"] = (
|
values["openai_organization"] = (
|
||||||
values["openai_organization"]
|
values.get("openai_organization")
|
||||||
or os.getenv("OPENAI_ORG_ID")
|
or os.getenv("OPENAI_ORG_ID")
|
||||||
or os.getenv("OPENAI_ORGANIZATION")
|
or os.getenv("OPENAI_ORGANIZATION")
|
||||||
)
|
)
|
||||||
@ -85,10 +85,10 @@ class AzureOpenAIEmbeddings(OpenAIEmbeddings):
|
|||||||
"OPENAI_PROXY",
|
"OPENAI_PROXY",
|
||||||
default="",
|
default="",
|
||||||
)
|
)
|
||||||
values["azure_endpoint"] = values["azure_endpoint"] or os.getenv(
|
values["azure_endpoint"] = values.get("azure_endpoint") or os.getenv(
|
||||||
"AZURE_OPENAI_ENDPOINT"
|
"AZURE_OPENAI_ENDPOINT"
|
||||||
)
|
)
|
||||||
values["azure_ad_token"] = values["azure_ad_token"] or os.getenv(
|
values["azure_ad_token"] = values.get("azure_ad_token") or os.getenv(
|
||||||
"AZURE_OPENAI_AD_TOKEN"
|
"AZURE_OPENAI_AD_TOKEN"
|
||||||
)
|
)
|
||||||
# Azure OpenAI embedding models allow a maximum of 16 texts
|
# Azure OpenAI embedding models allow a maximum of 16 texts
|
||||||
|
Loading…
Reference in New Issue
Block a user