From 27262d845421e59327c09e50239d159ac13fa1ef Mon Sep 17 00:00:00 2001 From: Anirudh31415926535 Date: Mon, 14 Oct 2024 22:35:08 +0800 Subject: [PATCH] fix: Allow cohere_api_key to be SecretStr in CohereEmbedding (#102) Resolves issue https://github.com/langchain-ai/langchain-cohere/issues/101 --- libs/cohere/langchain_cohere/embeddings.py | 3 +++ libs/cohere/pyproject.toml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/cohere/langchain_cohere/embeddings.py b/libs/cohere/langchain_cohere/embeddings.py index 4fff4c1..5493f10 100644 --- a/libs/cohere/langchain_cohere/embeddings.py +++ b/libs/cohere/langchain_cohere/embeddings.py @@ -78,6 +78,9 @@ def validate_environment(cls, values: Dict) -> Any: cohere_api_key = get_from_dict_or_env( values, "cohere_api_key", "COHERE_API_KEY" ) + if isinstance(cohere_api_key, SecretStr): + cohere_api_key = cohere_api_key.get_secret_value() + request_timeout = values.get("request_timeout") client_name = values.get("user_agent", "langchain:partner") diff --git a/libs/cohere/pyproject.toml b/libs/cohere/pyproject.toml index 978966d..e22d5d3 100644 --- a/libs/cohere/pyproject.toml +++ b/libs/cohere/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langchain-cohere" -version = "0.3.0" +version = "0.3.1" description = "An integration package connecting Cohere and LangChain" authors = [] readme = "README.md"