Skip to content

Commit 41f344b

Browse files
fern-supportjsklan
andauthored
feat(client): forward max_retries through Client/ClientV2 constructors (#779)
* feat(client): forward max_retries through Client/ClientV2 constructors The base BaseCohere/AsyncBaseCohere constructors accept `max_retries`, but the hand-maintained Client, AsyncClient, ClientV2 and AsyncClientV2 override constructors never exposed it, so it could not be set at the client level (only per-request via request_options). Thread `max_retries: Optional[int] = None` through all four override constructors, forwarding to the respective super().__init__. The None default preserves the existing behavior (base applies its default of 2). * chore: bump version 7.0.4 -> 7.0.5 --------- Co-authored-by: jsklan <jsklan.development@gmail.com>
1 parent c81e8a7 commit 41f344b

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ dynamic = ["version"]
44

55
[tool.poetry]
66
name = "cohere"
7-
version = "7.0.4"
7+
version = "7.0.5"
88
description = ""
99
readme = "README.md"
1010
authors = []

src/cohere/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def __init__(
139139
environment: ClientEnvironment = ClientEnvironment.PRODUCTION,
140140
client_name: typing.Optional[str] = None,
141141
timeout: typing.Optional[float] = None,
142+
max_retries: typing.Optional[int] = None,
142143
httpx_client: typing.Optional[httpx.Client] = None,
143144
thread_pool_executor: ThreadPoolExecutor = ThreadPoolExecutor(64),
144145
log_warning_experimental_features: bool = True,
@@ -157,6 +158,7 @@ def __init__(
157158
client_name=client_name,
158159
token=api_key,
159160
timeout=timeout,
161+
max_retries=max_retries,
160162
httpx_client=httpx_client,
161163
)
162164

@@ -386,6 +388,7 @@ def __init__(
386388
environment: ClientEnvironment = ClientEnvironment.PRODUCTION,
387389
client_name: typing.Optional[str] = None,
388390
timeout: typing.Optional[float] = None,
391+
max_retries: typing.Optional[int] = None,
389392
httpx_client: typing.Optional[httpx.AsyncClient] = None,
390393
thread_pool_executor: ThreadPoolExecutor = ThreadPoolExecutor(64),
391394
log_warning_experimental_features: bool = True,
@@ -404,6 +407,7 @@ def __init__(
404407
client_name=client_name,
405408
token=api_key,
406409
timeout=timeout,
410+
max_retries=max_retries,
407411
httpx_client=httpx_client,
408412
)
409413

src/cohere/client_v2.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def __init__(
3838
environment: ClientEnvironment = ClientEnvironment.PRODUCTION,
3939
client_name: typing.Optional[str] = None,
4040
timeout: typing.Optional[float] = None,
41+
max_retries: typing.Optional[int] = None,
4142
httpx_client: typing.Optional[httpx.Client] = None,
4243
thread_pool_executor: ThreadPoolExecutor = ThreadPoolExecutor(64),
4344
log_warning_experimental_features: bool = True,
@@ -49,6 +50,7 @@ def __init__(
4950
environment=environment,
5051
client_name=client_name,
5152
timeout=timeout,
53+
max_retries=max_retries,
5254
httpx_client=httpx_client,
5355
thread_pool_executor=thread_pool_executor,
5456
log_warning_experimental_features=log_warning_experimental_features,
@@ -71,6 +73,7 @@ def __init__(
7173
environment: ClientEnvironment = ClientEnvironment.PRODUCTION,
7274
client_name: typing.Optional[str] = None,
7375
timeout: typing.Optional[float] = None,
76+
max_retries: typing.Optional[int] = None,
7477
httpx_client: typing.Optional[httpx.AsyncClient] = None,
7578
thread_pool_executor: ThreadPoolExecutor = ThreadPoolExecutor(64),
7679
log_warning_experimental_features: bool = True,
@@ -82,6 +85,7 @@ def __init__(
8285
environment=environment,
8386
client_name=client_name,
8487
timeout=timeout,
88+
max_retries=max_retries,
8589
httpx_client=httpx_client,
8690
thread_pool_executor=thread_pool_executor,
8791
log_warning_experimental_features=log_warning_experimental_features,

src/cohere/core/client_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ def get_headers(self) -> typing.Dict[str, str]:
3131
import platform
3232

3333
headers: typing.Dict[str, str] = {
34-
"User-Agent": "cohere/7.0.4",
34+
"User-Agent": "cohere/7.0.5",
3535
"X-Fern-Language": "Python",
3636
"X-Fern-Runtime": f"python/{platform.python_version()}",
3737
"X-Fern-Platform": f"{platform.system().lower()}/{platform.release()}",
3838
"X-Fern-SDK-Name": "cohere",
39-
"X-Fern-SDK-Version": "7.0.4",
39+
"X-Fern-SDK-Version": "7.0.5",
4040
**(self.get_custom_headers() or {}),
4141
}
4242
if self._client_name is not None:

0 commit comments

Comments
 (0)