Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(partners): support request timeout in BaseCohere #19641

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions libs/partners/cohere/langchain_cohere/llms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand All @@ -82,11 +85,13 @@ def validate_environment(cls, values: Dict) -> Dict:
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
Expand Down