Skip to content

Commit 160dd05

Browse files
fern-api[bot]fern-supportjsklan
authored
🌿 Fern Regeneration -- April 8, 2026 (#751)
* SDK regeneration * Update python version used in ci * nit * Add aiohttp test to ci * fix custom tests * nits * fix * nit * nit --------- Co-authored-by: fern-api[bot] <115122769+fern-api[bot]@users.noreply.github.com> Co-authored-by: fern-support <126544928+fern-support@users.noreply.github.com> Co-authored-by: jsklan <jsklan.development@gmail.com>
1 parent dcd81d8 commit 160dd05

24 files changed

Lines changed: 1513 additions & 388 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.63.2",
33
"generatorName": "fernapi/fern-python-sdk",
4-
"generatorVersion": "4.63.4",
4+
"generatorVersion": "5.3.3",
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": "f6bbd671944a203a435dd01ebe619dcb4e493503",
82+
"sdkVersion": "6.0.0"
8483
}

.github/workflows/ci.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- name: Set up python
1111
uses: actions/setup-python@v4
1212
with:
13-
python-version: 3.9
13+
python-version: "3.10"
1414
- name: Bootstrap poetry
1515
uses: snok/install-poetry@v1
1616
with:
@@ -28,7 +28,7 @@ jobs:
2828
- name: Set up python
2929
uses: actions/setup-python@v4
3030
with:
31-
python-version: 3.9
31+
python-version: "3.10"
3232
- name: Bootstrap poetry
3333
uses: snok/install-poetry@v1
3434
with:
@@ -39,9 +39,17 @@ jobs:
3939
- name: Install aws deps
4040
run: poetry run pip install boto3 sagemaker botocore
4141
- name: Test
42-
run: poetry run pytest .
42+
run: poetry run pytest -rP -n auto .
4343
env:
4444
CO_API_KEY: ${{ secrets.COHERE_API_KEY }}
45+
- name: Install aiohttp extra
46+
run: poetry install --extras aiohttp
47+
48+
- name: Test (aiohttp)
49+
run: poetry run pytest -rP -n auto -m aiohttp . || [ $? -eq 5 ]
50+
env:
51+
CO_API_KEY: ${{ secrets.COHERE_API_KEY }}
52+
4553
publish:
4654
needs: [compile, test]
4755
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
@@ -52,7 +60,7 @@ jobs:
5260
- name: Set up python
5361
uses: actions/setup-python@v4
5462
with:
55-
python-version: 3.9
63+
python-version: "3.10"
5664
- name: Bootstrap poetry
5765
run: |
5866
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1

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"]

reference.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,7 +2309,7 @@ Follow the [Migration Guide](https://docs.cohere.com/v2/docs/migrating-v1-to-v2)
23092309
<dd>
23102310

23112311
```python
2312-
from cohere import Client
2312+
from cohere import Client, ChatMessageV2_User
23132313
from cohere.environment import ClientEnvironment
23142314

23152315
client = Client(
@@ -2320,10 +2320,9 @@ client = Client(
23202320
client.v2.chat_stream(
23212321
model="command-a-03-2025",
23222322
messages=[
2323-
{
2324-
"role": "user",
2325-
"content": "Tell me about LLMs"
2326-
}
2323+
ChatMessageV2_User(
2324+
content="Tell me about LLMs",
2325+
)
23272326
],
23282327
)
23292328

@@ -2608,7 +2607,7 @@ Follow the [Migration Guide](https://docs.cohere.com/v2/docs/migrating-v1-to-v2)
26082607
<dd>
26092608

26102609
```python
2611-
from cohere import Client
2610+
from cohere import Client, ChatMessageV2_User
26122611
from cohere.environment import ClientEnvironment
26132612

26142613
client = Client(
@@ -2619,10 +2618,9 @@ client = Client(
26192618
client.v2.chat_stream(
26202619
model="command-a-03-2025",
26212620
messages=[
2622-
{
2623-
"role": "user",
2624-
"content": "Tell me about LLMs"
2625-
}
2621+
ChatMessageV2_User(
2622+
content="Tell me about LLMs",
2623+
)
26262624
],
26272625
)
26282626

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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
Generation,
154154
GetConnectorResponse,
155155
GetModelResponse,
156+
GetModelResponseSamplingDefaults,
156157
Image,
157158
ImageContent,
158159
ImageUrl,
@@ -257,6 +258,7 @@
257258
UnprocessableEntityError,
258259
)
259260
from . import audio, batches, connectors, datasets, embed_jobs, finetuning, models, v2
261+
from ._default_clients import DefaultAioHttpClient, DefaultAsyncHttpxClient
260262
from .aliases import (
261263
ChatResponse,
262264
ContentDeltaStreamedChatResponseV2,
@@ -448,6 +450,8 @@
448450
"DatasetsListResponse": ".datasets",
449451
"DebugStreamedChatResponse": ".types",
450452
"DebugV2ChatStreamResponse": ".v2",
453+
"DefaultAioHttpClient": "._default_clients",
454+
"DefaultAsyncHttpxClient": "._default_clients",
451455
"DeleteConnectorResponse": ".types",
452456
"DetokenizeResponse": ".types",
453457
"Document": ".types",
@@ -490,6 +494,7 @@
490494
"GetBatchResponse": ".batches",
491495
"GetConnectorResponse": ".types",
492496
"GetModelResponse": ".types",
497+
"GetModelResponseSamplingDefaults": ".types",
493498
"Image": ".types",
494499
"ImageContent": ".types",
495500
"ImageUrl": ".types",
@@ -782,6 +787,8 @@ def __dir__():
782787
"DatasetsListResponse",
783788
"DebugStreamedChatResponse",
784789
"DebugV2ChatStreamResponse",
790+
"DefaultAioHttpClient",
791+
"DefaultAsyncHttpxClient",
785792
"DeleteConnectorResponse",
786793
"DetokenizeResponse",
787794
"Document",
@@ -824,6 +831,7 @@ def __dir__():
824831
"GetBatchResponse",
825832
"GetConnectorResponse",
826833
"GetModelResponse",
834+
"GetModelResponseSamplingDefaults",
827835
"Image",
828836
"ImageContent",
829837
"ImageUrl",

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+
"""

0 commit comments

Comments
 (0)