Skip to content

Commit 0c5ed77

Browse files
SDK regeneration
1 parent dcd81d8 commit 0c5ed77

15 files changed

Lines changed: 1431 additions & 347 deletions

.fern/metadata.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
2-
"cliVersion": "4.48.0",
2+
"cliVersion": "4.62.0",
33
"generatorName": "fernapi/fern-python-sdk",
4-
"generatorVersion": "4.63.4",
4+
"generatorVersion": "5.3.1",
55
"generatorConfig": {
6-
"pyproject_python_version": "^3.9",
76
"inline_request_params": false,
87
"extra_dependencies": {
98
"fastavro": "^1.9.4",
@@ -79,6 +78,6 @@
7978
}
8079
]
8180
},
82-
"originGitCommit": "40f3fd11b9fd6b445b024a2fcf6f2e67f6181147",
83-
"sdkVersion": "5.21.2"
81+
"originGitCommit": "a424220a3cebe0f93c504c5dbc7d9ac58ab7a640",
82+
"sdkVersion": "6.0.0"
8483
}

poetry.lock

Lines changed: 1025 additions & 250 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ dynamic = ["version"]
44

55
[tool.poetry]
66
name = "cohere"
7-
version = "5.21.2"
7+
version = "6.0.0"
88
description = ""
99
readme = "README.md"
1010
authors = []
@@ -14,7 +14,6 @@ classifiers = [
1414
"Intended Audience :: Developers",
1515
"Programming Language :: Python",
1616
"Programming Language :: Python :: 3",
17-
"Programming Language :: Python :: 3.9",
1817
"Programming Language :: Python :: 3.10",
1918
"Programming Language :: Python :: 3.11",
2019
"Programming Language :: Python :: 3.12",
@@ -38,20 +37,22 @@ packages = [
3837
Repository = 'https://github.com/cohere-ai/cohere-python'
3938

4039
[tool.poetry.dependencies]
41-
python = "^3.9"
40+
python = "^3.10"
41+
aiohttp = { version = ">=3.10.0,<4", optional = true}
4242
fastavro = "^1.9.4"
4343
httpx = ">=0.21.2"
44+
httpx-aiohttp = { version = "0.1.8", optional = true}
4445
pydantic = ">= 1.9.2"
45-
pydantic-core = ">=2.18.2"
46+
pydantic-core = ">=2.18.2,<2.44.0"
4647
requests = "^2.0.0"
4748
tokenizers = ">=0.15,<1"
4849
types-requests = "^2.0.0"
4950
typing_extensions = ">= 4.0.0"
5051

5152
[tool.poetry.group.dev.dependencies]
5253
mypy = "==1.13.0"
53-
pytest = "^7.4.0"
54-
pytest-asyncio = "^0.23.5"
54+
pytest = "^8.2.0"
55+
pytest-asyncio = "^1.0.0"
5556
pytest-xdist = "^3.6.1"
5657
python-dateutil = "^2.9.0"
5758
types-python-dateutil = "^2.9.0.20240316"
@@ -60,6 +61,9 @@ ruff = "==0.11.5"
6061
[tool.pytest.ini_options]
6162
testpaths = [ "tests" ]
6263
asyncio_mode = "auto"
64+
markers = [
65+
"aiohttp: tests that require httpx_aiohttp to be installed",
66+
]
6367

6468
[tool.mypy]
6569
plugins = ["pydantic.mypy"]
@@ -91,3 +95,6 @@ section-order = ["future", "standard-library", "third-party", "first-party"]
9195
[build-system]
9296
requires = ["poetry-core"]
9397
build-backend = "poetry.core.masonry.api"
98+
99+
[tool.poetry.extras]
100+
aiohttp=["aiohttp", "httpx-aiohttp"]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
fastavro==1.9.4
22
httpx>=0.21.2
33
pydantic>= 1.9.2
4-
pydantic-core>=2.18.2
4+
pydantic-core>=2.18.2,<2.44.0
55
requests==2.0.0
66
tokenizers>=0.15,<1
77
types-requests==2.0.0

src/cohere/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@
257257
UnprocessableEntityError,
258258
)
259259
from . import audio, batches, connectors, datasets, embed_jobs, finetuning, models, v2
260+
from ._default_clients import DefaultAioHttpClient, DefaultAsyncHttpxClient
260261
from .aliases import (
261262
ChatResponse,
262263
ContentDeltaStreamedChatResponseV2,
@@ -448,6 +449,8 @@
448449
"DatasetsListResponse": ".datasets",
449450
"DebugStreamedChatResponse": ".types",
450451
"DebugV2ChatStreamResponse": ".v2",
452+
"DefaultAioHttpClient": "._default_clients",
453+
"DefaultAsyncHttpxClient": "._default_clients",
451454
"DeleteConnectorResponse": ".types",
452455
"DetokenizeResponse": ".types",
453456
"Document": ".types",
@@ -782,6 +785,8 @@ def __dir__():
782785
"DatasetsListResponse",
783786
"DebugStreamedChatResponse",
784787
"DebugV2ChatStreamResponse",
788+
"DefaultAioHttpClient",
789+
"DefaultAsyncHttpxClient",
785790
"DeleteConnectorResponse",
786791
"DetokenizeResponse",
787792
"Document",

src/cohere/_default_clients.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file was auto-generated by Fern from our API Definition.
2+
3+
import typing
4+
5+
import httpx
6+
7+
SDK_DEFAULT_TIMEOUT = 60
8+
9+
try:
10+
import httpx_aiohttp # type: ignore[import-not-found]
11+
except ImportError:
12+
13+
class DefaultAioHttpClient(httpx.AsyncClient): # type: ignore
14+
def __init__(self, **kwargs: typing.Any) -> None:
15+
raise RuntimeError("To use the aiohttp client, install the aiohttp extra: pip install cohere[aiohttp]")
16+
17+
else:
18+
19+
class DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore
20+
def __init__(self, **kwargs: typing.Any) -> None:
21+
kwargs.setdefault("timeout", SDK_DEFAULT_TIMEOUT)
22+
kwargs.setdefault("follow_redirects", True)
23+
super().__init__(**kwargs)
24+
25+
26+
class DefaultAsyncHttpxClient(httpx.AsyncClient):
27+
def __init__(self, **kwargs: typing.Any) -> None:
28+
kwargs.setdefault("timeout", SDK_DEFAULT_TIMEOUT)
29+
kwargs.setdefault("follow_redirects", True)
30+
super().__init__(**kwargs)

src/cohere/base_client.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,6 +1581,24 @@ def audio(self):
15811581
return self._audio
15821582

15831583

1584+
def _make_default_async_client(
1585+
timeout: typing.Optional[float],
1586+
follow_redirects: typing.Optional[bool],
1587+
) -> httpx.AsyncClient:
1588+
try:
1589+
import httpx_aiohttp # type: ignore[import-not-found]
1590+
except ImportError:
1591+
pass
1592+
else:
1593+
if follow_redirects is not None:
1594+
return httpx_aiohttp.HttpxAiohttpClient(timeout=timeout, follow_redirects=follow_redirects)
1595+
return httpx_aiohttp.HttpxAiohttpClient(timeout=timeout)
1596+
1597+
if follow_redirects is not None:
1598+
return httpx.AsyncClient(timeout=timeout, follow_redirects=follow_redirects)
1599+
return httpx.AsyncClient(timeout=timeout)
1600+
1601+
15841602
class AsyncBaseCohere:
15851603
"""
15861604
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
@@ -1604,6 +1622,9 @@ class AsyncBaseCohere:
16041622
headers : typing.Optional[typing.Dict[str, str]]
16051623
Additional headers to send with every request.
16061624
1625+
async_token : typing.Optional[typing.Callable[[], typing.Awaitable[str]]]
1626+
An async callable that returns a bearer token. Use this when token acquisition involves async I/O (e.g., refreshing tokens via an async HTTP client). When provided, this is used instead of the synchronous token for async requests.
1627+
16071628
timeout : typing.Optional[float]
16081629
The timeout to be used, in seconds, for requests. By default the timeout is 300 seconds, unless a custom httpx client is used, in which case this default is not enforced.
16091630
@@ -1634,6 +1655,7 @@ def __init__(
16341655
client_name: typing.Optional[str] = None,
16351656
token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = os.getenv("CO_API_KEY"),
16361657
headers: typing.Optional[typing.Dict[str, str]] = None,
1658+
async_token: typing.Optional[typing.Callable[[], typing.Awaitable[str]]] = None,
16371659
timeout: typing.Optional[float] = None,
16381660
follow_redirects: typing.Optional[bool] = True,
16391661
httpx_client: typing.Optional[httpx.AsyncClient] = None,
@@ -1649,11 +1671,10 @@ def __init__(
16491671
client_name=client_name,
16501672
token=token,
16511673
headers=headers,
1674+
async_token=async_token,
16521675
httpx_client=httpx_client
16531676
if httpx_client is not None
1654-
else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
1655-
if follow_redirects is not None
1656-
else httpx.AsyncClient(timeout=_defaulted_timeout),
1677+
else _make_default_async_client(timeout=_defaulted_timeout, follow_redirects=follow_redirects),
16571678
timeout=_defaulted_timeout,
16581679
logging=logging,
16591680
)

src/cohere/batches/types/cancel_batch_response.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
import typing
44

55
CancelBatchResponse = typing.Dict[str, typing.Any]
6+
"""
7+
Response to a request to cancel a batch.
8+
"""

src/cohere/core/client_wrapper.py

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

3131
headers: typing.Dict[str, str] = {
32-
"User-Agent": "cohere/5.21.2",
32+
"User-Agent": "cohere/6.0.0",
3333
"X-Fern-Language": "Python",
3434
"X-Fern-Runtime": f"python/{platform.python_version()}",
3535
"X-Fern-Platform": f"{platform.system().lower()}/{platform.release()}",
3636
"X-Fern-SDK-Name": "cohere",
37-
"X-Fern-SDK-Version": "5.21.2",
37+
"X-Fern-SDK-Version": "6.0.0",
3838
**(self.get_custom_headers() or {}),
3939
}
4040
if self._client_name is not None:

0 commit comments

Comments
 (0)