diff --git a/.fern/metadata.json b/.fern/metadata.json index 896fe31d1..356cebb85 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,7 +1,7 @@ { - "cliVersion": "0.112.1", + "cliVersion": "3.50.1", "generatorName": "fernapi/fern-python-sdk", - "generatorVersion": "4.35.0", + "generatorVersion": "4.55.1", "generatorConfig": { "pyproject_python_version": "^3.9", "inline_request_params": false, @@ -78,5 +78,6 @@ ] } ] - } + }, + "sdkVersion": "5.20.5" } \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index ee8d6a8db..07a9ac43a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -205,6 +205,20 @@ typing-extensions = {version = ">=4.6.0", markers = "python_version < \"3.13\""} [package.extras] test = ["pytest (>=6)"] +[[package]] +name = "execnet" +version = "2.1.2" +description = "execnet: rapid multi-Python deployment" +optional = false +python-versions = ">=3.8" +files = [ + {file = "execnet-2.1.2-py3-none-any.whl", hash = "sha256:67fba928dd5a544b783f6056f449e5e3931a5c378b128bc18501f7ea79e296ec"}, + {file = "execnet-2.1.2.tar.gz", hash = "sha256:63d83bfdd9a23e35b9c6a3261412324f964c2ec8dcd8d3c6916ee9373e0befcd"}, +] + +[package.extras] +testing = ["hatch", "pre-commit", "pytest", "tox"] + [[package]] name = "fastavro" version = "1.12.1" @@ -408,13 +422,13 @@ zstd = ["zstandard (>=0.18.0)"] [[package]] name = "huggingface-hub" -version = "1.3.3" +version = "1.4.1" description = "Client library to download and publish models, datasets and other repos on the huggingface.co hub" optional = false python-versions = ">=3.9.0" files = [ - {file = "huggingface_hub-1.3.3-py3-none-any.whl", hash = "sha256:44af7b62380efc87c1c3bde7e1bf0661899b5bdfca1fc60975c61ee68410e10e"}, - {file = "huggingface_hub-1.3.3.tar.gz", hash = "sha256:f8be6f468da4470db48351e8c77d6d8115dff9b3daeb30276e568767b1ff7574"}, + {file = "huggingface_hub-1.4.1-py3-none-any.whl", hash = "sha256:9931d075fb7a79af5abc487106414ec5fba2c0ae86104c0c62fd6cae38873d18"}, + {file = "huggingface_hub-1.4.1.tar.gz", hash = "sha256:b41131ec35e631e7383ab26d6146b8d8972abc8b6309b963b306fbcca87f5ed5"}, ] [package.dependencies] @@ -750,6 +764,26 @@ pytest = ">=7.0.0,<9" docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1.0)"] testing = ["coverage (>=6.2)", "hypothesis (>=5.7.1)"] +[[package]] +name = "pytest-xdist" +version = "3.8.0" +description = "pytest xdist plugin for distributed testing, most importantly across multiple CPUs" +optional = false +python-versions = ">=3.9" +files = [ + {file = "pytest_xdist-3.8.0-py3-none-any.whl", hash = "sha256:202ca578cfeb7370784a8c33d6d05bc6e13b4f25b5053c30a152269fd10f0b88"}, + {file = "pytest_xdist-3.8.0.tar.gz", hash = "sha256:7e578125ec9bc6050861aa93f2d59f1d8d085595d6551c2c90b6f4fad8d3a9f1"}, +] + +[package.dependencies] +execnet = ">=2.1" +pytest = ">=7.0.0" + +[package.extras] +psutil = ["psutil (>=3.0)"] +setproctitle = ["setproctitle"] +testing = ["filelock"] + [[package]] name = "python-dateutil" version = "2.9.0.post0" @@ -1015,13 +1049,13 @@ files = [ [[package]] name = "tqdm" -version = "4.67.1" +version = "4.67.3" description = "Fast, Extensible Progress Meter" optional = false python-versions = ">=3.7" files = [ - {file = "tqdm-4.67.1-py3-none-any.whl", hash = "sha256:26445eca388f82e72884e0d580d5464cd801a3ea01e63e5601bdff9ba6a48de2"}, - {file = "tqdm-4.67.1.tar.gz", hash = "sha256:f8aef9c52c08c13a65f30ea34f4e5aac3fd1a34959879d7e59e63027286627f2"}, + {file = "tqdm-4.67.3-py3-none-any.whl", hash = "sha256:ee1e4c0e59148062281c49d80b25b67771a127c85fc9676d3be5f243206826bf"}, + {file = "tqdm-4.67.3.tar.gz", hash = "sha256:7d825f03f89244ef73f1d4ce193cb1774a8179fd96f31d7e1dcde62092b960bb"}, ] [package.dependencies] @@ -1054,13 +1088,13 @@ standard = ["rich (>=10.11.0)", "shellingham (>=1.3.0)"] [[package]] name = "types-python-dateutil" -version = "2.9.0.20251115" +version = "2.9.0.20260124" description = "Typing stubs for python-dateutil" optional = false python-versions = ">=3.9" files = [ - {file = "types_python_dateutil-2.9.0.20251115-py3-none-any.whl", hash = "sha256:9cf9c1c582019753b8639a081deefd7e044b9fa36bd8217f565c6c4e36ee0624"}, - {file = "types_python_dateutil-2.9.0.20251115.tar.gz", hash = "sha256:8a47f2c3920f52a994056b8786309b43143faa5a64d4cbb2722d6addabdf1a58"}, + {file = "types_python_dateutil-2.9.0.20260124-py3-none-any.whl", hash = "sha256:f802977ae08bf2260142e7ca1ab9d4403772a254409f7bbdf652229997124951"}, + {file = "types_python_dateutil-2.9.0.20260124.tar.gz", hash = "sha256:7d2db9f860820c30e5b8152bfe78dbdf795f7d1c6176057424e8b3fdd1f581af"}, ] [[package]] @@ -1122,4 +1156,4 @@ zstd = ["backports-zstd (>=1.0.0)"] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "7e6d31e1bd0c76d6c5f8e646e1f5e851e75860238cc06e85aa4169ae42bd5e89" +content-hash = "384b8db70da6095b11f9b3afddf8ff33e82021430de0a6d644dc1ed6e691c259" diff --git a/pyproject.toml b/pyproject.toml index 04a187b5c..d255f7dcf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,10 @@ [project] name = "cohere" +dynamic = ["version"] [tool.poetry] name = "cohere" -version = "5.20.4" +version = "5.20.5" description = "" readme = "README.md" authors = [] @@ -13,11 +14,13 @@ classifiers = [ "Intended Audience :: Developers", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", + "Programming Language :: Python :: 3.15", "Operating System :: OS Independent", "Operating System :: POSIX", "Operating System :: MacOS", @@ -49,6 +52,7 @@ typing_extensions = ">= 4.0.0" mypy = "==1.13.0" pytest = "^7.4.0" pytest-asyncio = "^0.23.5" +pytest-xdist = "^3.6.1" python-dateutil = "^2.9.0" types-python-dateutil = "^2.9.0.20240316" ruff = "==0.11.5" diff --git a/reference.md b/reference.md index 296baaa72..2a2ec15dd 100644 --- a/reference.md +++ b/reference.md @@ -1,5 +1,7 @@ # Reference -
client.chat_stream(...) +
client.chat_stream(...) -> typing.AsyncIterator[ + AsyncHttpResponse[typing.AsyncIterator[StreamedChatResponse]] +]
@@ -453,7 +455,7 @@ Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private D
-
client.chat(...) +
client.chat(...) -> AsyncHttpResponse[NonStreamedChatResponse]
@@ -928,7 +930,9 @@ Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private D
-
client.generate_stream(...) +
client.generate_stream(...) -> typing.AsyncIterator[ + AsyncHttpResponse[typing.AsyncIterator[GenerateStreamedResponse]] +]
@@ -1176,7 +1180,7 @@ WARNING: `ALL` is deprecated, and will be removed in a future release.
-
client.generate(...) +
client.generate(...) -> AsyncHttpResponse[Generation]
@@ -1422,7 +1426,7 @@ WARNING: `ALL` is deprecated, and will be removed in a future release.
-
client.embed(...) +
client.embed(...) -> AsyncHttpResponse[EmbedResponse]
@@ -1562,7 +1566,7 @@ If `NONE` is selected, when the input exceeds the maximum input token length an
-
client.rerank(...) +
client.rerank(...) -> AsyncHttpResponse[RerankResponse]
@@ -1710,7 +1714,7 @@ We recommend a maximum of 1,000 documents for optimal endpoint performance.
-
client.classify(...) +
client.classify(...) -> AsyncHttpResponse[ClassifyResponse]
@@ -1868,7 +1872,7 @@ If `NONE` is selected, when the input exceeds the maximum input token length an
-
client.summarize(...) +
client.summarize(...) -> AsyncHttpResponse[SummarizeResponse]
@@ -1990,7 +1994,7 @@ client.summarize(
-
client.tokenize(...) +
client.tokenize(...) -> AsyncHttpResponse[TokenizeResponse]
@@ -2070,7 +2074,7 @@ client.tokenize(
-
client.detokenize(...) +
client.detokenize(...) -> AsyncHttpResponse[DetokenizeResponse]
@@ -2150,7 +2154,7 @@ client.detokenize(
-
client.check_api_key() +
client.check_api_key() -> AsyncHttpResponse[CheckApiKeyResponse]
@@ -2212,7 +2216,9 @@ client.check_api_key()
## V2 -
client.v2.chat_stream(...) +
client.v2.chat_stream(...) -> typing.AsyncIterator[ + AsyncHttpResponse[typing.AsyncIterator[V2ChatStreamResponse]] +]
@@ -2512,7 +2518,7 @@ If tool_choice isn't specified, then the model is free to choose whether to use
-
client.v2.chat(...) +
client.v2.chat(...) -> AsyncHttpResponse[V2ChatResponse]
@@ -2810,7 +2816,7 @@ If tool_choice isn't specified, then the model is free to choose whether to use
-
client.v2.embed(...) +
client.v2.embed(...) -> AsyncHttpResponse[EmbedByTypeResponse]
@@ -2986,7 +2992,7 @@ If `NONE` is selected, when the input exceeds the maximum input token length an
-
client.v2.rerank(...) +
client.v2.rerank(...) -> AsyncHttpResponse[V2RerankResponse]
@@ -3114,7 +3120,7 @@ For optimal performance we recommend against sending more than 1,000 documents i
## Batches -
client.batches.list(...) +
client.batches.list(...) -> AsyncHttpResponse[ListBatchesResponse]
@@ -3214,7 +3220,7 @@ Use `created_at` for creation time or `updated_at` for last updated time.
-
client.batches.create(...) +
client.batches.create(...) -> AsyncHttpResponse[CreateBatchResponse]
@@ -3290,7 +3296,7 @@ client.batches.create(
-
client.batches.retrieve(...) +
client.batches.retrieve(...) -> AsyncHttpResponse[GetBatchResponse]
@@ -3361,7 +3367,7 @@ client.batches.retrieve(
-
client.batches.cancel(...) +
client.batches.cancel(...) -> AsyncHttpResponse[CancelBatchResponse]
@@ -3433,7 +3439,7 @@ client.batches.cancel(
## EmbedJobs -
client.embed_jobs.list() +
client.embed_jobs.list() -> AsyncHttpResponse[ListEmbedJobResponse]
@@ -3494,7 +3500,7 @@ client.embed_jobs.list()
-
client.embed_jobs.create(...) +
client.embed_jobs.create(...) -> AsyncHttpResponse[CreateEmbedJobResponse]
@@ -3628,7 +3634,7 @@ Passing `START` will discard the start of the input. `END` will discard the end
-
client.embed_jobs.get(...) +
client.embed_jobs.get(...) -> AsyncHttpResponse[EmbedJob]
@@ -3699,7 +3705,7 @@ client.embed_jobs.get(
-
client.embed_jobs.cancel(...) +
client.embed_jobs.cancel(...) -> AsyncHttpResponse[None]
@@ -3771,7 +3777,7 @@ client.embed_jobs.cancel(
## Datasets -
client.datasets.list(...) +
client.datasets.list(...) -> AsyncHttpResponse[DatasetsListResponse]
@@ -3893,7 +3899,7 @@ client.datasets.list(
-
client.datasets.create(...) +
client.datasets.create(...) -> AsyncHttpResponse[DatasetsCreateResponse]
@@ -4045,7 +4051,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-
client.datasets.get_usage() +
client.datasets.get_usage() -> AsyncHttpResponse[DatasetsGetUsageResponse]
@@ -4106,7 +4112,7 @@ client.datasets.get_usage()
-
client.datasets.get(...) +
client.datasets.get(...) -> AsyncHttpResponse[DatasetsGetResponse]
@@ -4177,7 +4183,7 @@ client.datasets.get(
-
client.datasets.delete(...) +
client.datasets.delete(...) -> AsyncHttpResponse[typing.Dict[str, typing.Any]]
@@ -4249,7 +4255,7 @@ client.datasets.delete(
## Connectors -
client.connectors.list(...) +
client.connectors.list(...) -> AsyncHttpResponse[ListConnectorsResponse]
@@ -4329,7 +4335,7 @@ client.connectors.list(
-
client.connectors.create(...) +
client.connectors.create(...) -> AsyncHttpResponse[CreateConnectorResponse]
@@ -4457,7 +4463,7 @@ client.connectors.create(
-
client.connectors.get(...) +
client.connectors.get(...) -> AsyncHttpResponse[GetConnectorResponse]
@@ -4528,7 +4534,7 @@ client.connectors.get(
-
client.connectors.delete(...) +
client.connectors.delete(...) -> AsyncHttpResponse[DeleteConnectorResponse]
@@ -4599,7 +4605,7 @@ client.connectors.delete(
-
client.connectors.update(...) +
client.connectors.update(...) -> AsyncHttpResponse[UpdateConnectorResponse]
@@ -4726,7 +4732,7 @@ client.connectors.update(
-
client.connectors.o_auth_authorize(...) +
client.connectors.o_auth_authorize(...) -> AsyncHttpResponse[OAuthAuthorizeResponse]
@@ -4807,7 +4813,7 @@ client.connectors.o_auth_authorize(
## Models -
client.models.get(...) +
client.models.get(...) -> AsyncHttpResponse[GetModelResponse]
@@ -4878,7 +4884,7 @@ client.models.get(
-
client.models.list(...) +
client.models.list(...) -> AsyncHttpResponse[ListModelsResponse]
@@ -4980,7 +4986,7 @@ Defaults to `20`, min value of `1`, max value of `1000`.
## /finetuning -
client.finetuning.list_finetuned_models(...) +
client.finetuning.list_finetuned_models(...) -> AsyncHttpResponse[ListFinetunedModelsResponse]
@@ -5079,7 +5085,7 @@ Supported sorting fields:
-
client.finetuning.create_finetuned_model(...) +
client.finetuning.create_finetuned_model(...) -> AsyncHttpResponse[CreateFinetunedModelResponse]
@@ -5159,7 +5165,7 @@ client.finetuning.create_finetuned_model(
-
client.finetuning.get_finetuned_model(...) +
client.finetuning.get_finetuned_model(...) -> AsyncHttpResponse[GetFinetunedModelResponse]
@@ -5230,7 +5236,7 @@ client.finetuning.get_finetuned_model(
-
client.finetuning.delete_finetuned_model(...) +
client.finetuning.delete_finetuned_model(...) -> AsyncHttpResponse[DeleteFinetunedModelResponse]
@@ -5302,7 +5308,7 @@ client.finetuning.delete_finetuned_model(
-
client.finetuning.update_finetuned_model(...) +
client.finetuning.update_finetuned_model(...) -> AsyncHttpResponse[UpdateFinetunedModelResponse]
@@ -5405,7 +5411,7 @@ client.finetuning.update_finetuned_model(
-
client.finetuning.list_events(...) +
client.finetuning.list_events(...) -> AsyncHttpResponse[ListEventsResponse]
@@ -5515,7 +5521,7 @@ Supported sorting fields:
-
client.finetuning.list_training_step_metrics(...) +
client.finetuning.list_training_step_metrics(...) -> AsyncHttpResponse[ListTrainingStepMetricsResponse]
diff --git a/src/cohere/__init__.py b/src/cohere/__init__.py index e325bfecb..5a9a38251 100644 --- a/src/cohere/__init__.py +++ b/src/cohere/__init__.py @@ -16,7 +16,7 @@ AssistantMessageResponse, AssistantMessageResponseContentItem, AssistantMessageV2Content, - AssistantMessageV2ContentItem, + AssistantMessageV2ContentOneItem, AuthTokenType, ChatCitation, ChatCitationGenerationEvent, @@ -122,6 +122,7 @@ DocumentToolContent, EmbedByTypeResponse, EmbedByTypeResponseEmbeddings, + EmbedByTypeResponseResponseType, EmbedContent, EmbedFloatsResponse, EmbedImage, @@ -199,20 +200,20 @@ SystemMessage, SystemMessageV2, SystemMessageV2Content, - SystemMessageV2ContentItem, + SystemMessageV2ContentOneItem, TextAssistantMessageResponseContentItem, - TextAssistantMessageV2ContentItem, + TextAssistantMessageV2ContentOneItem, TextContent, TextEmbedContent, TextGenerationGenerateStreamedResponse, TextGenerationStreamedChatResponse, TextResponseFormat, TextResponseFormatV2, - TextSystemMessageV2ContentItem, + TextSystemMessageV2ContentOneItem, TextToolContent, Thinking, ThinkingAssistantMessageResponseContentItem, - ThinkingAssistantMessageV2ContentItem, + ThinkingAssistantMessageV2ContentOneItem, ThinkingType, TokenizeResponse, Tool, @@ -320,7 +321,7 @@ "AssistantMessageResponse": ".types", "AssistantMessageResponseContentItem": ".types", "AssistantMessageV2Content": ".types", - "AssistantMessageV2ContentItem": ".types", + "AssistantMessageV2ContentOneItem": ".types", "AsyncClient": ".client", "AsyncClientV2": ".client_v2", "AuthTokenType": ".types", @@ -455,6 +456,7 @@ "DocumentToolContent": ".types", "EmbedByTypeResponse": ".types", "EmbedByTypeResponseEmbeddings": ".types", + "EmbedByTypeResponseResponseType": ".types", "EmbedContent": ".types", "EmbedFloatsResponse": ".types", "EmbedImage": ".types", @@ -548,20 +550,20 @@ "SystemMessage": ".types", "SystemMessageV2": ".types", "SystemMessageV2Content": ".types", - "SystemMessageV2ContentItem": ".types", + "SystemMessageV2ContentOneItem": ".types", "TextAssistantMessageResponseContentItem": ".types", - "TextAssistantMessageV2ContentItem": ".types", + "TextAssistantMessageV2ContentOneItem": ".types", "TextContent": ".types", "TextEmbedContent": ".types", "TextGenerationGenerateStreamedResponse": ".types", "TextGenerationStreamedChatResponse": ".types", "TextResponseFormat": ".types", "TextResponseFormatV2": ".types", - "TextSystemMessageV2ContentItem": ".types", + "TextSystemMessageV2ContentOneItem": ".types", "TextToolContent": ".types", "Thinking": ".types", "ThinkingAssistantMessageResponseContentItem": ".types", - "ThinkingAssistantMessageV2ContentItem": ".types", + "ThinkingAssistantMessageV2ContentOneItem": ".types", "ThinkingType": ".types", "TokenizeResponse": ".types", "TooManyRequestsError": ".errors", @@ -652,7 +654,7 @@ def __dir__(): "AssistantMessageResponse", "AssistantMessageResponseContentItem", "AssistantMessageV2Content", - "AssistantMessageV2ContentItem", + "AssistantMessageV2ContentOneItem", "AsyncClient", "AsyncClientV2", "AuthTokenType", @@ -787,6 +789,7 @@ def __dir__(): "DocumentToolContent", "EmbedByTypeResponse", "EmbedByTypeResponseEmbeddings", + "EmbedByTypeResponseResponseType", "EmbedContent", "EmbedFloatsResponse", "EmbedImage", @@ -880,20 +883,20 @@ def __dir__(): "SystemMessage", "SystemMessageV2", "SystemMessageV2Content", - "SystemMessageV2ContentItem", + "SystemMessageV2ContentOneItem", "TextAssistantMessageResponseContentItem", - "TextAssistantMessageV2ContentItem", + "TextAssistantMessageV2ContentOneItem", "TextContent", "TextEmbedContent", "TextGenerationGenerateStreamedResponse", "TextGenerationStreamedChatResponse", "TextResponseFormat", "TextResponseFormatV2", - "TextSystemMessageV2ContentItem", + "TextSystemMessageV2ContentOneItem", "TextToolContent", "Thinking", "ThinkingAssistantMessageResponseContentItem", - "ThinkingAssistantMessageV2ContentItem", + "ThinkingAssistantMessageV2ContentOneItem", "ThinkingType", "TokenizeResponse", "TooManyRequestsError", diff --git a/src/cohere/base_client.py b/src/cohere/base_client.py index 1b6766a73..b5a96a388 100644 --- a/src/cohere/base_client.py +++ b/src/cohere/base_client.py @@ -6,6 +6,7 @@ import typing import httpx +from .core.api_error import ApiError from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from .core.request_options import RequestOptions from .environment import ClientEnvironment @@ -116,6 +117,8 @@ def __init__( _defaulted_timeout = ( timeout if timeout is not None else 300 if httpx_client is None else httpx_client.timeout.read ) + if token is None: + raise ApiError(body="The client must be instantiated be either passing in token or setting CO_API_KEY") self._client_wrapper = SyncClientWrapper( base_url=_get_base_url(base_url=base_url, environment=environment), client_name=client_name, @@ -192,7 +195,7 @@ def chat_stream( Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments accepts : typing.Optional[typing.Literal["text/event-stream"]] - Pass text/event-stream to receive the streamed response as server-sent events. The default is `\n` delimited events. + Pass text/event-stream to receive the streamed response as server-sent events. The default is `\\n` delimited events. model : typing.Optional[str] The name of a compatible [Cohere model](https://docs.cohere.com/docs/models) or the ID of a [fine-tuned](https://docs.cohere.com/docs/chat-fine-tuning) model. @@ -492,7 +495,7 @@ def chat( Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments accepts : typing.Optional[typing.Literal["text/event-stream"]] - Pass text/event-stream to receive the streamed response as server-sent events. The default is `\n` delimited events. + Pass text/event-stream to receive the streamed response as server-sent events. The default is `\\n` delimited events. model : typing.Optional[str] The name of a compatible [Cohere model](https://docs.cohere.com/docs/models) or the ID of a [fine-tuned](https://docs.cohere.com/docs/chat-fine-tuning) model. @@ -1619,6 +1622,8 @@ def __init__( _defaulted_timeout = ( timeout if timeout is not None else 300 if httpx_client is None else httpx_client.timeout.read ) + if token is None: + raise ApiError(body="The client must be instantiated be either passing in token or setting CO_API_KEY") self._client_wrapper = AsyncClientWrapper( base_url=_get_base_url(base_url=base_url, environment=environment), client_name=client_name, @@ -1695,7 +1700,7 @@ async def chat_stream( Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments accepts : typing.Optional[typing.Literal["text/event-stream"]] - Pass text/event-stream to receive the streamed response as server-sent events. The default is `\n` delimited events. + Pass text/event-stream to receive the streamed response as server-sent events. The default is `\\n` delimited events. model : typing.Optional[str] The name of a compatible [Cohere model](https://docs.cohere.com/docs/models) or the ID of a [fine-tuned](https://docs.cohere.com/docs/chat-fine-tuning) model. @@ -2004,7 +2009,7 @@ async def chat( Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments accepts : typing.Optional[typing.Literal["text/event-stream"]] - Pass text/event-stream to receive the streamed response as server-sent events. The default is `\n` delimited events. + Pass text/event-stream to receive the streamed response as server-sent events. The default is `\\n` delimited events. model : typing.Optional[str] The name of a compatible [Cohere model](https://docs.cohere.com/docs/models) or the ID of a [fine-tuned](https://docs.cohere.com/docs/chat-fine-tuning) model. diff --git a/src/cohere/batches/raw_client.py b/src/cohere/batches/raw_client.py index 5c9c76418..cf3ca51e3 100644 --- a/src/cohere/batches/raw_client.py +++ b/src/cohere/batches/raw_client.py @@ -89,9 +89,9 @@ def list( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -100,9 +100,9 @@ def list( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -111,9 +111,9 @@ def list( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -122,9 +122,9 @@ def list( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -133,9 +133,9 @@ def list( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -144,9 +144,9 @@ def list( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -198,9 +198,9 @@ def create( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -209,9 +209,9 @@ def create( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -220,9 +220,9 @@ def create( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -231,9 +231,9 @@ def create( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -242,9 +242,9 @@ def create( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -253,9 +253,9 @@ def create( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -303,9 +303,9 @@ def retrieve( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -314,9 +314,9 @@ def retrieve( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -325,9 +325,9 @@ def retrieve( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -336,9 +336,9 @@ def retrieve( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -347,9 +347,9 @@ def retrieve( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -358,9 +358,9 @@ def retrieve( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -408,9 +408,9 @@ def cancel( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -419,9 +419,9 @@ def cancel( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -430,9 +430,9 @@ def cancel( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -441,9 +441,9 @@ def cancel( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -452,9 +452,9 @@ def cancel( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -463,9 +463,9 @@ def cancel( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -539,9 +539,9 @@ async def list( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -550,9 +550,9 @@ async def list( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -561,9 +561,9 @@ async def list( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -572,9 +572,9 @@ async def list( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -583,9 +583,9 @@ async def list( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -594,9 +594,9 @@ async def list( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -648,9 +648,9 @@ async def create( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -659,9 +659,9 @@ async def create( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -670,9 +670,9 @@ async def create( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -681,9 +681,9 @@ async def create( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -692,9 +692,9 @@ async def create( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -703,9 +703,9 @@ async def create( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -753,9 +753,9 @@ async def retrieve( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -764,9 +764,9 @@ async def retrieve( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -775,9 +775,9 @@ async def retrieve( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -786,9 +786,9 @@ async def retrieve( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -797,9 +797,9 @@ async def retrieve( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -808,9 +808,9 @@ async def retrieve( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -858,9 +858,9 @@ async def cancel( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -869,9 +869,9 @@ async def cancel( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -880,9 +880,9 @@ async def cancel( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -891,9 +891,9 @@ async def cancel( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -902,9 +902,9 @@ async def cancel( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -913,9 +913,9 @@ async def cancel( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), diff --git a/src/cohere/batches/types/cancel_batch_response.py b/src/cohere/batches/types/cancel_batch_response.py index 0363df8e8..6b155d3ee 100644 --- a/src/cohere/batches/types/cancel_batch_response.py +++ b/src/cohere/batches/types/cancel_batch_response.py @@ -2,4 +2,4 @@ import typing -CancelBatchResponse = typing.Dict[str, typing.Optional[typing.Any]] +CancelBatchResponse = typing.Dict[str, typing.Any] diff --git a/src/cohere/connectors/raw_client.py b/src/cohere/connectors/raw_client.py index 74024995b..ccc81c605 100644 --- a/src/cohere/connectors/raw_client.py +++ b/src/cohere/connectors/raw_client.py @@ -88,9 +88,9 @@ def list( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -99,9 +99,9 @@ def list( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -110,9 +110,9 @@ def list( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -121,9 +121,9 @@ def list( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -132,9 +132,9 @@ def list( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -143,9 +143,9 @@ def list( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -154,9 +154,9 @@ def list( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -165,9 +165,9 @@ def list( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -176,9 +176,9 @@ def list( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -187,9 +187,9 @@ def list( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -198,9 +198,9 @@ def list( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -209,9 +209,9 @@ def list( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -308,9 +308,9 @@ def create( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -319,9 +319,9 @@ def create( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -330,9 +330,9 @@ def create( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -341,9 +341,9 @@ def create( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -352,9 +352,9 @@ def create( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -363,9 +363,9 @@ def create( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -374,9 +374,9 @@ def create( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -385,9 +385,9 @@ def create( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -396,9 +396,9 @@ def create( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -407,9 +407,9 @@ def create( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -418,9 +418,9 @@ def create( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -429,9 +429,9 @@ def create( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -479,9 +479,9 @@ def get( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -490,9 +490,9 @@ def get( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -501,9 +501,9 @@ def get( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -512,9 +512,9 @@ def get( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -523,9 +523,9 @@ def get( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -534,9 +534,9 @@ def get( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -545,9 +545,9 @@ def get( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -556,9 +556,9 @@ def get( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -567,9 +567,9 @@ def get( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -578,9 +578,9 @@ def get( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -589,9 +589,9 @@ def get( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -600,9 +600,9 @@ def get( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -650,9 +650,9 @@ def delete( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -661,9 +661,9 @@ def delete( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -672,9 +672,9 @@ def delete( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -683,9 +683,9 @@ def delete( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -694,9 +694,9 @@ def delete( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -705,9 +705,9 @@ def delete( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -716,9 +716,9 @@ def delete( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -727,9 +727,9 @@ def delete( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -738,9 +738,9 @@ def delete( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -749,9 +749,9 @@ def delete( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -760,9 +760,9 @@ def delete( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -771,9 +771,9 @@ def delete( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -867,9 +867,9 @@ def update( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -878,9 +878,9 @@ def update( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -889,9 +889,9 @@ def update( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -900,9 +900,9 @@ def update( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -911,9 +911,9 @@ def update( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -922,9 +922,9 @@ def update( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -933,9 +933,9 @@ def update( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -944,9 +944,9 @@ def update( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -955,9 +955,9 @@ def update( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -966,9 +966,9 @@ def update( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -977,9 +977,9 @@ def update( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -988,9 +988,9 @@ def update( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1048,9 +1048,9 @@ def o_auth_authorize( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1059,9 +1059,9 @@ def o_auth_authorize( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1070,9 +1070,9 @@ def o_auth_authorize( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1081,9 +1081,9 @@ def o_auth_authorize( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1092,9 +1092,9 @@ def o_auth_authorize( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1103,9 +1103,9 @@ def o_auth_authorize( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1114,9 +1114,9 @@ def o_auth_authorize( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1125,9 +1125,9 @@ def o_auth_authorize( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1136,9 +1136,9 @@ def o_auth_authorize( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1147,9 +1147,9 @@ def o_auth_authorize( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1158,9 +1158,9 @@ def o_auth_authorize( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1169,9 +1169,9 @@ def o_auth_authorize( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1235,9 +1235,9 @@ async def list( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1246,9 +1246,9 @@ async def list( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1257,9 +1257,9 @@ async def list( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1268,9 +1268,9 @@ async def list( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1279,9 +1279,9 @@ async def list( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1290,9 +1290,9 @@ async def list( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1301,9 +1301,9 @@ async def list( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1312,9 +1312,9 @@ async def list( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1323,9 +1323,9 @@ async def list( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1334,9 +1334,9 @@ async def list( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1345,9 +1345,9 @@ async def list( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1356,9 +1356,9 @@ async def list( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1455,9 +1455,9 @@ async def create( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1466,9 +1466,9 @@ async def create( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1477,9 +1477,9 @@ async def create( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1488,9 +1488,9 @@ async def create( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1499,9 +1499,9 @@ async def create( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1510,9 +1510,9 @@ async def create( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1521,9 +1521,9 @@ async def create( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1532,9 +1532,9 @@ async def create( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1543,9 +1543,9 @@ async def create( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1554,9 +1554,9 @@ async def create( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1565,9 +1565,9 @@ async def create( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1576,9 +1576,9 @@ async def create( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1626,9 +1626,9 @@ async def get( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1637,9 +1637,9 @@ async def get( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1648,9 +1648,9 @@ async def get( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1659,9 +1659,9 @@ async def get( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1670,9 +1670,9 @@ async def get( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1681,9 +1681,9 @@ async def get( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1692,9 +1692,9 @@ async def get( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1703,9 +1703,9 @@ async def get( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1714,9 +1714,9 @@ async def get( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1725,9 +1725,9 @@ async def get( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1736,9 +1736,9 @@ async def get( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1747,9 +1747,9 @@ async def get( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1797,9 +1797,9 @@ async def delete( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1808,9 +1808,9 @@ async def delete( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1819,9 +1819,9 @@ async def delete( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1830,9 +1830,9 @@ async def delete( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1841,9 +1841,9 @@ async def delete( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1852,9 +1852,9 @@ async def delete( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1863,9 +1863,9 @@ async def delete( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1874,9 +1874,9 @@ async def delete( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1885,9 +1885,9 @@ async def delete( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1896,9 +1896,9 @@ async def delete( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1907,9 +1907,9 @@ async def delete( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1918,9 +1918,9 @@ async def delete( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2014,9 +2014,9 @@ async def update( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2025,9 +2025,9 @@ async def update( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2036,9 +2036,9 @@ async def update( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2047,9 +2047,9 @@ async def update( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2058,9 +2058,9 @@ async def update( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2069,9 +2069,9 @@ async def update( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2080,9 +2080,9 @@ async def update( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2091,9 +2091,9 @@ async def update( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2102,9 +2102,9 @@ async def update( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2113,9 +2113,9 @@ async def update( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2124,9 +2124,9 @@ async def update( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2135,9 +2135,9 @@ async def update( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2195,9 +2195,9 @@ async def o_auth_authorize( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2206,9 +2206,9 @@ async def o_auth_authorize( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2217,9 +2217,9 @@ async def o_auth_authorize( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2228,9 +2228,9 @@ async def o_auth_authorize( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2239,9 +2239,9 @@ async def o_auth_authorize( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2250,9 +2250,9 @@ async def o_auth_authorize( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2261,9 +2261,9 @@ async def o_auth_authorize( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2272,9 +2272,9 @@ async def o_auth_authorize( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2283,9 +2283,9 @@ async def o_auth_authorize( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2294,9 +2294,9 @@ async def o_auth_authorize( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2305,9 +2305,9 @@ async def o_auth_authorize( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2316,9 +2316,9 @@ async def o_auth_authorize( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), diff --git a/src/cohere/core/client_wrapper.py b/src/cohere/core/client_wrapper.py index 8a23c07f0..e9f18d52d 100644 --- a/src/cohere/core/client_wrapper.py +++ b/src/cohere/core/client_wrapper.py @@ -11,7 +11,7 @@ def __init__( self, *, client_name: typing.Optional[str] = None, - token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, + token: typing.Union[str, typing.Callable[[], str]], headers: typing.Optional[typing.Dict[str, str]] = None, base_url: str, timeout: typing.Optional[float] = None, @@ -23,22 +23,24 @@ def __init__( self._timeout = timeout def get_headers(self) -> typing.Dict[str, str]: + import platform + headers: typing.Dict[str, str] = { - "User-Agent": "cohere/5.20.4", + "User-Agent": "cohere/5.20.5", "X-Fern-Language": "Python", + "X-Fern-Runtime": f"python/{platform.python_version()}", + "X-Fern-Platform": f"{platform.system().lower()}/{platform.release()}", "X-Fern-SDK-Name": "cohere", - "X-Fern-SDK-Version": "5.20.4", + "X-Fern-SDK-Version": "5.20.5", **(self.get_custom_headers() or {}), } if self._client_name is not None: headers["X-Client-Name"] = self._client_name - token = self._get_token() - if token is not None: - headers["Authorization"] = f"Bearer {token}" + headers["Authorization"] = f"Bearer {self._get_token()}" return headers - def _get_token(self) -> typing.Optional[str]: - if isinstance(self._token, str) or self._token is None: + def _get_token(self) -> str: + if isinstance(self._token, str): return self._token else: return self._token() @@ -58,7 +60,7 @@ def __init__( self, *, client_name: typing.Optional[str] = None, - token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, + token: typing.Union[str, typing.Callable[[], str]], headers: typing.Optional[typing.Dict[str, str]] = None, base_url: str, timeout: typing.Optional[float] = None, @@ -78,16 +80,26 @@ def __init__( self, *, client_name: typing.Optional[str] = None, - token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, + token: typing.Union[str, typing.Callable[[], str]], headers: typing.Optional[typing.Dict[str, str]] = None, base_url: str, timeout: typing.Optional[float] = None, + async_token: typing.Optional[typing.Callable[[], typing.Awaitable[str]]] = None, httpx_client: httpx.AsyncClient, ): super().__init__(client_name=client_name, token=token, headers=headers, base_url=base_url, timeout=timeout) + self._async_token = async_token self.httpx_client = AsyncHttpClient( httpx_client=httpx_client, base_headers=self.get_headers, base_timeout=self.get_timeout, base_url=self.get_base_url, + async_base_headers=self.async_get_headers, ) + + async def async_get_headers(self) -> typing.Dict[str, str]: + headers = self.get_headers() + if self._async_token is not None: + token = await self._async_token() + headers["Authorization"] = f"Bearer {token}" + return headers diff --git a/src/cohere/core/http_client.py b/src/cohere/core/http_client.py index e4173f990..7c6c936f9 100644 --- a/src/cohere/core/http_client.py +++ b/src/cohere/core/http_client.py @@ -5,7 +5,6 @@ import re import time import typing -import urllib.parse from contextlib import asynccontextmanager, contextmanager from random import random @@ -14,13 +13,13 @@ from .force_multipart import FORCE_MULTIPART from .jsonable_encoder import jsonable_encoder from .query_encoder import encode_query -from .remove_none_from_dict import remove_none_from_dict +from .remove_none_from_dict import remove_none_from_dict as remove_none_from_dict from .request_options import RequestOptions from httpx._types import RequestFiles -INITIAL_RETRY_DELAY_SECONDS = 0.5 -MAX_RETRY_DELAY_SECONDS = 10 -MAX_RETRY_DELAY_SECONDS_FROM_HEADER = 30 +INITIAL_RETRY_DELAY_SECONDS = 1.0 +MAX_RETRY_DELAY_SECONDS = 60.0 +JITTER_FACTOR = 0.2 # 20% random jitter def _parse_retry_after(response_headers: httpx.Headers) -> typing.Optional[float]: @@ -64,6 +63,38 @@ def _parse_retry_after(response_headers: httpx.Headers) -> typing.Optional[float return seconds +def _add_positive_jitter(delay: float) -> float: + """Add positive jitter (0-20%) to prevent thundering herd.""" + jitter_multiplier = 1 + random() * JITTER_FACTOR + return delay * jitter_multiplier + + +def _add_symmetric_jitter(delay: float) -> float: + """Add symmetric jitter (±10%) for exponential backoff.""" + jitter_multiplier = 1 + (random() - 0.5) * JITTER_FACTOR + return delay * jitter_multiplier + + +def _parse_x_ratelimit_reset(response_headers: httpx.Headers) -> typing.Optional[float]: + """ + Parse the X-RateLimit-Reset header (Unix timestamp in seconds). + Returns seconds to wait, or None if header is missing/invalid. + """ + reset_time_str = response_headers.get("x-ratelimit-reset") + if reset_time_str is None: + return None + + try: + reset_time = int(reset_time_str) + delay = reset_time - time.time() + if delay > 0: + return delay + except (ValueError, TypeError): + pass + + return None + + def _retry_timeout(response: httpx.Response, retries: int) -> float: """ Determine the amount of time to wait before retrying a request. @@ -71,17 +102,19 @@ def _retry_timeout(response: httpx.Response, retries: int) -> float: with a jitter to determine the number of seconds to wait. """ - # If the API asks us to wait a certain amount of time (and it's a reasonable amount), just do what it says. + # 1. Check Retry-After header first retry_after = _parse_retry_after(response.headers) - if retry_after is not None and retry_after <= MAX_RETRY_DELAY_SECONDS_FROM_HEADER: - return retry_after + if retry_after is not None and retry_after > 0: + return min(retry_after, MAX_RETRY_DELAY_SECONDS) - # Apply exponential backoff, capped at MAX_RETRY_DELAY_SECONDS. - retry_delay = min(INITIAL_RETRY_DELAY_SECONDS * pow(2.0, retries), MAX_RETRY_DELAY_SECONDS) + # 2. Check X-RateLimit-Reset header (with positive jitter) + ratelimit_reset = _parse_x_ratelimit_reset(response.headers) + if ratelimit_reset is not None: + return _add_positive_jitter(min(ratelimit_reset, MAX_RETRY_DELAY_SECONDS)) - # Add a randomness / jitter to the retry delay to avoid overwhelming the server with retries. - timeout = retry_delay * (1 - 0.25 * random()) - return timeout if timeout >= 0 else 0 + # 3. Fall back to exponential backoff (with symmetric jitter) + backoff = min(INITIAL_RETRY_DELAY_SECONDS * pow(2.0, retries), MAX_RETRY_DELAY_SECONDS) + return _add_symmetric_jitter(backoff) def _should_retry(response: httpx.Response) -> bool: @@ -89,6 +122,45 @@ def _should_retry(response: httpx.Response) -> bool: return response.status_code >= 500 or response.status_code in retryable_400s +def _build_url(base_url: str, path: typing.Optional[str]) -> str: + """ + Build a full URL by joining a base URL with a path. + + This function correctly handles base URLs that contain path prefixes (e.g., tenant-based URLs) + by using string concatenation instead of urllib.parse.urljoin(), which would incorrectly + strip path components when the path starts with '/'. + + Example: + >>> _build_url("https://cloud.example.com/org/tenant/api", "/users") + 'https://cloud.example.com/org/tenant/api/users' + + Args: + base_url: The base URL, which may contain path prefixes. + path: The path to append. Can be None or empty string. + + Returns: + The full URL with base_url and path properly joined. + """ + if not path: + return base_url + return f"{base_url.rstrip('/')}/{path.lstrip('/')}" + + +def _maybe_filter_none_from_multipart_data( + data: typing.Optional[typing.Any], + request_files: typing.Optional[RequestFiles], + force_multipart: typing.Optional[bool], +) -> typing.Optional[typing.Any]: + """ + Filter None values from data body for multipart/form requests. + This prevents httpx from converting None to empty strings in multipart encoding. + Only applies when files are present or force_multipart is True. + """ + if data is not None and isinstance(data, typing.Mapping) and (request_files or force_multipart): + return remove_none_from_dict(data) + return data + + def remove_omit_from_dict( original: typing.Dict[str, typing.Optional[typing.Any]], omit: typing.Optional[typing.Any], @@ -143,8 +215,19 @@ def get_request_body( # If both data and json are None, we send json data in the event extra properties are specified json_body = maybe_filter_request_body(json, request_options, omit) - # If you have an empty JSON body, you should just send None - return (json_body if json_body != {} else None), data_body if data_body != {} else None + has_additional_body_parameters = bool( + request_options is not None and request_options.get("additional_body_parameters") + ) + + # Only collapse empty dict to None when the body was not explicitly provided + # and there are no additional body parameters. This preserves explicit empty + # bodies (e.g., when an endpoint has a request body type but all fields are optional). + if json_body == {} and json is None and not has_additional_body_parameters: + json_body = None + if data_body == {} and data is None and not has_additional_body_parameters: + data_body = None + + return json_body, data_body class HttpClient: @@ -188,7 +271,7 @@ def request( ] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, - retries: int = 2, + retries: int = 0, omit: typing.Optional[typing.Any] = None, force_multipart: typing.Optional[bool] = None, ) -> httpx.Response: @@ -210,9 +293,31 @@ def request( if (request_files is None or len(request_files) == 0) and force_multipart: request_files = FORCE_MULTIPART + data_body = _maybe_filter_none_from_multipart_data(data_body, request_files, force_multipart) + + # Compute encoded params separately to avoid passing empty list to httpx + # (httpx strips existing query params from URL when params=[] is passed) + _encoded_params = encode_query( + jsonable_encoder( + remove_none_from_dict( + remove_omit_from_dict( + { + **(params if params is not None else {}), + **( + request_options.get("additional_query_parameters", {}) or {} + if request_options is not None + else {} + ), + }, + omit, + ) + ) + ) + ) + response = self.httpx_client.request( method=method, - url=urllib.parse.urljoin(f"{base_url}/", path), + url=_build_url(base_url, path), headers=jsonable_encoder( remove_none_from_dict( { @@ -222,23 +327,7 @@ def request( } ) ), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - remove_omit_from_dict( - { - **(params if params is not None else {}), - **( - request_options.get("additional_query_parameters", {}) or {} - if request_options is not None - else {} - ), - }, - omit, - ) - ) - ) - ), + params=_encoded_params if _encoded_params else None, json=json_body, data=data_body, content=content, @@ -246,9 +335,9 @@ def request( timeout=timeout, ) - max_retries: int = request_options.get("max_retries", 0) if request_options is not None else 0 + max_retries: int = request_options.get("max_retries", 2) if request_options is not None else 2 if _should_retry(response=response): - if max_retries > retries: + if retries < max_retries: time.sleep(_retry_timeout(response=response, retries=retries)) return self.request( path=path, @@ -285,7 +374,7 @@ def stream( ] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, - retries: int = 2, + retries: int = 0, omit: typing.Optional[typing.Any] = None, force_multipart: typing.Optional[bool] = None, ) -> typing.Iterator[httpx.Response]: @@ -307,9 +396,31 @@ def stream( json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) + data_body = _maybe_filter_none_from_multipart_data(data_body, request_files, force_multipart) + + # Compute encoded params separately to avoid passing empty list to httpx + # (httpx strips existing query params from URL when params=[] is passed) + _encoded_params = encode_query( + jsonable_encoder( + remove_none_from_dict( + remove_omit_from_dict( + { + **(params if params is not None else {}), + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + }, + omit, + ) + ) + ) + ) + with self.httpx_client.stream( method=method, - url=urllib.parse.urljoin(f"{base_url}/", path), + url=_build_url(base_url, path), headers=jsonable_encoder( remove_none_from_dict( { @@ -319,23 +430,7 @@ def stream( } ) ), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - remove_omit_from_dict( - { - **(params if params is not None else {}), - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - }, - omit, - ) - ) - ) - ), + params=_encoded_params if _encoded_params else None, json=json_body, data=data_body, content=content, @@ -353,12 +448,19 @@ def __init__( base_timeout: typing.Callable[[], typing.Optional[float]], base_headers: typing.Callable[[], typing.Dict[str, str]], base_url: typing.Optional[typing.Callable[[], str]] = None, + async_base_headers: typing.Optional[typing.Callable[[], typing.Awaitable[typing.Dict[str, str]]]] = None, ): self.base_url = base_url self.base_timeout = base_timeout self.base_headers = base_headers + self.async_base_headers = async_base_headers self.httpx_client = httpx_client + async def _get_headers(self) -> typing.Dict[str, str]: + if self.async_base_headers is not None: + return await self.async_base_headers() + return self.base_headers() + def get_base_url(self, maybe_base_url: typing.Optional[str]) -> str: base_url = maybe_base_url if self.base_url is not None and base_url is None: @@ -386,7 +488,7 @@ async def request( ] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, - retries: int = 2, + retries: int = 0, omit: typing.Optional[typing.Any] = None, force_multipart: typing.Optional[bool] = None, ) -> httpx.Response: @@ -408,36 +510,45 @@ async def request( json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) + data_body = _maybe_filter_none_from_multipart_data(data_body, request_files, force_multipart) + + # Get headers (supports async token providers) + _headers = await self._get_headers() + + # Compute encoded params separately to avoid passing empty list to httpx + # (httpx strips existing query params from URL when params=[] is passed) + _encoded_params = encode_query( + jsonable_encoder( + remove_none_from_dict( + remove_omit_from_dict( + { + **(params if params is not None else {}), + **( + request_options.get("additional_query_parameters", {}) or {} + if request_options is not None + else {} + ), + }, + omit, + ) + ) + ) + ) + # Add the input to each of these and do None-safety checks response = await self.httpx_client.request( method=method, - url=urllib.parse.urljoin(f"{base_url}/", path), + url=_build_url(base_url, path), headers=jsonable_encoder( remove_none_from_dict( { - **self.base_headers(), + **_headers, **(headers if headers is not None else {}), **(request_options.get("additional_headers", {}) or {} if request_options is not None else {}), } ) ), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - remove_omit_from_dict( - { - **(params if params is not None else {}), - **( - request_options.get("additional_query_parameters", {}) or {} - if request_options is not None - else {} - ), - }, - omit, - ) - ) - ) - ), + params=_encoded_params if _encoded_params else None, json=json_body, data=data_body, content=content, @@ -445,9 +556,9 @@ async def request( timeout=timeout, ) - max_retries: int = request_options.get("max_retries", 0) if request_options is not None else 0 + max_retries: int = request_options.get("max_retries", 2) if request_options is not None else 2 if _should_retry(response=response): - if max_retries > retries: + if retries < max_retries: await asyncio.sleep(_retry_timeout(response=response, retries=retries)) return await self.request( path=path, @@ -483,7 +594,7 @@ async def stream( ] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, - retries: int = 2, + retries: int = 0, omit: typing.Optional[typing.Any] = None, force_multipart: typing.Optional[bool] = None, ) -> typing.AsyncIterator[httpx.Response]: @@ -505,35 +616,44 @@ async def stream( json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) + data_body = _maybe_filter_none_from_multipart_data(data_body, request_files, force_multipart) + + # Get headers (supports async token providers) + _headers = await self._get_headers() + + # Compute encoded params separately to avoid passing empty list to httpx + # (httpx strips existing query params from URL when params=[] is passed) + _encoded_params = encode_query( + jsonable_encoder( + remove_none_from_dict( + remove_omit_from_dict( + { + **(params if params is not None else {}), + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + }, + omit=omit, + ) + ) + ) + ) + async with self.httpx_client.stream( method=method, - url=urllib.parse.urljoin(f"{base_url}/", path), + url=_build_url(base_url, path), headers=jsonable_encoder( remove_none_from_dict( { - **self.base_headers(), + **_headers, **(headers if headers is not None else {}), **(request_options.get("additional_headers", {}) if request_options is not None else {}), } ) ), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - remove_omit_from_dict( - { - **(params if params is not None else {}), - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - }, - omit=omit, - ) - ) - ) - ), + params=_encoded_params if _encoded_params else None, json=json_body, data=data_body, content=content, diff --git a/src/cohere/core/http_response.py b/src/cohere/core/http_response.py index 2479747e8..00bb1096d 100644 --- a/src/cohere/core/http_response.py +++ b/src/cohere/core/http_response.py @@ -9,7 +9,7 @@ class BaseHttpResponse: - """Minimalist HTTP response wrapper that exposes response headers.""" + """Minimalist HTTP response wrapper that exposes response headers and status code.""" _response: httpx.Response @@ -20,6 +20,10 @@ def __init__(self, response: httpx.Response): def headers(self) -> Dict[str, str]: return dict(self._response.headers) + @property + def status_code(self) -> int: + return self._response.status_code + class HttpResponse(Generic[T], BaseHttpResponse): """HTTP response wrapper that exposes response headers and data.""" diff --git a/src/cohere/core/jsonable_encoder.py b/src/cohere/core/jsonable_encoder.py index afee3662d..f8beaeafb 100644 --- a/src/cohere/core/jsonable_encoder.py +++ b/src/cohere/core/jsonable_encoder.py @@ -30,6 +30,10 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any], Any]]] = None) -> Any: custom_encoder = custom_encoder or {} + # Generated SDKs use Ellipsis (`...`) as the sentinel value for "OMIT". + # OMIT values should be excluded from serialized payloads. + if obj is Ellipsis: + return None if custom_encoder: if type(obj) in custom_encoder: return custom_encoder[type(obj)](obj) @@ -70,6 +74,8 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any] allowed_keys = set(obj.keys()) for key, value in obj.items(): if key in allowed_keys: + if value is Ellipsis: + continue encoded_key = jsonable_encoder(key, custom_encoder=custom_encoder) encoded_value = jsonable_encoder(value, custom_encoder=custom_encoder) encoded_dict[encoded_key] = encoded_value @@ -77,6 +83,8 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any] if isinstance(obj, (list, set, frozenset, GeneratorType, tuple)): encoded_list = [] for item in obj: + if item is Ellipsis: + continue encoded_list.append(jsonable_encoder(item, custom_encoder=custom_encoder)) return encoded_list diff --git a/src/cohere/core/pydantic_utilities.py b/src/cohere/core/pydantic_utilities.py index 185e5c4f6..789081b07 100644 --- a/src/cohere/core/pydantic_utilities.py +++ b/src/cohere/core/pydantic_utilities.py @@ -2,10 +2,35 @@ # nopycln: file import datetime as dt +import inspect +import json +import logging from collections import defaultdict -from typing import Any, Callable, ClassVar, Dict, List, Mapping, Optional, Set, Tuple, Type, TypeVar, Union, cast +from dataclasses import asdict +from typing import ( + TYPE_CHECKING, + Any, + Callable, + ClassVar, + Dict, + List, + Mapping, + Optional, + Set, + Tuple, + Type, + TypeVar, + Union, + cast, +) import pydantic +import typing_extensions + +_logger = logging.getLogger(__name__) + +if TYPE_CHECKING: + from .http_sse._models import ServerSentEvent IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.") @@ -36,8 +61,212 @@ Model = TypeVar("Model", bound=pydantic.BaseModel) +def _get_discriminator_and_variants(type_: Type[Any]) -> Tuple[Optional[str], Optional[List[Type[Any]]]]: + """ + Extract the discriminator field name and union variants from a discriminated union type. + Supports Annotated[Union[...], Field(discriminator=...)] patterns. + Returns (discriminator, variants) or (None, None) if not a discriminated union. + """ + origin = typing_extensions.get_origin(type_) + + if origin is typing_extensions.Annotated: + args = typing_extensions.get_args(type_) + if len(args) >= 2: + inner_type = args[0] + # Check annotations for discriminator + discriminator = None + for annotation in args[1:]: + if hasattr(annotation, "discriminator"): + discriminator = getattr(annotation, "discriminator", None) + break + + if discriminator: + inner_origin = typing_extensions.get_origin(inner_type) + if inner_origin is Union: + variants = list(typing_extensions.get_args(inner_type)) + return discriminator, variants + return None, None + + +def _get_field_annotation(model: Type[Any], field_name: str) -> Optional[Type[Any]]: + """Get the type annotation of a field from a Pydantic model.""" + if IS_PYDANTIC_V2: + fields = getattr(model, "model_fields", {}) + field_info = fields.get(field_name) + if field_info: + return cast(Optional[Type[Any]], field_info.annotation) + else: + fields = getattr(model, "__fields__", {}) + field_info = fields.get(field_name) + if field_info: + return cast(Optional[Type[Any]], field_info.outer_type_) + return None + + +def _find_variant_by_discriminator( + variants: List[Type[Any]], + discriminator: str, + discriminator_value: Any, +) -> Optional[Type[Any]]: + """Find the union variant that matches the discriminator value.""" + for variant in variants: + if not (inspect.isclass(variant) and issubclass(variant, pydantic.BaseModel)): + continue + + disc_annotation = _get_field_annotation(variant, discriminator) + if disc_annotation and is_literal_type(disc_annotation): + literal_args = get_args(disc_annotation) + if literal_args and literal_args[0] == discriminator_value: + return variant + return None + + +def _is_string_type(type_: Type[Any]) -> bool: + """Check if a type is str or Optional[str].""" + if type_ is str: + return True + + origin = typing_extensions.get_origin(type_) + if origin is Union: + args = typing_extensions.get_args(type_) + # Optional[str] = Union[str, None] + non_none_args = [a for a in args if a is not type(None)] + if len(non_none_args) == 1 and non_none_args[0] is str: + return True + + return False + + +def parse_sse_obj(sse: "ServerSentEvent", type_: Type[T]) -> T: + """ + Parse a ServerSentEvent into the appropriate type. + + Handles two scenarios based on where the discriminator field is located: + + 1. Data-level discrimination: The discriminator (e.g., 'type') is inside the 'data' payload. + The union describes the data content, not the SSE envelope. + -> Returns: json.loads(data) parsed into the type + + Example: ChatStreamResponse with discriminator='type' + Input: ServerSentEvent(event="message", data='{"type": "content-delta", ...}', id="") + Output: ContentDeltaEvent (parsed from data, SSE envelope stripped) + + 2. Event-level discrimination: The discriminator (e.g., 'event') is at the SSE event level. + The union describes the full SSE event structure. + -> Returns: SSE envelope with 'data' field JSON-parsed only if the variant expects non-string + + Example: JobStreamResponse with discriminator='event' + Input: ServerSentEvent(event="ERROR", data='{"code": "FAILED", ...}', id="123") + Output: JobStreamResponse_Error with data as ErrorData object + + But for variants where data is str (like STATUS_UPDATE): + Input: ServerSentEvent(event="STATUS_UPDATE", data='{"status": "processing"}', id="1") + Output: JobStreamResponse_StatusUpdate with data as string (not parsed) + + Args: + sse: The ServerSentEvent object to parse + type_: The target discriminated union type + + Returns: + The parsed object of type T + + Note: + This function is only available in SDK contexts where http_sse module exists. + """ + sse_event = asdict(sse) + discriminator, variants = _get_discriminator_and_variants(type_) + + if discriminator is None or variants is None: + # Not a discriminated union - parse the data field as JSON + data_value = sse_event.get("data") + if isinstance(data_value, str) and data_value: + try: + parsed_data = json.loads(data_value) + return parse_obj_as(type_, parsed_data) + except json.JSONDecodeError as e: + _logger.warning( + "Failed to parse SSE data field as JSON: %s, data: %s", + e, + data_value[:100] if len(data_value) > 100 else data_value, + ) + return parse_obj_as(type_, sse_event) + + data_value = sse_event.get("data") + + # Check if discriminator is at the top level (event-level discrimination) + if discriminator in sse_event: + # Case 2: Event-level discrimination + # Find the matching variant to check if 'data' field needs JSON parsing + disc_value = sse_event.get(discriminator) + matching_variant = _find_variant_by_discriminator(variants, discriminator, disc_value) + + if matching_variant is not None: + # Check what type the variant expects for 'data' + data_type = _get_field_annotation(matching_variant, "data") + if data_type is not None and not _is_string_type(data_type): + # Variant expects non-string data - parse JSON + if isinstance(data_value, str) and data_value: + try: + parsed_data = json.loads(data_value) + new_object = dict(sse_event) + new_object["data"] = parsed_data + return parse_obj_as(type_, new_object) + except json.JSONDecodeError as e: + _logger.warning( + "Failed to parse SSE data field as JSON for event-level discrimination: %s, data: %s", + e, + data_value[:100] if len(data_value) > 100 else data_value, + ) + # Either no matching variant, data is string type, or JSON parse failed + return parse_obj_as(type_, sse_event) + + else: + # Case 1: Data-level discrimination + # The discriminator is inside the data payload - extract and parse data only + if isinstance(data_value, str) and data_value: + try: + parsed_data = json.loads(data_value) + return parse_obj_as(type_, parsed_data) + except json.JSONDecodeError as e: + _logger.warning( + "Failed to parse SSE data field as JSON for data-level discrimination: %s, data: %s", + e, + data_value[:100] if len(data_value) > 100 else data_value, + ) + return parse_obj_as(type_, sse_event) + + def parse_obj_as(type_: Type[T], object_: Any) -> T: - dealiased_object = convert_and_respect_annotation_metadata(object_=object_, annotation=type_, direction="read") + # convert_and_respect_annotation_metadata is required for TypedDict aliasing. + # + # For Pydantic models, whether we should pre-dealias depends on how the model encodes aliasing: + # - If the model uses real Pydantic aliases (pydantic.Field(alias=...)), then we must pass wire keys through + # unchanged so Pydantic can validate them. + # - If the model encodes aliasing only via FieldMetadata annotations, then we MUST pre-dealias because Pydantic + # will not recognize those aliases during validation. + if inspect.isclass(type_) and issubclass(type_, pydantic.BaseModel): + has_pydantic_aliases = False + if IS_PYDANTIC_V2: + for field_name, field_info in getattr(type_, "model_fields", {}).items(): # type: ignore[attr-defined] + alias = getattr(field_info, "alias", None) + if alias is not None and alias != field_name: + has_pydantic_aliases = True + break + else: + for field in getattr(type_, "__fields__", {}).values(): + alias = getattr(field, "alias", None) + name = getattr(field, "name", None) + if alias is not None and name is not None and alias != name: + has_pydantic_aliases = True + break + + dealiased_object = ( + object_ + if has_pydantic_aliases + else convert_and_respect_annotation_metadata(object_=object_, annotation=type_, direction="read") + ) + else: + dealiased_object = convert_and_respect_annotation_metadata(object_=object_, annotation=type_, direction="read") if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore[attr-defined] return adapter.validate_python(dealiased_object) @@ -59,6 +288,43 @@ class UniversalBaseModel(pydantic.BaseModel): protected_namespaces=(), ) + @pydantic.model_validator(mode="before") # type: ignore[attr-defined] + @classmethod + def _coerce_field_names_to_aliases(cls, data: Any) -> Any: + """ + Accept Python field names in input by rewriting them to their Pydantic aliases, + while avoiding silent collisions when a key could refer to multiple fields. + """ + if not isinstance(data, Mapping): + return data + + fields = getattr(cls, "model_fields", {}) # type: ignore[attr-defined] + name_to_alias: Dict[str, str] = {} + alias_to_name: Dict[str, str] = {} + + for name, field_info in fields.items(): + alias = getattr(field_info, "alias", None) or name + name_to_alias[name] = alias + if alias != name: + alias_to_name[alias] = name + + # Detect ambiguous keys: a key that is an alias for one field and a name for another. + ambiguous_keys = set(alias_to_name.keys()).intersection(set(name_to_alias.keys())) + for key in ambiguous_keys: + if key in data and name_to_alias[key] not in data: + raise ValueError( + f"Ambiguous input key '{key}': it is both a field name and an alias. " + "Provide the explicit alias key to disambiguate." + ) + + original_keys = set(data.keys()) + rewritten: Dict[str, Any] = dict(data) + for name, alias in name_to_alias.items(): + if alias != name and name in original_keys and alias not in rewritten: + rewritten[alias] = rewritten.pop(name) + + return rewritten + @pydantic.model_serializer(mode="plain", when_used="json") # type: ignore[attr-defined] def serialize_model(self) -> Any: # type: ignore[name-defined] serialized = self.dict() # type: ignore[attr-defined] @@ -71,6 +337,40 @@ class Config: smart_union = True json_encoders = {dt.datetime: serialize_datetime} + @pydantic.root_validator(pre=True) + def _coerce_field_names_to_aliases(cls, values: Any) -> Any: + """ + Pydantic v1 equivalent of _coerce_field_names_to_aliases. + """ + if not isinstance(values, Mapping): + return values + + fields = getattr(cls, "__fields__", {}) + name_to_alias: Dict[str, str] = {} + alias_to_name: Dict[str, str] = {} + + for name, field in fields.items(): + alias = getattr(field, "alias", None) or name + name_to_alias[name] = alias + if alias != name: + alias_to_name[alias] = name + + ambiguous_keys = set(alias_to_name.keys()).intersection(set(name_to_alias.keys())) + for key in ambiguous_keys: + if key in values and name_to_alias[key] not in values: + raise ValueError( + f"Ambiguous input key '{key}': it is both a field name and an alias. " + "Provide the explicit alias key to disambiguate." + ) + + original_keys = set(values.keys()) + rewritten: Dict[str, Any] = dict(values) + for name, alias in name_to_alias.items(): + if alias != name and name in original_keys and alias not in rewritten: + rewritten[alias] = rewritten.pop(name) + + return rewritten + @classmethod def model_construct(cls: Type["Model"], _fields_set: Optional[Set[str]] = None, **values: Any) -> "Model": dealiased_object = convert_and_respect_annotation_metadata(object_=values, annotation=cls, direction="read") diff --git a/src/cohere/datasets/client.py b/src/cohere/datasets/client.py index 3b6a56d03..c5b55425e 100644 --- a/src/cohere/datasets/client.py +++ b/src/cohere/datasets/client.py @@ -259,7 +259,7 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non def delete( self, id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> typing.Dict[str, typing.Optional[typing.Any]]: + ) -> typing.Dict[str, typing.Any]: """ Delete a dataset by ID. Datasets are automatically deleted after 30 days, but they can also be deleted manually. @@ -272,7 +272,7 @@ def delete( Returns ------- - typing.Dict[str, typing.Optional[typing.Any]] + typing.Dict[str, typing.Any] A successful response. Examples @@ -563,7 +563,7 @@ async def main() -> None: async def delete( self, id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> typing.Dict[str, typing.Optional[typing.Any]]: + ) -> typing.Dict[str, typing.Any]: """ Delete a dataset by ID. Datasets are automatically deleted after 30 days, but they can also be deleted manually. @@ -576,7 +576,7 @@ async def delete( Returns ------- - typing.Dict[str, typing.Optional[typing.Any]] + typing.Dict[str, typing.Any] A successful response. Examples diff --git a/src/cohere/datasets/raw_client.py b/src/cohere/datasets/raw_client.py index c148178fb..3e3b73ccb 100644 --- a/src/cohere/datasets/raw_client.py +++ b/src/cohere/datasets/raw_client.py @@ -108,9 +108,9 @@ def list( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -119,9 +119,9 @@ def list( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -130,9 +130,9 @@ def list( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -141,9 +141,9 @@ def list( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -152,9 +152,9 @@ def list( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -163,9 +163,9 @@ def list( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -174,9 +174,9 @@ def list( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -185,9 +185,9 @@ def list( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -196,9 +196,9 @@ def list( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -207,9 +207,9 @@ def list( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -218,9 +218,9 @@ def list( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -229,9 +229,9 @@ def list( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -335,9 +335,9 @@ def create( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -346,9 +346,9 @@ def create( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -357,9 +357,9 @@ def create( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -368,9 +368,9 @@ def create( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -379,9 +379,9 @@ def create( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -390,9 +390,9 @@ def create( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -401,9 +401,9 @@ def create( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -412,9 +412,9 @@ def create( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -423,9 +423,9 @@ def create( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -434,9 +434,9 @@ def create( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -445,9 +445,9 @@ def create( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -456,9 +456,9 @@ def create( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -503,9 +503,9 @@ def get_usage( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -514,9 +514,9 @@ def get_usage( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -525,9 +525,9 @@ def get_usage( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -536,9 +536,9 @@ def get_usage( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -547,9 +547,9 @@ def get_usage( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -558,9 +558,9 @@ def get_usage( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -569,9 +569,9 @@ def get_usage( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -580,9 +580,9 @@ def get_usage( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -591,9 +591,9 @@ def get_usage( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -602,9 +602,9 @@ def get_usage( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -613,9 +613,9 @@ def get_usage( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -624,9 +624,9 @@ def get_usage( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -673,9 +673,9 @@ def get( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -684,9 +684,9 @@ def get( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -695,9 +695,9 @@ def get( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -706,9 +706,9 @@ def get( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -717,9 +717,9 @@ def get( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -728,9 +728,9 @@ def get( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -739,9 +739,9 @@ def get( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -750,9 +750,9 @@ def get( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -761,9 +761,9 @@ def get( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -772,9 +772,9 @@ def get( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -783,9 +783,9 @@ def get( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -794,9 +794,9 @@ def get( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -808,7 +808,7 @@ def get( def delete( self, id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> HttpResponse[typing.Dict[str, typing.Optional[typing.Any]]]: + ) -> HttpResponse[typing.Dict[str, typing.Any]]: """ Delete a dataset by ID. Datasets are automatically deleted after 30 days, but they can also be deleted manually. @@ -821,7 +821,7 @@ def delete( Returns ------- - HttpResponse[typing.Dict[str, typing.Optional[typing.Any]]] + HttpResponse[typing.Dict[str, typing.Any]] A successful response. """ _response = self._client_wrapper.httpx_client.request( @@ -832,9 +832,9 @@ def delete( try: if 200 <= _response.status_code < 300: _data = typing.cast( - typing.Dict[str, typing.Optional[typing.Any]], + typing.Dict[str, typing.Any], construct_type( - type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore + type_=typing.Dict[str, typing.Any], # type: ignore object_=_response.json(), ), ) @@ -843,9 +843,9 @@ def delete( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -854,9 +854,9 @@ def delete( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -865,9 +865,9 @@ def delete( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -876,9 +876,9 @@ def delete( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -887,9 +887,9 @@ def delete( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -898,9 +898,9 @@ def delete( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -909,9 +909,9 @@ def delete( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -920,9 +920,9 @@ def delete( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -931,9 +931,9 @@ def delete( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -942,9 +942,9 @@ def delete( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -953,9 +953,9 @@ def delete( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -964,9 +964,9 @@ def delete( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1050,9 +1050,9 @@ async def list( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1061,9 +1061,9 @@ async def list( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1072,9 +1072,9 @@ async def list( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1083,9 +1083,9 @@ async def list( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1094,9 +1094,9 @@ async def list( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1105,9 +1105,9 @@ async def list( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1116,9 +1116,9 @@ async def list( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1127,9 +1127,9 @@ async def list( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1138,9 +1138,9 @@ async def list( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1149,9 +1149,9 @@ async def list( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1160,9 +1160,9 @@ async def list( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1171,9 +1171,9 @@ async def list( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1277,9 +1277,9 @@ async def create( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1288,9 +1288,9 @@ async def create( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1299,9 +1299,9 @@ async def create( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1310,9 +1310,9 @@ async def create( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1321,9 +1321,9 @@ async def create( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1332,9 +1332,9 @@ async def create( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1343,9 +1343,9 @@ async def create( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1354,9 +1354,9 @@ async def create( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1365,9 +1365,9 @@ async def create( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1376,9 +1376,9 @@ async def create( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1387,9 +1387,9 @@ async def create( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1398,9 +1398,9 @@ async def create( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1445,9 +1445,9 @@ async def get_usage( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1456,9 +1456,9 @@ async def get_usage( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1467,9 +1467,9 @@ async def get_usage( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1478,9 +1478,9 @@ async def get_usage( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1489,9 +1489,9 @@ async def get_usage( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1500,9 +1500,9 @@ async def get_usage( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1511,9 +1511,9 @@ async def get_usage( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1522,9 +1522,9 @@ async def get_usage( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1533,9 +1533,9 @@ async def get_usage( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1544,9 +1544,9 @@ async def get_usage( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1555,9 +1555,9 @@ async def get_usage( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1566,9 +1566,9 @@ async def get_usage( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1615,9 +1615,9 @@ async def get( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1626,9 +1626,9 @@ async def get( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1637,9 +1637,9 @@ async def get( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1648,9 +1648,9 @@ async def get( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1659,9 +1659,9 @@ async def get( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1670,9 +1670,9 @@ async def get( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1681,9 +1681,9 @@ async def get( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1692,9 +1692,9 @@ async def get( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1703,9 +1703,9 @@ async def get( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1714,9 +1714,9 @@ async def get( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1725,9 +1725,9 @@ async def get( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1736,9 +1736,9 @@ async def get( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1750,7 +1750,7 @@ async def get( async def delete( self, id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> AsyncHttpResponse[typing.Dict[str, typing.Optional[typing.Any]]]: + ) -> AsyncHttpResponse[typing.Dict[str, typing.Any]]: """ Delete a dataset by ID. Datasets are automatically deleted after 30 days, but they can also be deleted manually. @@ -1763,7 +1763,7 @@ async def delete( Returns ------- - AsyncHttpResponse[typing.Dict[str, typing.Optional[typing.Any]]] + AsyncHttpResponse[typing.Dict[str, typing.Any]] A successful response. """ _response = await self._client_wrapper.httpx_client.request( @@ -1774,9 +1774,9 @@ async def delete( try: if 200 <= _response.status_code < 300: _data = typing.cast( - typing.Dict[str, typing.Optional[typing.Any]], + typing.Dict[str, typing.Any], construct_type( - type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore + type_=typing.Dict[str, typing.Any], # type: ignore object_=_response.json(), ), ) @@ -1785,9 +1785,9 @@ async def delete( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1796,9 +1796,9 @@ async def delete( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1807,9 +1807,9 @@ async def delete( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1818,9 +1818,9 @@ async def delete( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1829,9 +1829,9 @@ async def delete( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1840,9 +1840,9 @@ async def delete( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1851,9 +1851,9 @@ async def delete( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1862,9 +1862,9 @@ async def delete( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1873,9 +1873,9 @@ async def delete( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1884,9 +1884,9 @@ async def delete( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1895,9 +1895,9 @@ async def delete( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1906,9 +1906,9 @@ async def delete( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), diff --git a/src/cohere/embed_jobs/raw_client.py b/src/cohere/embed_jobs/raw_client.py index 11c9106e4..e49127f58 100644 --- a/src/cohere/embed_jobs/raw_client.py +++ b/src/cohere/embed_jobs/raw_client.py @@ -69,9 +69,9 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Ht raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -80,9 +80,9 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Ht raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -91,9 +91,9 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Ht raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -102,9 +102,9 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Ht raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -113,9 +113,9 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Ht raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -124,9 +124,9 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Ht raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -135,9 +135,9 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Ht raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -146,9 +146,9 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Ht raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -157,9 +157,9 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Ht raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -168,9 +168,9 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Ht raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -179,9 +179,9 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Ht raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -190,9 +190,9 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Ht raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -289,9 +289,9 @@ def create( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -300,9 +300,9 @@ def create( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -311,9 +311,9 @@ def create( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -322,9 +322,9 @@ def create( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -333,9 +333,9 @@ def create( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -344,9 +344,9 @@ def create( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -355,9 +355,9 @@ def create( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -366,9 +366,9 @@ def create( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -377,9 +377,9 @@ def create( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -388,9 +388,9 @@ def create( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -399,9 +399,9 @@ def create( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -410,9 +410,9 @@ def create( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -458,9 +458,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -469,9 +469,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -480,9 +480,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -491,9 +491,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -502,9 +502,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -513,9 +513,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -524,9 +524,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -535,9 +535,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -546,9 +546,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -557,9 +557,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -568,9 +568,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -579,9 +579,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -619,9 +619,9 @@ def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -630,9 +630,9 @@ def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -641,9 +641,9 @@ def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -652,9 +652,9 @@ def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -663,9 +663,9 @@ def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -674,9 +674,9 @@ def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -685,9 +685,9 @@ def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -696,9 +696,9 @@ def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -707,9 +707,9 @@ def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -718,9 +718,9 @@ def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -729,9 +729,9 @@ def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -740,9 +740,9 @@ def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -792,9 +792,9 @@ async def list( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -803,9 +803,9 @@ async def list( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -814,9 +814,9 @@ async def list( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -825,9 +825,9 @@ async def list( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -836,9 +836,9 @@ async def list( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -847,9 +847,9 @@ async def list( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -858,9 +858,9 @@ async def list( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -869,9 +869,9 @@ async def list( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -880,9 +880,9 @@ async def list( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -891,9 +891,9 @@ async def list( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -902,9 +902,9 @@ async def list( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -913,9 +913,9 @@ async def list( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1012,9 +1012,9 @@ async def create( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1023,9 +1023,9 @@ async def create( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1034,9 +1034,9 @@ async def create( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1045,9 +1045,9 @@ async def create( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1056,9 +1056,9 @@ async def create( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1067,9 +1067,9 @@ async def create( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1078,9 +1078,9 @@ async def create( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1089,9 +1089,9 @@ async def create( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1100,9 +1100,9 @@ async def create( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1111,9 +1111,9 @@ async def create( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1122,9 +1122,9 @@ async def create( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1133,9 +1133,9 @@ async def create( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1183,9 +1183,9 @@ async def get( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1194,9 +1194,9 @@ async def get( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1205,9 +1205,9 @@ async def get( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1216,9 +1216,9 @@ async def get( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1227,9 +1227,9 @@ async def get( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1238,9 +1238,9 @@ async def get( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1249,9 +1249,9 @@ async def get( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1260,9 +1260,9 @@ async def get( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1271,9 +1271,9 @@ async def get( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1282,9 +1282,9 @@ async def get( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1293,9 +1293,9 @@ async def get( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1304,9 +1304,9 @@ async def get( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1346,9 +1346,9 @@ async def cancel( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1357,9 +1357,9 @@ async def cancel( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1368,9 +1368,9 @@ async def cancel( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1379,9 +1379,9 @@ async def cancel( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1390,9 +1390,9 @@ async def cancel( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1401,9 +1401,9 @@ async def cancel( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1412,9 +1412,9 @@ async def cancel( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1423,9 +1423,9 @@ async def cancel( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1434,9 +1434,9 @@ async def cancel( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1445,9 +1445,9 @@ async def cancel( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1456,9 +1456,9 @@ async def cancel( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1467,9 +1467,9 @@ async def cancel( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), diff --git a/src/cohere/errors/bad_request_error.py b/src/cohere/errors/bad_request_error.py index baf5be4f7..ec78e2697 100644 --- a/src/cohere/errors/bad_request_error.py +++ b/src/cohere/errors/bad_request_error.py @@ -6,5 +6,5 @@ class BadRequestError(ApiError): - def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None): + def __init__(self, body: typing.Any, headers: typing.Optional[typing.Dict[str, str]] = None): super().__init__(status_code=400, headers=headers, body=body) diff --git a/src/cohere/errors/client_closed_request_error.py b/src/cohere/errors/client_closed_request_error.py index 869cec5d8..eaec56461 100644 --- a/src/cohere/errors/client_closed_request_error.py +++ b/src/cohere/errors/client_closed_request_error.py @@ -6,5 +6,5 @@ class ClientClosedRequestError(ApiError): - def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None): + def __init__(self, body: typing.Any, headers: typing.Optional[typing.Dict[str, str]] = None): super().__init__(status_code=499, headers=headers, body=body) diff --git a/src/cohere/errors/forbidden_error.py b/src/cohere/errors/forbidden_error.py index 3e390b0de..07d7e45b8 100644 --- a/src/cohere/errors/forbidden_error.py +++ b/src/cohere/errors/forbidden_error.py @@ -6,5 +6,5 @@ class ForbiddenError(ApiError): - def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None): + def __init__(self, body: typing.Any, headers: typing.Optional[typing.Dict[str, str]] = None): super().__init__(status_code=403, headers=headers, body=body) diff --git a/src/cohere/errors/gateway_timeout_error.py b/src/cohere/errors/gateway_timeout_error.py index b48950179..b4a413427 100644 --- a/src/cohere/errors/gateway_timeout_error.py +++ b/src/cohere/errors/gateway_timeout_error.py @@ -6,5 +6,5 @@ class GatewayTimeoutError(ApiError): - def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None): + def __init__(self, body: typing.Any, headers: typing.Optional[typing.Dict[str, str]] = None): super().__init__(status_code=504, headers=headers, body=body) diff --git a/src/cohere/errors/internal_server_error.py b/src/cohere/errors/internal_server_error.py index 14313ab41..fabcc45cf 100644 --- a/src/cohere/errors/internal_server_error.py +++ b/src/cohere/errors/internal_server_error.py @@ -6,5 +6,5 @@ class InternalServerError(ApiError): - def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None): + def __init__(self, body: typing.Any, headers: typing.Optional[typing.Dict[str, str]] = None): super().__init__(status_code=500, headers=headers, body=body) diff --git a/src/cohere/errors/invalid_token_error.py b/src/cohere/errors/invalid_token_error.py index 35fd0b592..367de5a5b 100644 --- a/src/cohere/errors/invalid_token_error.py +++ b/src/cohere/errors/invalid_token_error.py @@ -6,5 +6,5 @@ class InvalidTokenError(ApiError): - def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None): + def __init__(self, body: typing.Any, headers: typing.Optional[typing.Dict[str, str]] = None): super().__init__(status_code=498, headers=headers, body=body) diff --git a/src/cohere/errors/not_found_error.py b/src/cohere/errors/not_found_error.py index dcd60e383..75f557df6 100644 --- a/src/cohere/errors/not_found_error.py +++ b/src/cohere/errors/not_found_error.py @@ -6,5 +6,5 @@ class NotFoundError(ApiError): - def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None): + def __init__(self, body: typing.Any, headers: typing.Optional[typing.Dict[str, str]] = None): super().__init__(status_code=404, headers=headers, body=body) diff --git a/src/cohere/errors/not_implemented_error.py b/src/cohere/errors/not_implemented_error.py index 857b88416..2a7e0463a 100644 --- a/src/cohere/errors/not_implemented_error.py +++ b/src/cohere/errors/not_implemented_error.py @@ -6,5 +6,5 @@ class NotImplementedError(ApiError): - def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None): + def __init__(self, body: typing.Any, headers: typing.Optional[typing.Dict[str, str]] = None): super().__init__(status_code=501, headers=headers, body=body) diff --git a/src/cohere/errors/service_unavailable_error.py b/src/cohere/errors/service_unavailable_error.py index 28a6a56de..950c47402 100644 --- a/src/cohere/errors/service_unavailable_error.py +++ b/src/cohere/errors/service_unavailable_error.py @@ -6,5 +6,5 @@ class ServiceUnavailableError(ApiError): - def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None): + def __init__(self, body: typing.Any, headers: typing.Optional[typing.Dict[str, str]] = None): super().__init__(status_code=503, headers=headers, body=body) diff --git a/src/cohere/errors/too_many_requests_error.py b/src/cohere/errors/too_many_requests_error.py index 270539909..705d6f1ba 100644 --- a/src/cohere/errors/too_many_requests_error.py +++ b/src/cohere/errors/too_many_requests_error.py @@ -6,5 +6,5 @@ class TooManyRequestsError(ApiError): - def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None): + def __init__(self, body: typing.Any, headers: typing.Optional[typing.Dict[str, str]] = None): super().__init__(status_code=429, headers=headers, body=body) diff --git a/src/cohere/errors/unauthorized_error.py b/src/cohere/errors/unauthorized_error.py index c83b25c26..7e48bb6f1 100644 --- a/src/cohere/errors/unauthorized_error.py +++ b/src/cohere/errors/unauthorized_error.py @@ -6,5 +6,5 @@ class UnauthorizedError(ApiError): - def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None): + def __init__(self, body: typing.Any, headers: typing.Optional[typing.Dict[str, str]] = None): super().__init__(status_code=401, headers=headers, body=body) diff --git a/src/cohere/errors/unprocessable_entity_error.py b/src/cohere/errors/unprocessable_entity_error.py index 93cb1ab32..1c801a4bc 100644 --- a/src/cohere/errors/unprocessable_entity_error.py +++ b/src/cohere/errors/unprocessable_entity_error.py @@ -6,5 +6,5 @@ class UnprocessableEntityError(ApiError): - def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None): + def __init__(self, body: typing.Any, headers: typing.Optional[typing.Dict[str, str]] = None): super().__init__(status_code=422, headers=headers, body=body) diff --git a/src/cohere/finetuning/finetuning/types/delete_finetuned_model_response.py b/src/cohere/finetuning/finetuning/types/delete_finetuned_model_response.py index 0f730dda7..a61b4e681 100644 --- a/src/cohere/finetuning/finetuning/types/delete_finetuned_model_response.py +++ b/src/cohere/finetuning/finetuning/types/delete_finetuned_model_response.py @@ -2,4 +2,4 @@ import typing -DeleteFinetunedModelResponse = typing.Dict[str, typing.Optional[typing.Any]] +DeleteFinetunedModelResponse = typing.Dict[str, typing.Any] diff --git a/src/cohere/finetuning/raw_client.py b/src/cohere/finetuning/raw_client.py index 54e65b0f2..a5a56addb 100644 --- a/src/cohere/finetuning/raw_client.py +++ b/src/cohere/finetuning/raw_client.py @@ -95,9 +95,9 @@ def list_finetuned_models( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -106,9 +106,9 @@ def list_finetuned_models( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -117,9 +117,9 @@ def list_finetuned_models( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -128,9 +128,9 @@ def list_finetuned_models( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -139,9 +139,9 @@ def list_finetuned_models( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -150,9 +150,9 @@ def list_finetuned_models( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -204,9 +204,9 @@ def create_finetuned_model( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -215,9 +215,9 @@ def create_finetuned_model( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -226,9 +226,9 @@ def create_finetuned_model( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -237,9 +237,9 @@ def create_finetuned_model( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -248,9 +248,9 @@ def create_finetuned_model( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -259,9 +259,9 @@ def create_finetuned_model( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -309,9 +309,9 @@ def get_finetuned_model( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -320,9 +320,9 @@ def get_finetuned_model( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -331,9 +331,9 @@ def get_finetuned_model( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -342,9 +342,9 @@ def get_finetuned_model( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -353,9 +353,9 @@ def get_finetuned_model( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -364,9 +364,9 @@ def get_finetuned_model( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -415,9 +415,9 @@ def delete_finetuned_model( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -426,9 +426,9 @@ def delete_finetuned_model( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -437,9 +437,9 @@ def delete_finetuned_model( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -448,9 +448,9 @@ def delete_finetuned_model( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -459,9 +459,9 @@ def delete_finetuned_model( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -470,9 +470,9 @@ def delete_finetuned_model( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -546,9 +546,9 @@ def update_finetuned_model( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -557,9 +557,9 @@ def update_finetuned_model( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -568,9 +568,9 @@ def update_finetuned_model( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -579,9 +579,9 @@ def update_finetuned_model( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -590,9 +590,9 @@ def update_finetuned_model( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -601,9 +601,9 @@ def update_finetuned_model( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -679,9 +679,9 @@ def list_events( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -690,9 +690,9 @@ def list_events( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -701,9 +701,9 @@ def list_events( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -712,9 +712,9 @@ def list_events( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -723,9 +723,9 @@ def list_events( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -734,9 +734,9 @@ def list_events( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -802,9 +802,9 @@ def list_training_step_metrics( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -813,9 +813,9 @@ def list_training_step_metrics( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -824,9 +824,9 @@ def list_training_step_metrics( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -835,9 +835,9 @@ def list_training_step_metrics( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -846,9 +846,9 @@ def list_training_step_metrics( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -857,9 +857,9 @@ def list_training_step_metrics( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -934,9 +934,9 @@ async def list_finetuned_models( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -945,9 +945,9 @@ async def list_finetuned_models( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -956,9 +956,9 @@ async def list_finetuned_models( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -967,9 +967,9 @@ async def list_finetuned_models( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -978,9 +978,9 @@ async def list_finetuned_models( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -989,9 +989,9 @@ async def list_finetuned_models( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1043,9 +1043,9 @@ async def create_finetuned_model( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1054,9 +1054,9 @@ async def create_finetuned_model( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1065,9 +1065,9 @@ async def create_finetuned_model( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1076,9 +1076,9 @@ async def create_finetuned_model( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1087,9 +1087,9 @@ async def create_finetuned_model( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1098,9 +1098,9 @@ async def create_finetuned_model( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1148,9 +1148,9 @@ async def get_finetuned_model( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1159,9 +1159,9 @@ async def get_finetuned_model( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1170,9 +1170,9 @@ async def get_finetuned_model( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1181,9 +1181,9 @@ async def get_finetuned_model( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1192,9 +1192,9 @@ async def get_finetuned_model( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1203,9 +1203,9 @@ async def get_finetuned_model( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1254,9 +1254,9 @@ async def delete_finetuned_model( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1265,9 +1265,9 @@ async def delete_finetuned_model( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1276,9 +1276,9 @@ async def delete_finetuned_model( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1287,9 +1287,9 @@ async def delete_finetuned_model( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1298,9 +1298,9 @@ async def delete_finetuned_model( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1309,9 +1309,9 @@ async def delete_finetuned_model( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1385,9 +1385,9 @@ async def update_finetuned_model( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1396,9 +1396,9 @@ async def update_finetuned_model( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1407,9 +1407,9 @@ async def update_finetuned_model( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1418,9 +1418,9 @@ async def update_finetuned_model( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1429,9 +1429,9 @@ async def update_finetuned_model( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1440,9 +1440,9 @@ async def update_finetuned_model( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1518,9 +1518,9 @@ async def list_events( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1529,9 +1529,9 @@ async def list_events( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1540,9 +1540,9 @@ async def list_events( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1551,9 +1551,9 @@ async def list_events( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1562,9 +1562,9 @@ async def list_events( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1573,9 +1573,9 @@ async def list_events( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1641,9 +1641,9 @@ async def list_training_step_metrics( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1652,9 +1652,9 @@ async def list_training_step_metrics( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1663,9 +1663,9 @@ async def list_training_step_metrics( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1674,9 +1674,9 @@ async def list_training_step_metrics( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1685,9 +1685,9 @@ async def list_training_step_metrics( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1696,9 +1696,9 @@ async def list_training_step_metrics( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), diff --git a/src/cohere/models/raw_client.py b/src/cohere/models/raw_client.py index 2dcaf2d21..57037d6de 100644 --- a/src/cohere/models/raw_client.py +++ b/src/cohere/models/raw_client.py @@ -67,9 +67,9 @@ def get( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -78,9 +78,9 @@ def get( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -89,9 +89,9 @@ def get( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -100,9 +100,9 @@ def get( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -111,9 +111,9 @@ def get( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -122,9 +122,9 @@ def get( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -133,9 +133,9 @@ def get( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -144,9 +144,9 @@ def get( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -155,9 +155,9 @@ def get( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -166,9 +166,9 @@ def get( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -177,9 +177,9 @@ def get( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -188,9 +188,9 @@ def get( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -260,9 +260,9 @@ def list( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -271,9 +271,9 @@ def list( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -282,9 +282,9 @@ def list( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -293,9 +293,9 @@ def list( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -304,9 +304,9 @@ def list( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -315,9 +315,9 @@ def list( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -326,9 +326,9 @@ def list( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -337,9 +337,9 @@ def list( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -348,9 +348,9 @@ def list( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -359,9 +359,9 @@ def list( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -370,9 +370,9 @@ def list( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -381,9 +381,9 @@ def list( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -435,9 +435,9 @@ async def get( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -446,9 +446,9 @@ async def get( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -457,9 +457,9 @@ async def get( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -468,9 +468,9 @@ async def get( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -479,9 +479,9 @@ async def get( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -490,9 +490,9 @@ async def get( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -501,9 +501,9 @@ async def get( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -512,9 +512,9 @@ async def get( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -523,9 +523,9 @@ async def get( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -534,9 +534,9 @@ async def get( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -545,9 +545,9 @@ async def get( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -556,9 +556,9 @@ async def get( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -628,9 +628,9 @@ async def list( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -639,9 +639,9 @@ async def list( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -650,9 +650,9 @@ async def list( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -661,9 +661,9 @@ async def list( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -672,9 +672,9 @@ async def list( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -683,9 +683,9 @@ async def list( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -694,9 +694,9 @@ async def list( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -705,9 +705,9 @@ async def list( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -716,9 +716,9 @@ async def list( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -727,9 +727,9 @@ async def list( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -738,9 +738,9 @@ async def list( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -749,9 +749,9 @@ async def list( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), diff --git a/src/cohere/raw_base_client.py b/src/cohere/raw_base_client.py index 5f2cd4455..645086721 100644 --- a/src/cohere/raw_base_client.py +++ b/src/cohere/raw_base_client.py @@ -113,7 +113,7 @@ def chat_stream( Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments accepts : typing.Optional[typing.Literal["text/event-stream"]] - Pass text/event-stream to receive the streamed response as server-sent events. The default is `\n` delimited events. + Pass text/event-stream to receive the streamed response as server-sent events. The default is `\\n` delimited events. model : typing.Optional[str] The name of a compatible [Cohere model](https://docs.cohere.com/docs/models) or the ID of a [fine-tuned](https://docs.cohere.com/docs/chat-fine-tuning) model. @@ -399,9 +399,9 @@ def _iter(): raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -410,9 +410,9 @@ def _iter(): raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -421,9 +421,9 @@ def _iter(): raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -432,9 +432,9 @@ def _iter(): raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -443,9 +443,9 @@ def _iter(): raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -454,9 +454,9 @@ def _iter(): raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -465,9 +465,9 @@ def _iter(): raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -476,9 +476,9 @@ def _iter(): raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -487,9 +487,9 @@ def _iter(): raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -498,9 +498,9 @@ def _iter(): raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -509,9 +509,9 @@ def _iter(): raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -520,9 +520,9 @@ def _iter(): raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -579,7 +579,7 @@ def chat( Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments accepts : typing.Optional[typing.Literal["text/event-stream"]] - Pass text/event-stream to receive the streamed response as server-sent events. The default is `\n` delimited events. + Pass text/event-stream to receive the streamed response as server-sent events. The default is `\\n` delimited events. model : typing.Optional[str] The name of a compatible [Cohere model](https://docs.cohere.com/docs/models) or the ID of a [fine-tuned](https://docs.cohere.com/docs/chat-fine-tuning) model. @@ -852,9 +852,9 @@ def chat( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -863,9 +863,9 @@ def chat( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -874,9 +874,9 @@ def chat( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -885,9 +885,9 @@ def chat( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -896,9 +896,9 @@ def chat( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -907,9 +907,9 @@ def chat( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -918,9 +918,9 @@ def chat( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -929,9 +929,9 @@ def chat( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -940,9 +940,9 @@ def chat( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -951,9 +951,9 @@ def chat( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -962,9 +962,9 @@ def chat( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -973,9 +973,9 @@ def chat( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1154,9 +1154,9 @@ def _iter(): raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1165,9 +1165,9 @@ def _iter(): raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1176,9 +1176,9 @@ def _iter(): raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1187,9 +1187,9 @@ def _iter(): raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1198,9 +1198,9 @@ def _iter(): raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1209,9 +1209,9 @@ def _iter(): raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1220,9 +1220,9 @@ def _iter(): raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1231,9 +1231,9 @@ def _iter(): raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1242,9 +1242,9 @@ def _iter(): raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1253,9 +1253,9 @@ def _iter(): raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1264,9 +1264,9 @@ def _iter(): raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1275,9 +1275,9 @@ def _iter(): raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1446,9 +1446,9 @@ def generate( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1457,9 +1457,9 @@ def generate( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1468,9 +1468,9 @@ def generate( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1479,9 +1479,9 @@ def generate( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1490,9 +1490,9 @@ def generate( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1501,9 +1501,9 @@ def generate( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1512,9 +1512,9 @@ def generate( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1523,9 +1523,9 @@ def generate( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1534,9 +1534,9 @@ def generate( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1545,9 +1545,9 @@ def generate( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1556,9 +1556,9 @@ def generate( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1567,9 +1567,9 @@ def generate( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1669,9 +1669,9 @@ def embed( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1680,9 +1680,9 @@ def embed( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1691,9 +1691,9 @@ def embed( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1702,9 +1702,9 @@ def embed( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1713,9 +1713,9 @@ def embed( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1724,9 +1724,9 @@ def embed( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1735,9 +1735,9 @@ def embed( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1746,9 +1746,9 @@ def embed( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1757,9 +1757,9 @@ def embed( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1768,9 +1768,9 @@ def embed( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1779,9 +1779,9 @@ def embed( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1790,9 +1790,9 @@ def embed( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1888,9 +1888,9 @@ def rerank( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1899,9 +1899,9 @@ def rerank( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1910,9 +1910,9 @@ def rerank( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1921,9 +1921,9 @@ def rerank( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1932,9 +1932,9 @@ def rerank( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1943,9 +1943,9 @@ def rerank( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1954,9 +1954,9 @@ def rerank( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1965,9 +1965,9 @@ def rerank( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1976,9 +1976,9 @@ def rerank( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1987,9 +1987,9 @@ def rerank( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1998,9 +1998,9 @@ def rerank( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2009,9 +2009,9 @@ def rerank( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2097,9 +2097,9 @@ def classify( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2108,9 +2108,9 @@ def classify( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2119,9 +2119,9 @@ def classify( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2130,9 +2130,9 @@ def classify( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2141,9 +2141,9 @@ def classify( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2152,9 +2152,9 @@ def classify( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2163,9 +2163,9 @@ def classify( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2174,9 +2174,9 @@ def classify( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2185,9 +2185,9 @@ def classify( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2196,9 +2196,9 @@ def classify( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2207,9 +2207,9 @@ def classify( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2218,9 +2218,9 @@ def classify( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2311,9 +2311,9 @@ def summarize( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2322,9 +2322,9 @@ def summarize( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2333,9 +2333,9 @@ def summarize( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2344,9 +2344,9 @@ def summarize( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2355,9 +2355,9 @@ def summarize( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2366,9 +2366,9 @@ def summarize( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2377,9 +2377,9 @@ def summarize( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2388,9 +2388,9 @@ def summarize( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2399,9 +2399,9 @@ def summarize( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2410,9 +2410,9 @@ def summarize( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2421,9 +2421,9 @@ def summarize( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2432,9 +2432,9 @@ def summarize( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2493,9 +2493,9 @@ def tokenize( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2504,9 +2504,9 @@ def tokenize( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2515,9 +2515,9 @@ def tokenize( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2526,9 +2526,9 @@ def tokenize( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2537,9 +2537,9 @@ def tokenize( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2548,9 +2548,9 @@ def tokenize( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2559,9 +2559,9 @@ def tokenize( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2570,9 +2570,9 @@ def tokenize( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2581,9 +2581,9 @@ def tokenize( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2592,9 +2592,9 @@ def tokenize( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2603,9 +2603,9 @@ def tokenize( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2614,9 +2614,9 @@ def tokenize( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2675,9 +2675,9 @@ def detokenize( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2686,9 +2686,9 @@ def detokenize( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2697,9 +2697,9 @@ def detokenize( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2708,9 +2708,9 @@ def detokenize( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2719,9 +2719,9 @@ def detokenize( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2730,9 +2730,9 @@ def detokenize( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2741,9 +2741,9 @@ def detokenize( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2752,9 +2752,9 @@ def detokenize( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2763,9 +2763,9 @@ def detokenize( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2774,9 +2774,9 @@ def detokenize( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2785,9 +2785,9 @@ def detokenize( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2796,9 +2796,9 @@ def detokenize( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2843,9 +2843,9 @@ def check_api_key( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2854,9 +2854,9 @@ def check_api_key( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2865,9 +2865,9 @@ def check_api_key( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2876,9 +2876,9 @@ def check_api_key( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2887,9 +2887,9 @@ def check_api_key( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2898,9 +2898,9 @@ def check_api_key( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2909,9 +2909,9 @@ def check_api_key( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2920,9 +2920,9 @@ def check_api_key( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2931,9 +2931,9 @@ def check_api_key( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2942,9 +2942,9 @@ def check_api_key( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2953,9 +2953,9 @@ def check_api_key( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2964,9 +2964,9 @@ def check_api_key( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3026,7 +3026,7 @@ async def chat_stream( Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments accepts : typing.Optional[typing.Literal["text/event-stream"]] - Pass text/event-stream to receive the streamed response as server-sent events. The default is `\n` delimited events. + Pass text/event-stream to receive the streamed response as server-sent events. The default is `\\n` delimited events. model : typing.Optional[str] The name of a compatible [Cohere model](https://docs.cohere.com/docs/models) or the ID of a [fine-tuned](https://docs.cohere.com/docs/chat-fine-tuning) model. @@ -3312,9 +3312,9 @@ async def _iter(): raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3323,9 +3323,9 @@ async def _iter(): raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3334,9 +3334,9 @@ async def _iter(): raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3345,9 +3345,9 @@ async def _iter(): raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3356,9 +3356,9 @@ async def _iter(): raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3367,9 +3367,9 @@ async def _iter(): raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3378,9 +3378,9 @@ async def _iter(): raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3389,9 +3389,9 @@ async def _iter(): raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3400,9 +3400,9 @@ async def _iter(): raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3411,9 +3411,9 @@ async def _iter(): raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3422,9 +3422,9 @@ async def _iter(): raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3433,9 +3433,9 @@ async def _iter(): raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3492,7 +3492,7 @@ async def chat( Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments accepts : typing.Optional[typing.Literal["text/event-stream"]] - Pass text/event-stream to receive the streamed response as server-sent events. The default is `\n` delimited events. + Pass text/event-stream to receive the streamed response as server-sent events. The default is `\\n` delimited events. model : typing.Optional[str] The name of a compatible [Cohere model](https://docs.cohere.com/docs/models) or the ID of a [fine-tuned](https://docs.cohere.com/docs/chat-fine-tuning) model. @@ -3765,9 +3765,9 @@ async def chat( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3776,9 +3776,9 @@ async def chat( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3787,9 +3787,9 @@ async def chat( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3798,9 +3798,9 @@ async def chat( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3809,9 +3809,9 @@ async def chat( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3820,9 +3820,9 @@ async def chat( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3831,9 +3831,9 @@ async def chat( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3842,9 +3842,9 @@ async def chat( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3853,9 +3853,9 @@ async def chat( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3864,9 +3864,9 @@ async def chat( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3875,9 +3875,9 @@ async def chat( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -3886,9 +3886,9 @@ async def chat( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4067,9 +4067,9 @@ async def _iter(): raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4078,9 +4078,9 @@ async def _iter(): raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4089,9 +4089,9 @@ async def _iter(): raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4100,9 +4100,9 @@ async def _iter(): raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4111,9 +4111,9 @@ async def _iter(): raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4122,9 +4122,9 @@ async def _iter(): raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4133,9 +4133,9 @@ async def _iter(): raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4144,9 +4144,9 @@ async def _iter(): raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4155,9 +4155,9 @@ async def _iter(): raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4166,9 +4166,9 @@ async def _iter(): raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4177,9 +4177,9 @@ async def _iter(): raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4188,9 +4188,9 @@ async def _iter(): raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4359,9 +4359,9 @@ async def generate( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4370,9 +4370,9 @@ async def generate( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4381,9 +4381,9 @@ async def generate( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4392,9 +4392,9 @@ async def generate( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4403,9 +4403,9 @@ async def generate( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4414,9 +4414,9 @@ async def generate( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4425,9 +4425,9 @@ async def generate( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4436,9 +4436,9 @@ async def generate( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4447,9 +4447,9 @@ async def generate( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4458,9 +4458,9 @@ async def generate( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4469,9 +4469,9 @@ async def generate( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4480,9 +4480,9 @@ async def generate( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4582,9 +4582,9 @@ async def embed( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4593,9 +4593,9 @@ async def embed( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4604,9 +4604,9 @@ async def embed( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4615,9 +4615,9 @@ async def embed( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4626,9 +4626,9 @@ async def embed( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4637,9 +4637,9 @@ async def embed( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4648,9 +4648,9 @@ async def embed( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4659,9 +4659,9 @@ async def embed( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4670,9 +4670,9 @@ async def embed( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4681,9 +4681,9 @@ async def embed( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4692,9 +4692,9 @@ async def embed( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4703,9 +4703,9 @@ async def embed( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4801,9 +4801,9 @@ async def rerank( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4812,9 +4812,9 @@ async def rerank( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4823,9 +4823,9 @@ async def rerank( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4834,9 +4834,9 @@ async def rerank( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4845,9 +4845,9 @@ async def rerank( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4856,9 +4856,9 @@ async def rerank( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4867,9 +4867,9 @@ async def rerank( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4878,9 +4878,9 @@ async def rerank( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4889,9 +4889,9 @@ async def rerank( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4900,9 +4900,9 @@ async def rerank( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4911,9 +4911,9 @@ async def rerank( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -4922,9 +4922,9 @@ async def rerank( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5010,9 +5010,9 @@ async def classify( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5021,9 +5021,9 @@ async def classify( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5032,9 +5032,9 @@ async def classify( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5043,9 +5043,9 @@ async def classify( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5054,9 +5054,9 @@ async def classify( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5065,9 +5065,9 @@ async def classify( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5076,9 +5076,9 @@ async def classify( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5087,9 +5087,9 @@ async def classify( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5098,9 +5098,9 @@ async def classify( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5109,9 +5109,9 @@ async def classify( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5120,9 +5120,9 @@ async def classify( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5131,9 +5131,9 @@ async def classify( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5224,9 +5224,9 @@ async def summarize( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5235,9 +5235,9 @@ async def summarize( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5246,9 +5246,9 @@ async def summarize( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5257,9 +5257,9 @@ async def summarize( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5268,9 +5268,9 @@ async def summarize( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5279,9 +5279,9 @@ async def summarize( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5290,9 +5290,9 @@ async def summarize( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5301,9 +5301,9 @@ async def summarize( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5312,9 +5312,9 @@ async def summarize( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5323,9 +5323,9 @@ async def summarize( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5334,9 +5334,9 @@ async def summarize( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5345,9 +5345,9 @@ async def summarize( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5406,9 +5406,9 @@ async def tokenize( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5417,9 +5417,9 @@ async def tokenize( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5428,9 +5428,9 @@ async def tokenize( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5439,9 +5439,9 @@ async def tokenize( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5450,9 +5450,9 @@ async def tokenize( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5461,9 +5461,9 @@ async def tokenize( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5472,9 +5472,9 @@ async def tokenize( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5483,9 +5483,9 @@ async def tokenize( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5494,9 +5494,9 @@ async def tokenize( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5505,9 +5505,9 @@ async def tokenize( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5516,9 +5516,9 @@ async def tokenize( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5527,9 +5527,9 @@ async def tokenize( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5588,9 +5588,9 @@ async def detokenize( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5599,9 +5599,9 @@ async def detokenize( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5610,9 +5610,9 @@ async def detokenize( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5621,9 +5621,9 @@ async def detokenize( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5632,9 +5632,9 @@ async def detokenize( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5643,9 +5643,9 @@ async def detokenize( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5654,9 +5654,9 @@ async def detokenize( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5665,9 +5665,9 @@ async def detokenize( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5676,9 +5676,9 @@ async def detokenize( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5687,9 +5687,9 @@ async def detokenize( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5698,9 +5698,9 @@ async def detokenize( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5709,9 +5709,9 @@ async def detokenize( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5756,9 +5756,9 @@ async def check_api_key( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5767,9 +5767,9 @@ async def check_api_key( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5778,9 +5778,9 @@ async def check_api_key( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5789,9 +5789,9 @@ async def check_api_key( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5800,9 +5800,9 @@ async def check_api_key( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5811,9 +5811,9 @@ async def check_api_key( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5822,9 +5822,9 @@ async def check_api_key( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5833,9 +5833,9 @@ async def check_api_key( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5844,9 +5844,9 @@ async def check_api_key( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5855,9 +5855,9 @@ async def check_api_key( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5866,9 +5866,9 @@ async def check_api_key( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -5877,9 +5877,9 @@ async def check_api_key( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), diff --git a/src/cohere/types/__init__.py b/src/cohere/types/__init__.py index 54bd3509c..5acc4bb9d 100644 --- a/src/cohere/types/__init__.py +++ b/src/cohere/types/__init__.py @@ -18,10 +18,10 @@ ThinkingAssistantMessageResponseContentItem, ) from .assistant_message_v2content import AssistantMessageV2Content - from .assistant_message_v2content_item import ( - AssistantMessageV2ContentItem, - TextAssistantMessageV2ContentItem, - ThinkingAssistantMessageV2ContentItem, + from .assistant_message_v2content_one_item import ( + AssistantMessageV2ContentOneItem, + TextAssistantMessageV2ContentOneItem, + ThinkingAssistantMessageV2ContentOneItem, ) from .auth_token_type import AuthTokenType from .chat_citation import ChatCitation @@ -133,6 +133,7 @@ from .document_content import DocumentContent from .embed_by_type_response import EmbedByTypeResponse from .embed_by_type_response_embeddings import EmbedByTypeResponseEmbeddings + from .embed_by_type_response_response_type import EmbedByTypeResponseResponseType from .embed_content import EmbedContent, ImageUrlEmbedContent, TextEmbedContent from .embed_floats_response import EmbedFloatsResponse from .embed_image import EmbedImage @@ -212,7 +213,7 @@ from .summarize_response import SummarizeResponse from .system_message_v2 import SystemMessageV2 from .system_message_v2content import SystemMessageV2Content - from .system_message_v2content_item import SystemMessageV2ContentItem, TextSystemMessageV2ContentItem + from .system_message_v2content_one_item import SystemMessageV2ContentOneItem, TextSystemMessageV2ContentOneItem from .thinking import Thinking from .thinking_type import ThinkingType from .tokenize_response import TokenizeResponse @@ -244,7 +245,7 @@ "AssistantMessageResponse": ".assistant_message_response", "AssistantMessageResponseContentItem": ".assistant_message_response_content_item", "AssistantMessageV2Content": ".assistant_message_v2content", - "AssistantMessageV2ContentItem": ".assistant_message_v2content_item", + "AssistantMessageV2ContentOneItem": ".assistant_message_v2content_one_item", "AuthTokenType": ".auth_token_type", "ChatCitation": ".chat_citation", "ChatCitationGenerationEvent": ".chat_citation_generation_event", @@ -350,6 +351,7 @@ "DocumentToolContent": ".tool_content", "EmbedByTypeResponse": ".embed_by_type_response", "EmbedByTypeResponseEmbeddings": ".embed_by_type_response_embeddings", + "EmbedByTypeResponseResponseType": ".embed_by_type_response_response_type", "EmbedContent": ".embed_content", "EmbedFloatsResponse": ".embed_floats_response", "EmbedImage": ".embed_image", @@ -427,20 +429,20 @@ "SystemMessage": ".message", "SystemMessageV2": ".system_message_v2", "SystemMessageV2Content": ".system_message_v2content", - "SystemMessageV2ContentItem": ".system_message_v2content_item", + "SystemMessageV2ContentOneItem": ".system_message_v2content_one_item", "TextAssistantMessageResponseContentItem": ".assistant_message_response_content_item", - "TextAssistantMessageV2ContentItem": ".assistant_message_v2content_item", + "TextAssistantMessageV2ContentOneItem": ".assistant_message_v2content_one_item", "TextContent": ".content", "TextEmbedContent": ".embed_content", "TextGenerationGenerateStreamedResponse": ".generate_streamed_response", "TextGenerationStreamedChatResponse": ".streamed_chat_response", "TextResponseFormat": ".response_format", "TextResponseFormatV2": ".response_format_v2", - "TextSystemMessageV2ContentItem": ".system_message_v2content_item", + "TextSystemMessageV2ContentOneItem": ".system_message_v2content_one_item", "TextToolContent": ".tool_content", "Thinking": ".thinking", "ThinkingAssistantMessageResponseContentItem": ".assistant_message_response_content_item", - "ThinkingAssistantMessageV2ContentItem": ".assistant_message_v2content_item", + "ThinkingAssistantMessageV2ContentOneItem": ".assistant_message_v2content_one_item", "ThinkingType": ".thinking_type", "TokenizeResponse": ".tokenize_response", "Tool": ".tool", @@ -502,7 +504,7 @@ def __dir__(): "AssistantMessageResponse", "AssistantMessageResponseContentItem", "AssistantMessageV2Content", - "AssistantMessageV2ContentItem", + "AssistantMessageV2ContentOneItem", "AuthTokenType", "ChatCitation", "ChatCitationGenerationEvent", @@ -608,6 +610,7 @@ def __dir__(): "DocumentToolContent", "EmbedByTypeResponse", "EmbedByTypeResponseEmbeddings", + "EmbedByTypeResponseResponseType", "EmbedContent", "EmbedFloatsResponse", "EmbedImage", @@ -685,20 +688,20 @@ def __dir__(): "SystemMessage", "SystemMessageV2", "SystemMessageV2Content", - "SystemMessageV2ContentItem", + "SystemMessageV2ContentOneItem", "TextAssistantMessageResponseContentItem", - "TextAssistantMessageV2ContentItem", + "TextAssistantMessageV2ContentOneItem", "TextContent", "TextEmbedContent", "TextGenerationGenerateStreamedResponse", "TextGenerationStreamedChatResponse", "TextResponseFormat", "TextResponseFormatV2", - "TextSystemMessageV2ContentItem", + "TextSystemMessageV2ContentOneItem", "TextToolContent", "Thinking", "ThinkingAssistantMessageResponseContentItem", - "ThinkingAssistantMessageV2ContentItem", + "ThinkingAssistantMessageV2ContentOneItem", "ThinkingType", "TokenizeResponse", "Tool", diff --git a/src/cohere/types/assistant_message_v2content.py b/src/cohere/types/assistant_message_v2content.py index 9343e0cf5..9b32400af 100644 --- a/src/cohere/types/assistant_message_v2content.py +++ b/src/cohere/types/assistant_message_v2content.py @@ -2,6 +2,6 @@ import typing -from .assistant_message_v2content_item import AssistantMessageV2ContentItem +from .assistant_message_v2content_one_item import AssistantMessageV2ContentOneItem -AssistantMessageV2Content = typing.Union[str, typing.List[AssistantMessageV2ContentItem]] +AssistantMessageV2Content = typing.Union[str, typing.List[AssistantMessageV2ContentOneItem]] diff --git a/src/cohere/types/assistant_message_v2content_item.py b/src/cohere/types/assistant_message_v2content_one_item.py similarity index 76% rename from src/cohere/types/assistant_message_v2content_item.py rename to src/cohere/types/assistant_message_v2content_one_item.py index 5a65bf222..46f2706fa 100644 --- a/src/cohere/types/assistant_message_v2content_item.py +++ b/src/cohere/types/assistant_message_v2content_one_item.py @@ -10,7 +10,7 @@ from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata -class TextAssistantMessageV2ContentItem(UncheckedBaseModel): +class TextAssistantMessageV2ContentOneItem(UncheckedBaseModel): type: typing.Literal["text"] = "text" text: str @@ -23,7 +23,7 @@ class Config: extra = pydantic.Extra.allow -class ThinkingAssistantMessageV2ContentItem(UncheckedBaseModel): +class ThinkingAssistantMessageV2ContentOneItem(UncheckedBaseModel): type: typing.Literal["thinking"] = "thinking" thinking: str @@ -36,7 +36,7 @@ class Config: extra = pydantic.Extra.allow -AssistantMessageV2ContentItem = typing_extensions.Annotated[ - typing.Union[TextAssistantMessageV2ContentItem, ThinkingAssistantMessageV2ContentItem], +AssistantMessageV2ContentOneItem = typing_extensions.Annotated[ + typing.Union[TextAssistantMessageV2ContentOneItem, ThinkingAssistantMessageV2ContentOneItem], UnionMetadata(discriminant="type"), ] diff --git a/src/cohere/types/chat_connector.py b/src/cohere/types/chat_connector.py index ca20cf012..9fe42f40f 100644 --- a/src/cohere/types/chat_connector.py +++ b/src/cohere/types/chat_connector.py @@ -29,7 +29,7 @@ class ChatConnector(UncheckedBaseModel): When `true`, the request will continue if this connector returned an error. """ - options: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) + options: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None) """ Provides the connector with different settings at request time. The key/value pairs of this object are specific to each connector. diff --git a/src/cohere/types/chat_document_source.py b/src/cohere/types/chat_document_source.py index 97bb33ffc..c8995c0f4 100644 --- a/src/cohere/types/chat_document_source.py +++ b/src/cohere/types/chat_document_source.py @@ -17,7 +17,7 @@ class ChatDocumentSource(UncheckedBaseModel): The unique identifier of the document """ - document: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None + document: typing.Optional[typing.Dict[str, typing.Any]] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 diff --git a/src/cohere/types/chat_tool_source.py b/src/cohere/types/chat_tool_source.py index e22a9f1a1..bd6936a63 100644 --- a/src/cohere/types/chat_tool_source.py +++ b/src/cohere/types/chat_tool_source.py @@ -13,7 +13,7 @@ class ChatToolSource(UncheckedBaseModel): The unique identifier of the document """ - tool_output: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None + tool_output: typing.Optional[typing.Dict[str, typing.Any]] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 diff --git a/src/cohere/types/dataset.py b/src/cohere/types/dataset.py index 51a4bbd46..ce400070c 100644 --- a/src/cohere/types/dataset.py +++ b/src/cohere/types/dataset.py @@ -41,13 +41,11 @@ class Dataset(UncheckedBaseModel): Errors found during validation """ - schema_: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="schema")] = pydantic.Field( - default=None - ) - """ - the avro schema of the dataset - """ - + schema_: typing_extensions.Annotated[ + typing.Optional[str], + FieldMetadata(alias="schema"), + pydantic.Field(alias="schema", description="the avro schema of the dataset"), + ] = None required_fields: typing.Optional[typing.List[str]] = None preserve_fields: typing.Optional[typing.List[str]] = None dataset_parts: typing.Optional[typing.List[DatasetPart]] = pydantic.Field(default=None) diff --git a/src/cohere/types/delete_connector_response.py b/src/cohere/types/delete_connector_response.py index 18e826cbf..e99205536 100644 --- a/src/cohere/types/delete_connector_response.py +++ b/src/cohere/types/delete_connector_response.py @@ -2,4 +2,4 @@ import typing -DeleteConnectorResponse = typing.Dict[str, typing.Optional[typing.Any]] +DeleteConnectorResponse = typing.Dict[str, typing.Any] diff --git a/src/cohere/types/document.py b/src/cohere/types/document.py index 40d79557f..a026c359d 100644 --- a/src/cohere/types/document.py +++ b/src/cohere/types/document.py @@ -14,7 +14,7 @@ class Document(UncheckedBaseModel): passed to the model. """ - data: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() + data: typing.Dict[str, typing.Any] = pydantic.Field() """ A relevant document that the model can cite to generate a more accurate reply. Each document is a string-any dictionary. """ diff --git a/src/cohere/types/embed_by_type_response.py b/src/cohere/types/embed_by_type_response.py index 408df9fb1..7c298540b 100644 --- a/src/cohere/types/embed_by_type_response.py +++ b/src/cohere/types/embed_by_type_response.py @@ -7,10 +7,12 @@ from ..core.unchecked_base_model import UncheckedBaseModel from .api_meta import ApiMeta from .embed_by_type_response_embeddings import EmbedByTypeResponseEmbeddings +from .embed_by_type_response_response_type import EmbedByTypeResponseResponseType from .image import Image class EmbedByTypeResponse(UncheckedBaseModel): + response_type: typing.Optional[EmbedByTypeResponseResponseType] = None id: str embeddings: EmbedByTypeResponseEmbeddings = pydantic.Field() """ diff --git a/src/cohere/types/embed_by_type_response_embeddings.py b/src/cohere/types/embed_by_type_response_embeddings.py index fd6e32749..dff789fd8 100644 --- a/src/cohere/types/embed_by_type_response_embeddings.py +++ b/src/cohere/types/embed_by_type_response_embeddings.py @@ -15,12 +15,10 @@ class EmbedByTypeResponseEmbeddings(UncheckedBaseModel): """ float_: typing_extensions.Annotated[ - typing.Optional[typing.List[typing.List[float]]], FieldMetadata(alias="float") - ] = pydantic.Field(default=None) - """ - An array of float embeddings. - """ - + typing.Optional[typing.List[typing.List[float]]], + FieldMetadata(alias="float"), + pydantic.Field(alias="float", description="An array of float embeddings."), + ] = None int8: typing.Optional[typing.List[typing.List[int]]] = pydantic.Field(default=None) """ An array of signed int8 embeddings. Each value is between -128 and 127. diff --git a/src/cohere/types/embed_by_type_response_response_type.py b/src/cohere/types/embed_by_type_response_response_type.py new file mode 100644 index 000000000..201b623aa --- /dev/null +++ b/src/cohere/types/embed_by_type_response_response_type.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +EmbedByTypeResponseResponseType = typing.Union[typing.Literal["embeddings_floats", "embeddings_by_type"], typing.Any] diff --git a/src/cohere/types/json_response_format.py b/src/cohere/types/json_response_format.py index 405fbe6d3..4b3527904 100644 --- a/src/cohere/types/json_response_format.py +++ b/src/cohere/types/json_response_format.py @@ -11,24 +11,13 @@ class JsonResponseFormat(UncheckedBaseModel): schema_: typing_extensions.Annotated[ - typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]], FieldMetadata(alias="schema") - ] = pydantic.Field(default=None) - """ - A JSON schema object that the output will adhere to. There are some restrictions we have on the schema, refer to [our guide](https://docs.cohere.com/docs/structured-outputs-json#schema-constraints) for more information. - Example (required name and age object): - ```json - { - "type": "object", - "properties": { - "name": {"type": "string"}, - "age": {"type": "integer"} - }, - "required": ["name", "age"] - } - ``` - - **Note**: This field must not be specified when the `type` is set to `"text"`. - """ + typing.Optional[typing.Dict[str, typing.Any]], + FieldMetadata(alias="schema"), + pydantic.Field( + alias="schema", + description='A JSON schema object that the output will adhere to. There are some restrictions we have on the schema, refer to [our guide](https://docs.cohere.com/docs/structured-outputs-json#schema-constraints) for more information.\nExample (required name and age object):\n```json\n{\n "type": "object",\n "properties": {\n "name": {"type": "string"},\n "age": {"type": "integer"}\n },\n "required": ["name", "age"]\n}\n```\n\n**Note**: This field must not be specified when the `type` is set to `"text"`.', + ), + ] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 diff --git a/src/cohere/types/json_response_format_v2.py b/src/cohere/types/json_response_format_v2.py index 4d3e214da..d7e64ed24 100644 --- a/src/cohere/types/json_response_format_v2.py +++ b/src/cohere/types/json_response_format_v2.py @@ -8,7 +8,7 @@ class JsonResponseFormatV2(UncheckedBaseModel): - json_schema: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) + json_schema: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None) """ A [JSON schema](https://json-schema.org/overview/what-is-jsonschema) object that the output will adhere to. There are some restrictions we have on the schema, refer to [our guide](https://docs.cohere.com/docs/structured-outputs-json#schema-constraints) for more information. Example (required name and age object): diff --git a/src/cohere/types/response_format.py b/src/cohere/types/response_format.py index 89b8e3e91..6f915268b 100644 --- a/src/cohere/types/response_format.py +++ b/src/cohere/types/response_format.py @@ -48,7 +48,7 @@ class JsonObjectResponseFormat(UncheckedBaseModel): type: typing.Literal["json_object"] = "json_object" schema_: typing_extensions.Annotated[ - typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]], FieldMetadata(alias="schema") + typing.Optional[typing.Dict[str, typing.Any]], FieldMetadata(alias="schema"), pydantic.Field(alias="schema") ] = None if IS_PYDANTIC_V2: diff --git a/src/cohere/types/response_format_v2.py b/src/cohere/types/response_format_v2.py index d2155a491..631935630 100644 --- a/src/cohere/types/response_format_v2.py +++ b/src/cohere/types/response_format_v2.py @@ -52,7 +52,7 @@ class JsonObjectResponseFormatV2(UncheckedBaseModel): """ type: typing.Literal["json_object"] = "json_object" - json_schema: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None + json_schema: typing.Optional[typing.Dict[str, typing.Any]] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 diff --git a/src/cohere/types/source.py b/src/cohere/types/source.py index c9602bfb7..1928498db 100644 --- a/src/cohere/types/source.py +++ b/src/cohere/types/source.py @@ -17,7 +17,7 @@ class ToolSource(UncheckedBaseModel): type: typing.Literal["tool"] = "tool" id: typing.Optional[str] = None - tool_output: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None + tool_output: typing.Optional[typing.Dict[str, typing.Any]] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 @@ -35,7 +35,7 @@ class DocumentSource(UncheckedBaseModel): type: typing.Literal["document"] = "document" id: typing.Optional[str] = None - document: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None + document: typing.Optional[typing.Dict[str, typing.Any]] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 diff --git a/src/cohere/types/system_message_v2content.py b/src/cohere/types/system_message_v2content.py index f190a7e1f..57ac2ecdd 100644 --- a/src/cohere/types/system_message_v2content.py +++ b/src/cohere/types/system_message_v2content.py @@ -2,6 +2,6 @@ import typing -from .system_message_v2content_item import SystemMessageV2ContentItem +from .system_message_v2content_one_item import SystemMessageV2ContentOneItem -SystemMessageV2Content = typing.Union[str, typing.List[SystemMessageV2ContentItem]] +SystemMessageV2Content = typing.Union[str, typing.List[SystemMessageV2ContentOneItem]] diff --git a/src/cohere/types/system_message_v2content_item.py b/src/cohere/types/system_message_v2content_one_item.py similarity index 81% rename from src/cohere/types/system_message_v2content_item.py rename to src/cohere/types/system_message_v2content_one_item.py index 8bde22dc3..b014d15de 100644 --- a/src/cohere/types/system_message_v2content_item.py +++ b/src/cohere/types/system_message_v2content_one_item.py @@ -9,7 +9,7 @@ from ..core.unchecked_base_model import UncheckedBaseModel -class TextSystemMessageV2ContentItem(UncheckedBaseModel): +class TextSystemMessageV2ContentOneItem(UncheckedBaseModel): type: typing.Literal["text"] = "text" text: str @@ -22,4 +22,4 @@ class Config: extra = pydantic.Extra.allow -SystemMessageV2ContentItem = TextSystemMessageV2ContentItem +SystemMessageV2ContentOneItem = TextSystemMessageV2ContentOneItem diff --git a/src/cohere/types/tool_call.py b/src/cohere/types/tool_call.py index f8591b214..2f6f9038a 100644 --- a/src/cohere/types/tool_call.py +++ b/src/cohere/types/tool_call.py @@ -17,7 +17,7 @@ class ToolCall(UncheckedBaseModel): Name of the tool to call. """ - parameters: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() + parameters: typing.Dict[str, typing.Any] = pydantic.Field() """ The name and value of the parameters to use when invoking a tool. """ diff --git a/src/cohere/types/tool_result.py b/src/cohere/types/tool_result.py index b02c8e6b2..69a37c335 100644 --- a/src/cohere/types/tool_result.py +++ b/src/cohere/types/tool_result.py @@ -10,7 +10,7 @@ class ToolResult(UncheckedBaseModel): call: ToolCall - outputs: typing.List[typing.Dict[str, typing.Optional[typing.Any]]] + outputs: typing.List[typing.Dict[str, typing.Any]] if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 diff --git a/src/cohere/types/tool_v2function.py b/src/cohere/types/tool_v2function.py index 3c37e51bc..964dbba1c 100644 --- a/src/cohere/types/tool_v2function.py +++ b/src/cohere/types/tool_v2function.py @@ -22,7 +22,7 @@ class ToolV2Function(UncheckedBaseModel): The description of the function. """ - parameters: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() + parameters: typing.Dict[str, typing.Any] = pydantic.Field() """ The parameters of the function as a JSON schema. """ diff --git a/src/cohere/v2/raw_client.py b/src/cohere/v2/raw_client.py index e5cd6b435..28610db5b 100644 --- a/src/cohere/v2/raw_client.py +++ b/src/cohere/v2/raw_client.py @@ -9,6 +9,7 @@ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.http_response import AsyncHttpResponse, HttpResponse from ..core.http_sse._api import EventSource +from ..core.pydantic_utilities import parse_sse_obj from ..core.request_options import RequestOptions from ..core.serialization import convert_and_respect_annotation_metadata from ..core.unchecked_base_model import construct_type @@ -236,9 +237,9 @@ def _iter(): try: yield typing.cast( V2ChatStreamResponse, - construct_type( + parse_sse_obj( + sse=_sse, type_=V2ChatStreamResponse, # type: ignore - object_=_sse.json(), ), ) except JSONDecodeError as e: @@ -259,9 +260,9 @@ def _iter(): raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -270,9 +271,9 @@ def _iter(): raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -281,9 +282,9 @@ def _iter(): raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -292,9 +293,9 @@ def _iter(): raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -303,9 +304,9 @@ def _iter(): raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -314,9 +315,9 @@ def _iter(): raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -325,9 +326,9 @@ def _iter(): raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -336,9 +337,9 @@ def _iter(): raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -347,9 +348,9 @@ def _iter(): raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -358,9 +359,9 @@ def _iter(): raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -369,9 +370,9 @@ def _iter(): raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -380,9 +381,9 @@ def _iter(): raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -580,9 +581,9 @@ def chat( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -591,9 +592,9 @@ def chat( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -602,9 +603,9 @@ def chat( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -613,9 +614,9 @@ def chat( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -624,9 +625,9 @@ def chat( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -635,9 +636,9 @@ def chat( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -646,9 +647,9 @@ def chat( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -657,9 +658,9 @@ def chat( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -668,9 +669,9 @@ def chat( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -679,9 +680,9 @@ def chat( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -690,9 +691,9 @@ def chat( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -701,9 +702,9 @@ def chat( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -827,9 +828,9 @@ def embed( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -838,9 +839,9 @@ def embed( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -849,9 +850,9 @@ def embed( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -860,9 +861,9 @@ def embed( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -871,9 +872,9 @@ def embed( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -882,9 +883,9 @@ def embed( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -893,9 +894,9 @@ def embed( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -904,9 +905,9 @@ def embed( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -915,9 +916,9 @@ def embed( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -926,9 +927,9 @@ def embed( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -937,9 +938,9 @@ def embed( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -948,9 +949,9 @@ def embed( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1038,9 +1039,9 @@ def rerank( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1049,9 +1050,9 @@ def rerank( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1060,9 +1061,9 @@ def rerank( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1071,9 +1072,9 @@ def rerank( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1082,9 +1083,9 @@ def rerank( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1093,9 +1094,9 @@ def rerank( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1104,9 +1105,9 @@ def rerank( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1115,9 +1116,9 @@ def rerank( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1126,9 +1127,9 @@ def rerank( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1137,9 +1138,9 @@ def rerank( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1148,9 +1149,9 @@ def rerank( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1159,9 +1160,9 @@ def rerank( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1360,9 +1361,9 @@ async def _iter(): try: yield typing.cast( V2ChatStreamResponse, - construct_type( + parse_sse_obj( + sse=_sse, type_=V2ChatStreamResponse, # type: ignore - object_=_sse.json(), ), ) except JSONDecodeError as e: @@ -1383,9 +1384,9 @@ async def _iter(): raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1394,9 +1395,9 @@ async def _iter(): raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1405,9 +1406,9 @@ async def _iter(): raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1416,9 +1417,9 @@ async def _iter(): raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1427,9 +1428,9 @@ async def _iter(): raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1438,9 +1439,9 @@ async def _iter(): raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1449,9 +1450,9 @@ async def _iter(): raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1460,9 +1461,9 @@ async def _iter(): raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1471,9 +1472,9 @@ async def _iter(): raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1482,9 +1483,9 @@ async def _iter(): raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1493,9 +1494,9 @@ async def _iter(): raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1504,9 +1505,9 @@ async def _iter(): raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1704,9 +1705,9 @@ async def chat( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1715,9 +1716,9 @@ async def chat( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1726,9 +1727,9 @@ async def chat( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1737,9 +1738,9 @@ async def chat( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1748,9 +1749,9 @@ async def chat( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1759,9 +1760,9 @@ async def chat( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1770,9 +1771,9 @@ async def chat( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1781,9 +1782,9 @@ async def chat( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1792,9 +1793,9 @@ async def chat( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1803,9 +1804,9 @@ async def chat( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1814,9 +1815,9 @@ async def chat( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1825,9 +1826,9 @@ async def chat( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1951,9 +1952,9 @@ async def embed( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1962,9 +1963,9 @@ async def embed( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1973,9 +1974,9 @@ async def embed( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1984,9 +1985,9 @@ async def embed( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -1995,9 +1996,9 @@ async def embed( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2006,9 +2007,9 @@ async def embed( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2017,9 +2018,9 @@ async def embed( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2028,9 +2029,9 @@ async def embed( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2039,9 +2040,9 @@ async def embed( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2050,9 +2051,9 @@ async def embed( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2061,9 +2062,9 @@ async def embed( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2072,9 +2073,9 @@ async def embed( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2162,9 +2163,9 @@ async def rerank( raise BadRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2173,9 +2174,9 @@ async def rerank( raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2184,9 +2185,9 @@ async def rerank( raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2195,9 +2196,9 @@ async def rerank( raise NotFoundError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2206,9 +2207,9 @@ async def rerank( raise UnprocessableEntityError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2217,9 +2218,9 @@ async def rerank( raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2228,9 +2229,9 @@ async def rerank( raise InvalidTokenError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2239,9 +2240,9 @@ async def rerank( raise ClientClosedRequestError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2250,9 +2251,9 @@ async def rerank( raise InternalServerError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2261,9 +2262,9 @@ async def rerank( raise NotImplementedError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2272,9 +2273,9 @@ async def rerank( raise ServiceUnavailableError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ), @@ -2283,9 +2284,9 @@ async def rerank( raise GatewayTimeoutError( headers=dict(_response.headers), body=typing.cast( - typing.Optional[typing.Any], + typing.Any, construct_type( - type_=typing.Optional[typing.Any], # type: ignore + type_=typing.Any, # type: ignore object_=_response.json(), ), ),