Skip to content

Commit df151d6

Browse files
committed
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).
1 parent c81e8a7 commit df151d6

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

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,

0 commit comments

Comments
 (0)