Skip to content

Commit

Permalink
SDK regeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Mar 18, 2024
1 parent c3314b2 commit 372bb05
Show file tree
Hide file tree
Showing 33 changed files with 607 additions and 177 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test SDK

on: [push]
jobs:
compile:
runs-on: ubuntu-20.04
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
- name: Install dependencies
run: poetry install
- name: Compile
run: poetry run mypy .
test:
runs-on: ubuntu-20.04
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
- name: Install dependencies
run: poetry install

- name: Install Fern
run: npm install -g fern-api

- name: Test
run: |
poetry run pytest .
45 changes: 44 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cohere"
version = "5.0.0a10"
version = "5.0.0a11"
description = ""
readme = "README.md"
authors = []
Expand All @@ -17,6 +17,16 @@ typing_extensions = ">= 4.0.0"
[tool.poetry.dev-dependencies]
mypy = "^1.8.0"
pytest = "^7.4.0"
pytest-asyncio = "^0.23.5"
python-dateutil = "^2.9.0"

[tool.pytest.ini_options]
testpaths = [ "tests" ]
asyncio_mode = "auto"

[tool.mypy]
plugins = ["pydantic.mypy"]


[build-system]
requires = ["poetry-core"]
Expand Down
4 changes: 2 additions & 2 deletions src/cohere/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
from .client import AsyncClient, Client
from .datasets import DatasetsCreateResponse, DatasetsGetResponse, DatasetsGetUsageResponse, DatasetsListResponse
from .embed_jobs import CreateEmbedJobRequestTruncate
from .environment import CohereEnvironment
from .environment import ClientEnvironment

__all__ = [
"ApiMeta",
Expand Down Expand Up @@ -169,7 +169,7 @@
"ClassifyResponseClassificationsItemClassificationType",
"ClassifyResponseClassificationsItemLabelsValue",
"Client",
"CohereEnvironment",
"ClientEnvironment",
"CompatibleEndpoint",
"Connector",
"ConnectorAuthStatus",
Expand Down
480 changes: 374 additions & 106 deletions src/cohere/base_client.py

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions src/cohere/connectors/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def list(
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from cohere.client import Cohere
from cohere.client import Client
client = Cohere(
client = Client(
client_name="YOUR_CLIENT_NAME",
token="YOUR_TOKEN",
)
Expand Down Expand Up @@ -140,9 +140,9 @@ def create(
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from cohere.client import Cohere
from cohere.client import Client
client = Cohere(
client = Client(
client_name="YOUR_CLIENT_NAME",
token="YOUR_TOKEN",
)
Expand Down Expand Up @@ -215,9 +215,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from cohere.client import Cohere
from cohere.client import Client
client = Cohere(
client = Client(
client_name="YOUR_CLIENT_NAME",
token="YOUR_TOKEN",
)
Expand Down Expand Up @@ -270,9 +270,9 @@ def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] =
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from cohere.client import Cohere
from cohere.client import Client
client = Cohere(
client = Client(
client_name="YOUR_CLIENT_NAME",
token="YOUR_TOKEN",
)
Expand Down Expand Up @@ -353,9 +353,9 @@ def update(
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from cohere.client import Cohere
from cohere.client import Client
client = Cohere(
client = Client(
client_name="YOUR_CLIENT_NAME",
token="YOUR_TOKEN",
)
Expand Down Expand Up @@ -439,9 +439,9 @@ def o_auth_authorize(
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from cohere.client import Cohere
from cohere.client import Client
client = Cohere(
client = Client(
client_name="YOUR_CLIENT_NAME",
token="YOUR_TOKEN",
)
Expand Down Expand Up @@ -521,9 +521,9 @@ async def list(
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from cohere.client import AsyncCohere
from cohere.client import AsyncClient
client = AsyncCohere(
client = AsyncClient(
client_name="YOUR_CLIENT_NAME",
token="YOUR_TOKEN",
)
Expand Down Expand Up @@ -608,9 +608,9 @@ async def create(
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from cohere.client import AsyncCohere
from cohere.client import AsyncClient
client = AsyncCohere(
client = AsyncClient(
client_name="YOUR_CLIENT_NAME",
token="YOUR_TOKEN",
)
Expand Down Expand Up @@ -683,9 +683,9 @@ async def get(self, id: str, *, request_options: typing.Optional[RequestOptions]
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from cohere.client import AsyncCohere
from cohere.client import AsyncClient
client = AsyncCohere(
client = AsyncClient(
client_name="YOUR_CLIENT_NAME",
token="YOUR_TOKEN",
)
Expand Down Expand Up @@ -740,9 +740,9 @@ async def delete(
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from cohere.client import AsyncCohere
from cohere.client import AsyncClient
client = AsyncCohere(
client = AsyncClient(
client_name="YOUR_CLIENT_NAME",
token="YOUR_TOKEN",
)
Expand Down Expand Up @@ -823,9 +823,9 @@ async def update(
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from cohere.client import AsyncCohere
from cohere.client import AsyncClient
client = AsyncCohere(
client = AsyncClient(
client_name="YOUR_CLIENT_NAME",
token="YOUR_TOKEN",
)
Expand Down Expand Up @@ -909,9 +909,9 @@ async def o_auth_authorize(
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
---
from cohere.client import AsyncCohere
from cohere.client import AsyncClient
client = AsyncCohere(
client = AsyncClient(
client_name="YOUR_CLIENT_NAME",
token="YOUR_TOKEN",
)
Expand Down
2 changes: 1 addition & 1 deletion src/cohere/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_headers(self) -> typing.Dict[str, str]:
headers: typing.Dict[str, str] = {
"X-Fern-Language": "Python",
"X-Fern-SDK-Name": "cohere",
"X-Fern-SDK-Version": "5.0.0a10",
"X-Fern-SDK-Version": "5.0.0a11",
}
if self._client_name is not None:
headers["X-Client-Name"] = self._client_name
Expand Down
11 changes: 8 additions & 3 deletions src/cohere/core/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import re
import time
import typing
from contextlib import asynccontextmanager, contextmanager
from functools import wraps
from random import random

Expand Down Expand Up @@ -98,8 +99,10 @@ def request(
return response

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


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

@wraps(httpx.AsyncClient.request)
@wraps(httpx.AsyncClient.stream)
@asynccontextmanager
async def stream(
self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any
) -> typing.Any:
return self.httpx_client.stream(*args, **kwargs)
async with self.httpx_client.stream(*args, **kwargs) as stream:
yield stream
4 changes: 2 additions & 2 deletions src/cohere/core/jsonable_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any]
return str(obj)
if isinstance(obj, (str, int, float, type(None))):
return obj
if isinstance(obj, dt.date):
return str(obj)
if isinstance(obj, dt.datetime):
return serialize_datetime(obj)
if isinstance(obj, dt.date):
return str(obj)
if isinstance(obj, dict):
encoded_dict = {}
allowed_keys = set(obj.keys())
Expand Down
Loading

0 comments on commit 372bb05

Please sign in to comment.