From 403c0ea801e96464e1389970f5c90a73e33a237a Mon Sep 17 00:00:00 2001 From: bbaltagi-dtsl <85242845+bbaltagi-dtsl@users.noreply.github.com> Date: Mon, 21 Oct 2024 21:46:56 +0200 Subject: [PATCH] community: fix DallE hidden open_api_key (#26996) Thank you for contributing to LangChain! - [ X] **PR title**: "package: description" - Where "package" is whichever of langchain, community, core, etc. is being modified. Use "docs: ..." for purely docs changes, "templates: ..." for template changes, "infra: ..." for CI changes. - Example: "community: add foobar LLM" - [ X] - **Issue:** issue #26941 Additional guidelines: - Make sure optional dependencies are imported within a function. - Please do not add dependencies to pyproject.toml files (even optional ones) unless they are required for unit tests. - Most PRs should not touch more than one package. - Changes should be backwards compatible. - If you are adding something to community, do not re-import it in langchain. If no one reviews your PR within a few days, please @-mention one of baskaryan, efriis, eyurtsev, ccurme, vbarda, hwchase17. Co-authored-by: Erick Friis --- .../langchain_community/utilities/dalle_image_generator.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/community/langchain_community/utilities/dalle_image_generator.py b/libs/community/langchain_community/utilities/dalle_image_generator.py index ba7970effa6..fea18c3958d 100644 --- a/libs/community/langchain_community/utilities/dalle_image_generator.py +++ b/libs/community/langchain_community/utilities/dalle_image_generator.py @@ -116,7 +116,9 @@ class DallEAPIWrapper(BaseModel): if is_openai_v1(): client_params = { - "api_key": self.openai_api_key, + "api_key": self.openai_api_key.get_secret_value() + if self.openai_api_key + else None, "organization": self.openai_organization, "base_url": self.openai_api_base, "timeout": self.request_timeout,