diff --git a/poetry.lock b/poetry.lock index c8a61e9df..a71b7a656 100644 --- a/poetry.lock +++ b/poetry.lock @@ -236,13 +236,13 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "pydantic" -version = "2.6.2" +version = "2.6.3" description = "Data validation using Python type hints" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic-2.6.2-py3-none-any.whl", hash = "sha256:37a5432e54b12fecaa1049c5195f3d860a10e01bdfd24f1840ef14bd0d3aeab3"}, - {file = "pydantic-2.6.2.tar.gz", hash = "sha256:a09be1c3d28f3abe37f8a78af58284b236a92ce520105ddc91a6d29ea1176ba7"}, + {file = "pydantic-2.6.3-py3-none-any.whl", hash = "sha256:72c6034df47f46ccdf81869fddb81aade68056003900a8724a4f160700016a2a"}, + {file = "pydantic-2.6.3.tar.gz", hash = "sha256:e07805c4c7f5c6826e33a1d4c9d47950d7eaf34868e2690f8594d2e30241f11f"}, ] [package.dependencies] @@ -368,13 +368,13 @@ testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "no [[package]] name = "sniffio" -version = "1.3.0" +version = "1.3.1" description = "Sniff out which async library your code is running under" optional = false python-versions = ">=3.7" files = [ - {file = "sniffio-1.3.0-py3-none-any.whl", hash = "sha256:eecefdce1e5bbfb7ad2eeaabf7c1eeb404d7757c379bd1f7e5cce9d8bf425384"}, - {file = "sniffio-1.3.0.tar.gz", hash = "sha256:e60305c5e5d314f5389259b7f22aaa33d8f7dee49763119234af3755c55b9101"}, + {file = "sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2"}, + {file = "sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc"}, ] [[package]] @@ -390,13 +390,13 @@ files = [ [[package]] name = "typing-extensions" -version = "4.9.0" +version = "4.10.0" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.9.0-py3-none-any.whl", hash = "sha256:af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd"}, - {file = "typing_extensions-4.9.0.tar.gz", hash = "sha256:23478f88c37f27d76ac8aee6c905017a143b0b1b886c3c9f66bc2fd94f9f5783"}, + {file = "typing_extensions-4.10.0-py3-none-any.whl", hash = "sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475"}, + {file = "typing_extensions-4.10.0.tar.gz", hash = "sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb"}, ] [metadata] diff --git a/pyproject.toml b/pyproject.toml index 2e5f0d3a4..c7e3b30c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cohere" -version = "5.0.0a7" +version = "5.0.0a8" description = "" readme = "README.md" authors = [] diff --git a/src/cohere/__init__.py b/src/cohere/__init__.py index bebe2ca81..6b560db75 100644 --- a/src/cohere/__init__.py +++ b/src/cohere/__init__.py @@ -109,10 +109,8 @@ SummarizeResponse, TokenizeResponse, Tool, - ToolDefinition, - ToolDefinitionInputsItem, - ToolDefinitionOutputsItem, ToolInput, + ToolParameterDefinitionsValue, UpdateConnectorResponse, ) from .errors import BadRequestError, ForbiddenError, InternalServerError, NotFoundError, TooManyRequestsError @@ -252,10 +250,8 @@ "TokenizeResponse", "TooManyRequestsError", "Tool", - "ToolDefinition", - "ToolDefinitionInputsItem", - "ToolDefinitionOutputsItem", "ToolInput", + "ToolParameterDefinitionsValue", "UpdateConnectorResponse", "connectors", "datasets", diff --git a/src/cohere/base_client.py b/src/cohere/base_client.py index a7071e99d..6e68ad513 100644 --- a/src/cohere/base_client.py +++ b/src/cohere/base_client.py @@ -127,6 +127,7 @@ def chat_stream( p: typing.Optional[float] = OMIT, frequency_penalty: typing.Optional[float] = OMIT, presence_penalty: typing.Optional[float] = OMIT, + raw_prompting: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> typing.Iterator[StreamedChatResponse]: """ @@ -204,6 +205,8 @@ def chat_stream( Used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty`, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies. + - raw_prompting: typing.Optional[bool]. When enabled, the user's prompt will be sent to the model without any pre-processing. + - request_options: typing.Optional[RequestOptions]. Request-specific configuration. """ _request: typing.Dict[str, typing.Any] = {"message": message, "stream": True} @@ -235,6 +238,8 @@ def chat_stream( _request["frequency_penalty"] = frequency_penalty if presence_penalty is not OMIT: _request["presence_penalty"] = presence_penalty + if raw_prompting is not OMIT: + _request["raw_prompting"] = raw_prompting with self._client_wrapper.httpx_client.stream( "POST", urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "chat"), @@ -292,6 +297,7 @@ def chat( p: typing.Optional[float] = OMIT, frequency_penalty: typing.Optional[float] = OMIT, presence_penalty: typing.Optional[float] = OMIT, + raw_prompting: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> NonStreamedChatResponse: """ @@ -369,6 +375,8 @@ def chat( Used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty`, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies. + - raw_prompting: typing.Optional[bool]. When enabled, the user's prompt will be sent to the model without any pre-processing. + - request_options: typing.Optional[RequestOptions]. Request-specific configuration. --- from cohere import ChatMessage, ChatMessageRole, ChatRequestPromptTruncation @@ -427,6 +435,8 @@ def chat( _request["frequency_penalty"] = frequency_penalty if presence_penalty is not OMIT: _request["presence_penalty"] = presence_penalty + if raw_prompting is not OMIT: + _request["raw_prompting"] = raw_prompting _response = self._client_wrapper.httpx_client.request( "POST", urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "chat"), @@ -1368,6 +1378,7 @@ async def chat_stream( p: typing.Optional[float] = OMIT, frequency_penalty: typing.Optional[float] = OMIT, presence_penalty: typing.Optional[float] = OMIT, + raw_prompting: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> typing.AsyncIterator[StreamedChatResponse]: """ @@ -1445,6 +1456,8 @@ async def chat_stream( Used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty`, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies. + - raw_prompting: typing.Optional[bool]. When enabled, the user's prompt will be sent to the model without any pre-processing. + - request_options: typing.Optional[RequestOptions]. Request-specific configuration. """ _request: typing.Dict[str, typing.Any] = {"message": message, "stream": True} @@ -1476,6 +1489,8 @@ async def chat_stream( _request["frequency_penalty"] = frequency_penalty if presence_penalty is not OMIT: _request["presence_penalty"] = presence_penalty + if raw_prompting is not OMIT: + _request["raw_prompting"] = raw_prompting async with self._client_wrapper.httpx_client.stream( "POST", urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "chat"), @@ -1533,6 +1548,7 @@ async def chat( p: typing.Optional[float] = OMIT, frequency_penalty: typing.Optional[float] = OMIT, presence_penalty: typing.Optional[float] = OMIT, + raw_prompting: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> NonStreamedChatResponse: """ @@ -1610,6 +1626,8 @@ async def chat( Used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty`, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies. + - raw_prompting: typing.Optional[bool]. When enabled, the user's prompt will be sent to the model without any pre-processing. + - request_options: typing.Optional[RequestOptions]. Request-specific configuration. --- from cohere import ChatMessage, ChatMessageRole, ChatRequestPromptTruncation @@ -1668,6 +1686,8 @@ async def chat( _request["frequency_penalty"] = frequency_penalty if presence_penalty is not OMIT: _request["presence_penalty"] = presence_penalty + if raw_prompting is not OMIT: + _request["raw_prompting"] = raw_prompting _response = await self._client_wrapper.httpx_client.request( "POST", urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "chat"), diff --git a/src/cohere/core/client_wrapper.py b/src/cohere/core/client_wrapper.py index bef9b5dac..5cf0d4dce 100644 --- a/src/cohere/core/client_wrapper.py +++ b/src/cohere/core/client_wrapper.py @@ -21,7 +21,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.0a7", + "X-Fern-SDK-Version": "5.0.0a8", } if self._client_name is not None: headers["X-Client-Name"] = self._client_name diff --git a/src/cohere/types/__init__.py b/src/cohere/types/__init__.py index bd83404d3..246d69ee4 100644 --- a/src/cohere/types/__init__.py +++ b/src/cohere/types/__init__.py @@ -112,10 +112,8 @@ from .summarize_response import SummarizeResponse from .tokenize_response import TokenizeResponse from .tool import Tool -from .tool_definition import ToolDefinition -from .tool_definition_inputs_item import ToolDefinitionInputsItem -from .tool_definition_outputs_item import ToolDefinitionOutputsItem from .tool_input import ToolInput +from .tool_parameter_definitions_value import ToolParameterDefinitionsValue from .update_connector_response import UpdateConnectorResponse __all__ = [ @@ -227,9 +225,7 @@ "SummarizeResponse", "TokenizeResponse", "Tool", - "ToolDefinition", - "ToolDefinitionInputsItem", - "ToolDefinitionOutputsItem", "ToolInput", + "ToolParameterDefinitionsValue", "UpdateConnectorResponse", ] diff --git a/src/cohere/types/tool.py b/src/cohere/types/tool.py index 9dd03d761..cd5d14df8 100644 --- a/src/cohere/types/tool.py +++ b/src/cohere/types/tool.py @@ -4,7 +4,7 @@ import typing from ..core.datetime_utils import serialize_datetime -from .tool_definition import ToolDefinition +from .tool_parameter_definitions_value import ToolParameterDefinitionsValue try: import pydantic.v1 as pydantic # type: ignore @@ -14,7 +14,8 @@ class Tool(pydantic.BaseModel): name: str - definition: typing.Optional[ToolDefinition] = None + description: str + parameter_definitions: typing.Optional[typing.Dict[str, ToolParameterDefinitionsValue]] = None def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} diff --git a/src/cohere/types/tool_definition.py b/src/cohere/types/tool_definition.py deleted file mode 100644 index fc75c59e9..000000000 --- a/src/cohere/types/tool_definition.py +++ /dev/null @@ -1,32 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ..core.datetime_utils import serialize_datetime -from .tool_definition_inputs_item import ToolDefinitionInputsItem -from .tool_definition_outputs_item import ToolDefinitionOutputsItem - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class ToolDefinition(pydantic.BaseModel): - description: str - inputs: typing.Optional[typing.List[ToolDefinitionInputsItem]] = None - outputs: typing.Optional[typing.List[ToolDefinitionOutputsItem]] = None - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) - - class Config: - frozen = True - smart_union = True - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/cohere/types/tool_definition_outputs_item.py b/src/cohere/types/tool_definition_outputs_item.py deleted file mode 100644 index 6281ee67e..000000000 --- a/src/cohere/types/tool_definition_outputs_item.py +++ /dev/null @@ -1,31 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ..core.datetime_utils import serialize_datetime - -try: - import pydantic.v1 as pydantic # type: ignore -except ImportError: - import pydantic # type: ignore - - -class ToolDefinitionOutputsItem(pydantic.BaseModel): - name: str - description: str - type: str - required: typing.Optional[bool] = None - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) - - class Config: - frozen = True - smart_union = True - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/cohere/types/tool_definition_inputs_item.py b/src/cohere/types/tool_parameter_definitions_value.py similarity index 93% rename from src/cohere/types/tool_definition_inputs_item.py rename to src/cohere/types/tool_parameter_definitions_value.py index 3df4d3683..b5a3977e2 100644 --- a/src/cohere/types/tool_definition_inputs_item.py +++ b/src/cohere/types/tool_parameter_definitions_value.py @@ -11,8 +11,7 @@ import pydantic # type: ignore -class ToolDefinitionInputsItem(pydantic.BaseModel): - name: str +class ToolParameterDefinitionsValue(pydantic.BaseModel): description: str type: str required: typing.Optional[bool] = None