Skip to content

Commit

Permalink
SDK regeneration (#530)
Browse files Browse the repository at this point in the history
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
  • Loading branch information
fern-api[bot] committed Jun 17, 2024
1 parent 0fc77bc commit f7c268f
Show file tree
Hide file tree
Showing 28 changed files with 2,331 additions and 228 deletions.
282 changes: 136 additions & 146 deletions poetry.lock

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cohere"
version = "5.5.7"
version = "5.5.8"
description = ""
readme = "README.md"
authors = []
Expand All @@ -27,9 +27,6 @@ packages = [
{ include = "cohere", from = "src"}
]

[tool.poetry.group.dev.dependencies]
parameterized = "^0.9.0"

[project.urls]
Repository = 'https://github.com/cohere-ai/cohere-python'

Expand All @@ -42,7 +39,7 @@ httpx-sse = "^0.4.0"
parameterized = "^0.9.0"
pydantic = ">= 1.9.2"
requests = "^2.0.0"
tokenizers = "^0.15"
tokenizers = ">=0.15,<1"
types-requests = "^2.0.0"
typing_extensions = ">= 4.0.0"

Expand Down
16 changes: 16 additions & 0 deletions src/cohere/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
ClassifyResponseClassificationsItem,
ClassifyResponseClassificationsItemClassificationType,
ClassifyResponseClassificationsItemLabelsValue,
ClientClosedRequestErrorBody,
CompatibleEndpoint,
Connector,
ConnectorAuthStatus,
Expand Down Expand Up @@ -66,6 +67,7 @@
EmbeddingType,
FinetuneDatasetMetrics,
FinishReason,
GatewayTimeoutErrorBody,
GenerateRequestReturnLikelihoods,
GenerateRequestTruncate,
GenerateStreamEnd,
Expand Down Expand Up @@ -95,6 +97,7 @@
MetricsEmbedData,
MetricsEmbedDataFieldsItem,
NonStreamedChatResponse,
NotImplementedErrorBody,
OAuthAuthorizeResponse,
ParseInfo,
RerankRequestDocumentsItem,
Expand Down Expand Up @@ -127,16 +130,21 @@
ToolMessage,
ToolParameterDefinitionsValue,
ToolResult,
UnprocessableEntityErrorBody,
UpdateConnectorResponse,
)
from .errors import (
BadRequestError,
ClientClosedRequestError,
ForbiddenError,
GatewayTimeoutError,
InternalServerError,
NotFoundError,
NotImplementedError,
ServiceUnavailableError,
TooManyRequestsError,
UnauthorizedError,
UnprocessableEntityError,
)
from . import connectors, datasets, embed_jobs, finetuning, models
from .aws_client import AwsClient
Expand Down Expand Up @@ -197,6 +205,8 @@
"ClassifyResponseClassificationsItemClassificationType",
"ClassifyResponseClassificationsItemLabelsValue",
"Client",
"ClientClosedRequestError",
"ClientClosedRequestErrorBody",
"ClientEnvironment",
"CompatibleEndpoint",
"Connector",
Expand Down Expand Up @@ -233,6 +243,8 @@
"FinetuneDatasetMetrics",
"FinishReason",
"ForbiddenError",
"GatewayTimeoutError",
"GatewayTimeoutErrorBody",
"GenerateRequestReturnLikelihoods",
"GenerateRequestTruncate",
"GenerateStreamEnd",
Expand Down Expand Up @@ -264,6 +276,8 @@
"MetricsEmbedDataFieldsItem",
"NonStreamedChatResponse",
"NotFoundError",
"NotImplementedError",
"NotImplementedErrorBody",
"OAuthAuthorizeResponse",
"ParseInfo",
"RerankRequestDocumentsItem",
Expand Down Expand Up @@ -300,6 +314,8 @@
"ToolParameterDefinitionsValue",
"ToolResult",
"UnauthorizedError",
"UnprocessableEntityError",
"UnprocessableEntityErrorBody",
"UpdateConnectorResponse",
"__version__",
"connectors",
Expand Down
812 changes: 812 additions & 0 deletions src/cohere/base_client.py

Large diffs are not rendered by default.

338 changes: 338 additions & 0 deletions src/cohere/connectors/client.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/cohere/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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.5.7",
"X-Fern-SDK-Version": "5.5.8",
}
if self._client_name is not None:
headers["X-Client-Name"] = self._client_name
Expand Down
6 changes: 5 additions & 1 deletion src/cohere/core/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ def maybe_filter_request_body(
omit: typing.Optional[typing.Any],
) -> typing.Optional[typing.Any]:
if data is None:
return None
return (
jsonable_encoder(request_options.get("additional_body_parameters", {}))
if request_options is not None
else None
)
elif not isinstance(data, typing.Mapping):
data_content = jsonable_encoder(data)
else:
Expand Down
38 changes: 14 additions & 24 deletions src/cohere/core/unchecked_base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import typing_extensions

from .datetime_utils import serialize_datetime
from .pydantic_utilities import IS_PYDANTIC_V2, pydantic_v1
from .pydantic_utilities import pydantic_v1


class UnionMetadata:
Expand Down Expand Up @@ -46,49 +46,39 @@ def construct(
_fields_set = set(values.keys())

for name, field in cls.__fields__.items():
# Key here is only used to pull data from the values dict
# you should always use the NAME of the field to for field_values, etc.
# because that's how the object is constructed from a pydantic perspective
key = field.alias
if (
if key is None or (
key not in values and config.allow_population_by_field_name
): # Added this to allow population by field name
key = name

if key in values:
if (
values[key] is None and not field.required
): # Moved this check since None value can be passed for Optional nested field
fields_values[name] = field.get_default()
else:
type_ = typing.cast(typing.Type, field.outer_type_) # type: ignore
fields_values[name] = construct_type(object_=values[key], type_=type_)
type_ = typing.cast(typing.Type, field.outer_type_) # type: ignore
fields_values[name] = construct_type(object_=values[key], type_=type_)
_fields_set.add(name)
elif not field.required:
else:
default = field.get_default()
fields_values[name] = default

# If the default values are non-null act like they've been set
# This effectively allows exclude_unset to work like exclude_none where
# the latter passes through intentionally set none values.
if default != None:
_fields_set.add(key)
_fields_set.add(name)

# Add extras back in
_extra = {}
alias_fields = [field.alias for field in cls.__fields__.values()]
for key, value in values.items():
if key not in _fields_set:
_extra[key] = value
# In v2 we'll need to exclude extra fields from fields_values
if not IS_PYDANTIC_V2:
_fields_set.add(key)
fields_values[key] = value

if IS_PYDANTIC_V2:
object.__setattr__(m, "__pydantic_private__", None)
object.__setattr__(m, "__pydantic_extra__", _extra)
object.__setattr__(m, "__pydantic_fields_set__", _fields_set)
if key not in alias_fields and key not in cls.__fields__:
_fields_set.add(key)
fields_values[key] = value

object.__setattr__(m, "__dict__", fields_values)
object.__setattr__(m, "__fields_set__", _fields_set)
m._init_private_attributes()
object.__setattr__(m, "__fields_set__", _fields_set)
return m


Expand Down
Loading

0 comments on commit f7c268f

Please sign in to comment.