From 06dac394a62b0193f09b9d125611a2bcfb14d630 Mon Sep 17 00:00:00 2001 From: Massimiliano Pronesti Date: Mon, 1 Apr 2024 23:16:32 +0200 Subject: [PATCH] cohere[patch]: support request timeout in BaseCohere (#19641) As in #19346, this PR exposes `request_timeout` in `BaseCohere`, while `max_retires` is no longer a parameter of the beneath client (`cohere.Client`) and it is already configured in `langchain_cohere.llms.Cohere`. --------- Co-authored-by: Bagatur --- libs/partners/cohere/langchain_cohere/llms.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/partners/cohere/langchain_cohere/llms.py b/libs/partners/cohere/langchain_cohere/llms.py index a95a5c09b54..c0401b97eca 100644 --- a/libs/partners/cohere/langchain_cohere/llms.py +++ b/libs/partners/cohere/langchain_cohere/llms.py @@ -66,6 +66,9 @@ class BaseCohere(Serializable): streaming: bool = Field(default=False) """Whether to stream the results.""" + timeout: Optional[float] = 60 + """Timeout in seconds for the Cohere API request.""" + user_agent: str = "langchain" """Identifier for the application making the request.""" @@ -82,11 +85,13 @@ class BaseCohere(Serializable): values["client"] = cohere.Client( api_key=values["cohere_api_key"].get_secret_value(), client_name=client_name, + timeout=values["timeout"], base_url=values["base_url"], ) values["async_client"] = cohere.AsyncClient( api_key=values["cohere_api_key"].get_secret_value(), client_name=client_name, + timeout=values["timeout"], base_url=values["base_url"], ) return values