Skip to content

Commit 372bb05

Browse files
committed
SDK regeneration
1 parent c3314b2 commit 372bb05

33 files changed

+607
-177
lines changed

.github/workflows/tests.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Test SDK
2+
3+
on: [push]
4+
jobs:
5+
compile:
6+
runs-on: ubuntu-20.04
7+
steps:
8+
- name: Checkout repo
9+
uses: actions/checkout@v3
10+
- name: Set up python
11+
uses: actions/setup-python@v4
12+
with:
13+
python-version: 3.8
14+
- name: Bootstrap poetry
15+
run: |
16+
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
17+
- name: Install dependencies
18+
run: poetry install
19+
- name: Compile
20+
run: poetry run mypy .
21+
test:
22+
runs-on: ubuntu-20.04
23+
steps:
24+
- name: Checkout repo
25+
uses: actions/checkout@v3
26+
- name: Set up python
27+
uses: actions/setup-python@v4
28+
with:
29+
python-version: 3.8
30+
- name: Bootstrap poetry
31+
run: |
32+
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
33+
- name: Install dependencies
34+
run: poetry install
35+
36+
- name: Install Fern
37+
run: npm install -g fern-api
38+
39+
- name: Test
40+
run: |
41+
poetry run pytest .

poetry.lock

Lines changed: 44 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "cohere"
3-
version = "5.0.0a10"
3+
version = "5.0.0a11"
44
description = ""
55
readme = "README.md"
66
authors = []
@@ -17,6 +17,16 @@ typing_extensions = ">= 4.0.0"
1717
[tool.poetry.dev-dependencies]
1818
mypy = "^1.8.0"
1919
pytest = "^7.4.0"
20+
pytest-asyncio = "^0.23.5"
21+
python-dateutil = "^2.9.0"
22+
23+
[tool.pytest.ini_options]
24+
testpaths = [ "tests" ]
25+
asyncio_mode = "auto"
26+
27+
[tool.mypy]
28+
plugins = ["pydantic.mypy"]
29+
2030

2131
[build-system]
2232
requires = ["poetry-core"]

src/cohere/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
from .client import AsyncClient, Client
125125
from .datasets import DatasetsCreateResponse, DatasetsGetResponse, DatasetsGetUsageResponse, DatasetsListResponse
126126
from .embed_jobs import CreateEmbedJobRequestTruncate
127-
from .environment import CohereEnvironment
127+
from .environment import ClientEnvironment
128128

129129
__all__ = [
130130
"ApiMeta",
@@ -169,7 +169,7 @@
169169
"ClassifyResponseClassificationsItemClassificationType",
170170
"ClassifyResponseClassificationsItemLabelsValue",
171171
"Client",
172-
"CohereEnvironment",
172+
"ClientEnvironment",
173173
"CompatibleEndpoint",
174174
"Connector",
175175
"ConnectorAuthStatus",

src/cohere/base_client.py

Lines changed: 374 additions & 106 deletions
Large diffs are not rendered by default.

src/cohere/connectors/client.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ def list(
5353
5454
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
5555
---
56-
from cohere.client import Cohere
56+
from cohere.client import Client
5757
58-
client = Cohere(
58+
client = Client(
5959
client_name="YOUR_CLIENT_NAME",
6060
token="YOUR_TOKEN",
6161
)
@@ -140,9 +140,9 @@ def create(
140140
141141
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
142142
---
143-
from cohere.client import Cohere
143+
from cohere.client import Client
144144
145-
client = Cohere(
145+
client = Client(
146146
client_name="YOUR_CLIENT_NAME",
147147
token="YOUR_TOKEN",
148148
)
@@ -215,9 +215,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non
215215
216216
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
217217
---
218-
from cohere.client import Cohere
218+
from cohere.client import Client
219219
220-
client = Cohere(
220+
client = Client(
221221
client_name="YOUR_CLIENT_NAME",
222222
token="YOUR_TOKEN",
223223
)
@@ -270,9 +270,9 @@ def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] =
270270
271271
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
272272
---
273-
from cohere.client import Cohere
273+
from cohere.client import Client
274274
275-
client = Cohere(
275+
client = Client(
276276
client_name="YOUR_CLIENT_NAME",
277277
token="YOUR_TOKEN",
278278
)
@@ -353,9 +353,9 @@ def update(
353353
354354
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
355355
---
356-
from cohere.client import Cohere
356+
from cohere.client import Client
357357
358-
client = Cohere(
358+
client = Client(
359359
client_name="YOUR_CLIENT_NAME",
360360
token="YOUR_TOKEN",
361361
)
@@ -439,9 +439,9 @@ def o_auth_authorize(
439439
440440
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
441441
---
442-
from cohere.client import Cohere
442+
from cohere.client import Client
443443
444-
client = Cohere(
444+
client = Client(
445445
client_name="YOUR_CLIENT_NAME",
446446
token="YOUR_TOKEN",
447447
)
@@ -521,9 +521,9 @@ async def list(
521521
522522
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
523523
---
524-
from cohere.client import AsyncCohere
524+
from cohere.client import AsyncClient
525525
526-
client = AsyncCohere(
526+
client = AsyncClient(
527527
client_name="YOUR_CLIENT_NAME",
528528
token="YOUR_TOKEN",
529529
)
@@ -608,9 +608,9 @@ async def create(
608608
609609
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
610610
---
611-
from cohere.client import AsyncCohere
611+
from cohere.client import AsyncClient
612612
613-
client = AsyncCohere(
613+
client = AsyncClient(
614614
client_name="YOUR_CLIENT_NAME",
615615
token="YOUR_TOKEN",
616616
)
@@ -683,9 +683,9 @@ async def get(self, id: str, *, request_options: typing.Optional[RequestOptions]
683683
684684
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
685685
---
686-
from cohere.client import AsyncCohere
686+
from cohere.client import AsyncClient
687687
688-
client = AsyncCohere(
688+
client = AsyncClient(
689689
client_name="YOUR_CLIENT_NAME",
690690
token="YOUR_TOKEN",
691691
)
@@ -740,9 +740,9 @@ async def delete(
740740
741741
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
742742
---
743-
from cohere.client import AsyncCohere
743+
from cohere.client import AsyncClient
744744
745-
client = AsyncCohere(
745+
client = AsyncClient(
746746
client_name="YOUR_CLIENT_NAME",
747747
token="YOUR_TOKEN",
748748
)
@@ -823,9 +823,9 @@ async def update(
823823
824824
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
825825
---
826-
from cohere.client import AsyncCohere
826+
from cohere.client import AsyncClient
827827
828-
client = AsyncCohere(
828+
client = AsyncClient(
829829
client_name="YOUR_CLIENT_NAME",
830830
token="YOUR_TOKEN",
831831
)
@@ -909,9 +909,9 @@ async def o_auth_authorize(
909909
910910
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
911911
---
912-
from cohere.client import AsyncCohere
912+
from cohere.client import AsyncClient
913913
914-
client = AsyncCohere(
914+
client = AsyncClient(
915915
client_name="YOUR_CLIENT_NAME",
916916
token="YOUR_TOKEN",
917917
)

src/cohere/core/client_wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def get_headers(self) -> typing.Dict[str, str]:
2323
headers: typing.Dict[str, str] = {
2424
"X-Fern-Language": "Python",
2525
"X-Fern-SDK-Name": "cohere",
26-
"X-Fern-SDK-Version": "5.0.0a10",
26+
"X-Fern-SDK-Version": "5.0.0a11",
2727
}
2828
if self._client_name is not None:
2929
headers["X-Client-Name"] = self._client_name

src/cohere/core/http_client.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import re
66
import time
77
import typing
8+
from contextlib import asynccontextmanager, contextmanager
89
from functools import wraps
910
from random import random
1011

@@ -98,8 +99,10 @@ def request(
9899
return response
99100

100101
@wraps(httpx.Client.stream)
102+
@contextmanager
101103
def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any:
102-
return self.httpx_client.stream(*args, **kwargs)
104+
with self.httpx_client.stream(*args, **kwargs) as stream:
105+
yield stream
103106

104107

105108
class AsyncHttpClient:
@@ -118,8 +121,10 @@ async def request(
118121
return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs)
119122
return response
120123

121-
@wraps(httpx.AsyncClient.request)
124+
@wraps(httpx.AsyncClient.stream)
125+
@asynccontextmanager
122126
async def stream(
123127
self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any
124128
) -> typing.Any:
125-
return self.httpx_client.stream(*args, **kwargs)
129+
async with self.httpx_client.stream(*args, **kwargs) as stream:
130+
yield stream

src/cohere/core/jsonable_encoder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any]
6565
return str(obj)
6666
if isinstance(obj, (str, int, float, type(None))):
6767
return obj
68-
if isinstance(obj, dt.date):
69-
return str(obj)
7068
if isinstance(obj, dt.datetime):
7169
return serialize_datetime(obj)
70+
if isinstance(obj, dt.date):
71+
return str(obj)
7272
if isinstance(obj, dict):
7373
encoded_dict = {}
7474
allowed_keys = set(obj.keys())

0 commit comments

Comments
 (0)