Skip to content

Commit

Permalink
SDK regeneration (#509)
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] authored May 23, 2024
1 parent a5e9f0c commit 457f5d7
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 32 deletions.
20 changes: 10 additions & 10 deletions poetry.lock

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

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cohere"
version = "5.5.2"
version = "5.5.3"
description = ""
readme = "README.md"
authors = []
Expand Down
28 changes: 14 additions & 14 deletions src/cohere/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

class BaseCohere:
"""
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions.
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.
Parameters
----------
Expand Down Expand Up @@ -164,7 +164,7 @@ def chat_stream(
) -> typing.Iterator[StreamedChatResponse]:
"""
Generates a text response to a user message.
To learn how to use Chat with Streaming and RAG follow [this guide](https://docs.cohere.com/docs/cochat-beta#various-ways-of-using-the-chat-endpoint).
To learn how to use the Chat API with Streaming and RAG follow our [Text Generation guides](https://docs.cohere.com/docs/chat-api).
Parameters
----------
Expand Down Expand Up @@ -460,7 +460,7 @@ def chat_stream(
for chunk in response:
yield chunk
"""
_request: typing.Dict[str, typing.Any] = {"message": message}
_request: typing.Dict[str, typing.Any] = {"message": message, "stream": True}
if model is not OMIT:
_request["model"] = model
if preamble is not OMIT:
Expand Down Expand Up @@ -583,7 +583,7 @@ def chat(
) -> NonStreamedChatResponse:
"""
Generates a text response to a user message.
To learn how to use Chat with Streaming and RAG follow [this guide](https://docs.cohere.com/docs/cochat-beta#various-ways-of-using-the-chat-endpoint).
To learn how to use the Chat API with Streaming and RAG follow our [Text Generation guides](https://docs.cohere.com/docs/chat-api).
Parameters
----------
Expand Down Expand Up @@ -803,7 +803,7 @@ def chat(
temperature=0.3,
)
"""
_request: typing.Dict[str, typing.Any] = {"message": message}
_request: typing.Dict[str, typing.Any] = {"message": message, "stream": False}
if model is not OMIT:
_request["model"] = model
if preamble is not OMIT:
Expand Down Expand Up @@ -1038,7 +1038,7 @@ def generate_stream(
for chunk in response:
yield chunk
"""
_request: typing.Dict[str, typing.Any] = {"prompt": prompt}
_request: typing.Dict[str, typing.Any] = {"prompt": prompt, "stream": True}
if model is not OMIT:
_request["model"] = model
if num_generations is not OMIT:
Expand Down Expand Up @@ -1253,7 +1253,7 @@ def generate(
prompt="Please explain to me how LLMs work",
)
"""
_request: typing.Dict[str, typing.Any] = {"prompt": prompt}
_request: typing.Dict[str, typing.Any] = {"prompt": prompt, "stream": False}
if model is not OMIT:
_request["model"] = model
if num_generations is not OMIT:
Expand Down Expand Up @@ -2084,7 +2084,7 @@ def check_api_key(self, *, request_options: typing.Optional[RequestOptions] = No

class AsyncBaseCohere:
"""
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions.
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.
Parameters
----------
Expand Down Expand Up @@ -2183,7 +2183,7 @@ async def chat_stream(
) -> typing.AsyncIterator[StreamedChatResponse]:
"""
Generates a text response to a user message.
To learn how to use Chat with Streaming and RAG follow [this guide](https://docs.cohere.com/docs/cochat-beta#various-ways-of-using-the-chat-endpoint).
To learn how to use the Chat API with Streaming and RAG follow our [Text Generation guides](https://docs.cohere.com/docs/chat-api).
Parameters
----------
Expand Down Expand Up @@ -2479,7 +2479,7 @@ async def chat_stream(
async for chunk in response:
yield chunk
"""
_request: typing.Dict[str, typing.Any] = {"message": message}
_request: typing.Dict[str, typing.Any] = {"message": message, "stream": True}
if model is not OMIT:
_request["model"] = model
if preamble is not OMIT:
Expand Down Expand Up @@ -2602,7 +2602,7 @@ async def chat(
) -> NonStreamedChatResponse:
"""
Generates a text response to a user message.
To learn how to use Chat with Streaming and RAG follow [this guide](https://docs.cohere.com/docs/cochat-beta#various-ways-of-using-the-chat-endpoint).
To learn how to use the Chat API with Streaming and RAG follow our [Text Generation guides](https://docs.cohere.com/docs/chat-api).
Parameters
----------
Expand Down Expand Up @@ -2822,7 +2822,7 @@ async def chat(
temperature=0.3,
)
"""
_request: typing.Dict[str, typing.Any] = {"message": message}
_request: typing.Dict[str, typing.Any] = {"message": message, "stream": False}
if model is not OMIT:
_request["model"] = model
if preamble is not OMIT:
Expand Down Expand Up @@ -3057,7 +3057,7 @@ async def generate_stream(
async for chunk in response:
yield chunk
"""
_request: typing.Dict[str, typing.Any] = {"prompt": prompt}
_request: typing.Dict[str, typing.Any] = {"prompt": prompt, "stream": True}
if model is not OMIT:
_request["model"] = model
if num_generations is not OMIT:
Expand Down Expand Up @@ -3272,7 +3272,7 @@ async def generate(
prompt="Please explain to me how LLMs work",
)
"""
_request: typing.Dict[str, typing.Any] = {"prompt": prompt}
_request: typing.Dict[str, typing.Any] = {"prompt": prompt, "stream": False}
if model is not OMIT:
_request["model"] = model
if num_generations is not OMIT:
Expand Down
6 changes: 6 additions & 0 deletions src/cohere/connectors/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] =
request_options.get("additional_query_parameters") if request_options is not None else None
)
),
json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))
if request_options is not None
else None,
headers=jsonable_encoder(
remove_none_from_dict(
{
Expand Down Expand Up @@ -968,6 +971,9 @@ async def delete(
request_options.get("additional_query_parameters") if request_options is not None else None
)
),
json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))
if request_options is not None
else None,
headers=jsonable_encoder(
remove_none_from_dict(
{
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 @@ -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.2",
"X-Fern-SDK-Version": "5.5.3",
}
if self._client_name is not None:
headers["X-Client-Name"] = self._client_name
Expand Down
42 changes: 36 additions & 6 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 pydantic_v1
from .pydantic_utilities import IS_PYDANTIC_V2, pydantic_v1


class UnionMetadata:
Expand Down Expand Up @@ -60,6 +60,7 @@ def construct(
else:
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:
default = field.get_default()
fields_values[name] = default
Expand All @@ -71,10 +72,19 @@ def construct(
_fields_set.add(key)

# Add extras back in
_extra = {}
for key, value in values.items():
if key not in cls.__fields__:
_fields_set.add(key)
fields_values[key] = value
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)

object.__setattr__(m, "__dict__", fields_values)
object.__setattr__(m, "__fields_set__", _fields_set)
Expand Down Expand Up @@ -144,8 +154,12 @@ def construct_type(*, type_: typing.Type[typing.Any], object_: typing.Any) -> ty
if not isinstance(object_, typing.Mapping):
return object_

_, items_type = pydantic_v1.typing.get_args(type_)
return {key: construct_type(object_=item, type_=items_type) for key, item in object_.items()}
key_type, items_type = pydantic_v1.typing.get_args(type_)
d = {
construct_type(object_=key, type_=key_type): construct_type(object_=item, type_=items_type)
for key, item in object_.items()
}
return d

if base_type == list:
if not isinstance(object_, list):
Expand Down Expand Up @@ -190,4 +204,20 @@ def construct_type(*, type_: typing.Type[typing.Any], object_: typing.Any) -> ty
except Exception:
return object_

if base_type == int:
try:
return int(object_)
except Exception:
return object_

if base_type == bool:
try:
if isinstance(object_, str):
stringified_object = object_.lower()
return stringified_object == "true" or stringified_object == "1"

return bool(object_)
except Exception:
return object_

return object_
6 changes: 6 additions & 0 deletions src/cohere/datasets/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ def delete(
request_options.get("additional_query_parameters") if request_options is not None else None
)
),
json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))
if request_options is not None
else None,
headers=jsonable_encoder(
remove_none_from_dict(
{
Expand Down Expand Up @@ -844,6 +847,9 @@ async def delete(
request_options.get("additional_query_parameters") if request_options is not None else None
)
),
json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))
if request_options is not None
else None,
headers=jsonable_encoder(
remove_none_from_dict(
{
Expand Down
6 changes: 6 additions & 0 deletions src/cohere/finetuning/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@ def delete_finetuned_model(
request_options.get("additional_query_parameters") if request_options is not None else None
)
),
json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))
if request_options is not None
else None,
headers=jsonable_encoder(
remove_none_from_dict(
{
Expand Down Expand Up @@ -1127,6 +1130,9 @@ async def delete_finetuned_model(
request_options.get("additional_query_parameters") if request_options is not None else None
)
),
json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))
if request_options is not None
else None,
headers=jsonable_encoder(
remove_none_from_dict(
{
Expand Down

0 comments on commit 457f5d7

Please sign in to comment.