mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-27 08:58:48 +00:00
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 <baskaryan@gmail.com>
This commit is contained in:
parent
d5c412b0a9
commit
06dac394a6
@ -66,6 +66,9 @@ class BaseCohere(Serializable):
|
|||||||
streaming: bool = Field(default=False)
|
streaming: bool = Field(default=False)
|
||||||
"""Whether to stream the results."""
|
"""Whether to stream the results."""
|
||||||
|
|
||||||
|
timeout: Optional[float] = 60
|
||||||
|
"""Timeout in seconds for the Cohere API request."""
|
||||||
|
|
||||||
user_agent: str = "langchain"
|
user_agent: str = "langchain"
|
||||||
"""Identifier for the application making the request."""
|
"""Identifier for the application making the request."""
|
||||||
|
|
||||||
@ -82,11 +85,13 @@ class BaseCohere(Serializable):
|
|||||||
values["client"] = cohere.Client(
|
values["client"] = cohere.Client(
|
||||||
api_key=values["cohere_api_key"].get_secret_value(),
|
api_key=values["cohere_api_key"].get_secret_value(),
|
||||||
client_name=client_name,
|
client_name=client_name,
|
||||||
|
timeout=values["timeout"],
|
||||||
base_url=values["base_url"],
|
base_url=values["base_url"],
|
||||||
)
|
)
|
||||||
values["async_client"] = cohere.AsyncClient(
|
values["async_client"] = cohere.AsyncClient(
|
||||||
api_key=values["cohere_api_key"].get_secret_value(),
|
api_key=values["cohere_api_key"].get_secret_value(),
|
||||||
client_name=client_name,
|
client_name=client_name,
|
||||||
|
timeout=values["timeout"],
|
||||||
base_url=values["base_url"],
|
base_url=values["base_url"],
|
||||||
)
|
)
|
||||||
return values
|
return values
|
||||||
|
Loading…
Reference in New Issue
Block a user