From f7c268f08634071dbf5c85d2de749a7c57b625c9 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 15:38:15 -0500 Subject: [PATCH] SDK regeneration (#530) Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com> --- poetry.lock | 282 +++--- pyproject.toml | 7 +- src/cohere/__init__.py | 16 + src/cohere/base_client.py | 812 ++++++++++++++++++ src/cohere/connectors/client.py | 338 ++++++++ src/cohere/core/client_wrapper.py | 2 +- src/cohere/core/http_client.py | 6 +- src/cohere/core/unchecked_base_model.py | 38 +- src/cohere/datasets/client.py | 414 +++++++++ src/cohere/embed_jobs/client.py | 251 ++++++ src/cohere/errors/__init__.py | 8 + .../errors/client_closed_request_error.py | 9 + src/cohere/errors/gateway_timeout_error.py | 9 + src/cohere/errors/not_implemented_error.py | 9 + .../errors/service_unavailable_error.py | 5 +- src/cohere/errors/unauthorized_error.py | 5 +- .../errors/unprocessable_entity_error.py | 9 + src/cohere/finetuning/__init__.py | 2 - src/cohere/finetuning/client.py | 57 +- src/cohere/finetuning/finetuning/__init__.py | 2 - .../finetuning/finetuning/types/__init__.py | 2 - src/cohere/models/client.py | 156 ++++ src/cohere/types/__init__.py | 8 + .../client_closed_request_error_body.py} | 17 +- .../types/gateway_timeout_error_body.py | 30 + .../types/not_implemented_error_body.py | 30 + src/cohere/types/tool_call_delta.py | 5 + .../types/unprocessable_entity_error_body.py | 30 + 28 files changed, 2331 insertions(+), 228 deletions(-) create mode 100644 src/cohere/errors/client_closed_request_error.py create mode 100644 src/cohere/errors/gateway_timeout_error.py create mode 100644 src/cohere/errors/not_implemented_error.py create mode 100644 src/cohere/errors/unprocessable_entity_error.py rename src/cohere/{finetuning/finetuning/types/error.py => types/client_closed_request_error_body.py} (68%) create mode 100644 src/cohere/types/gateway_timeout_error_body.py create mode 100644 src/cohere/types/not_implemented_error_body.py create mode 100644 src/cohere/types/unprocessable_entity_error_body.py diff --git a/poetry.lock b/poetry.lock index 6c250ddd7..bd319db61 100644 --- a/poetry.lock +++ b/poetry.lock @@ -38,17 +38,17 @@ trio = ["trio (>=0.23)"] [[package]] name = "boto3" -version = "1.34.121" +version = "1.34.128" description = "The AWS SDK for Python" optional = false python-versions = ">=3.8" files = [ - {file = "boto3-1.34.121-py3-none-any.whl", hash = "sha256:4e79e400d6d44b4eee5deda6ac0ecd08a3f5a30c45a0d30712795cdc4459fd79"}, - {file = "boto3-1.34.121.tar.gz", hash = "sha256:ec89f3e0b0dc959c418df29e14d3748c0b05ab7acf7c0b90c839e9f340a659fa"}, + {file = "boto3-1.34.128-py3-none-any.whl", hash = "sha256:a048ff980a81cd652724a73bc496c519b336fabe19cc8bfc6c53b2ff6eb22c7b"}, + {file = "boto3-1.34.128.tar.gz", hash = "sha256:43a6e99f53a8d34b3b4dbe424dbcc6b894350dc41a85b0af7c7bc24a7ec2cead"}, ] [package.dependencies] -botocore = ">=1.34.121,<1.35.0" +botocore = ">=1.34.128,<1.35.0" jmespath = ">=0.7.1,<2.0.0" s3transfer = ">=0.10.0,<0.11.0" @@ -57,13 +57,13 @@ crt = ["botocore[crt] (>=1.21.0,<2.0a0)"] [[package]] name = "botocore" -version = "1.34.121" +version = "1.34.128" description = "Low-level, data-driven core of boto 3." optional = false python-versions = ">=3.8" files = [ - {file = "botocore-1.34.121-py3-none-any.whl", hash = "sha256:25b05c7646a9f240cde1c8f839552a43f27e71e15c42600275dea93e219f7dd9"}, - {file = "botocore-1.34.121.tar.gz", hash = "sha256:1a8f94b917c47dfd84a0b531ab607dc53570efb0d073d8686600f2d2be985323"}, + {file = "botocore-1.34.128-py3-none-any.whl", hash = "sha256:db67fda136c372ab3fa432580c819c89ba18d28a6152a4d2a7ea40d44082892e"}, + {file = "botocore-1.34.128.tar.gz", hash = "sha256:8d8e03f7c8c080ecafda72036eb3b482d649f8417c90b5dca33b7c2c47adb0c9"}, ] [package.dependencies] @@ -260,18 +260,18 @@ zstandard = ["zstandard"] [[package]] name = "filelock" -version = "3.14.0" +version = "3.15.1" description = "A platform independent file lock." optional = false python-versions = ">=3.8" files = [ - {file = "filelock-3.14.0-py3-none-any.whl", hash = "sha256:43339835842f110ca7ae60f1e1c160714c5a6afd15a2873419ab185334975c0f"}, - {file = "filelock-3.14.0.tar.gz", hash = "sha256:6ea72da3be9b8c82afd3edcf99f2fffbb5076335a5ae4d03248bb5b6c3eae78a"}, + {file = "filelock-3.15.1-py3-none-any.whl", hash = "sha256:71b3102950e91dfc1bb4209b64be4dc8854f40e5f534428d8684f953ac847fac"}, + {file = "filelock-3.15.1.tar.gz", hash = "sha256:58a2549afdf9e02e10720eaa4d4470f56386d7a6f72edd7d0596337af8ed7ad8"}, ] [package.extras] docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] -testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8.0.1)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8.0.1)", "pytest (>=7.4.3)", "pytest-asyncio (>=0.21)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"] typing = ["typing-extensions (>=4.8)"] [[package]] @@ -382,13 +382,13 @@ files = [ [[package]] name = "huggingface-hub" -version = "0.23.3" +version = "0.23.4" description = "Client library to download and publish models, datasets and other repos on the huggingface.co hub" optional = false python-versions = ">=3.8.0" files = [ - {file = "huggingface_hub-0.23.3-py3-none-any.whl", hash = "sha256:22222c41223f1b7c209ae5511d2d82907325a0e3cdbce5f66949d43c598ff3bc"}, - {file = "huggingface_hub-0.23.3.tar.gz", hash = "sha256:1a1118a0b3dea3bab6c325d71be16f5ffe441d32f3ac7c348d6875911b694b5b"}, + {file = "huggingface_hub-0.23.4-py3-none-any.whl", hash = "sha256:3a0b957aa87150addf0cc7bd71b4d954b78e749850e1e7fb29ebbd2db64ca037"}, + {file = "huggingface_hub-0.23.4.tar.gz", hash = "sha256:35d99016433900e44ae7efe1c209164a5a81dbbcd53a52f99c281dcd7ce22431"}, ] [package.dependencies] @@ -506,13 +506,13 @@ files = [ [[package]] name = "packaging" -version = "24.0" +version = "24.1" description = "Core utilities for Python packages" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "packaging-24.0-py3-none-any.whl", hash = "sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5"}, - {file = "packaging-24.0.tar.gz", hash = "sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9"}, + {file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"}, + {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, ] [[package]] @@ -546,13 +546,13 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "pydantic" -version = "2.7.3" +version = "2.7.4" description = "Data validation using Python type hints" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic-2.7.3-py3-none-any.whl", hash = "sha256:ea91b002777bf643bb20dd717c028ec43216b24a6001a280f83877fd2655d0b4"}, - {file = "pydantic-2.7.3.tar.gz", hash = "sha256:c46c76a40bb1296728d7a8b99aa73dd70a48c3510111ff290034f860c99c419e"}, + {file = "pydantic-2.7.4-py3-none-any.whl", hash = "sha256:ee8538d41ccb9c0a9ad3e0e5f07bf15ed8015b481ced539a1759d8cc89ae90d0"}, + {file = "pydantic-2.7.4.tar.gz", hash = "sha256:0c84efd9548d545f63ac0060c1e4d39bb9b14db8b3c0652338aecc07b5adec52"}, ] [package.dependencies] @@ -830,130 +830,120 @@ files = [ [[package]] name = "tokenizers" -version = "0.15.2" +version = "0.19.1" description = "" optional = false python-versions = ">=3.7" files = [ - {file = "tokenizers-0.15.2-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:52f6130c9cbf70544287575a985bf44ae1bda2da7e8c24e97716080593638012"}, - {file = "tokenizers-0.15.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:054c1cc9c6d68f7ffa4e810b3d5131e0ba511b6e4be34157aa08ee54c2f8d9ee"}, - {file = "tokenizers-0.15.2-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:a9b9b070fdad06e347563b88c278995735292ded1132f8657084989a4c84a6d5"}, - {file = "tokenizers-0.15.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ea621a7eef4b70e1f7a4e84dd989ae3f0eeb50fc8690254eacc08acb623e82f1"}, - {file = "tokenizers-0.15.2-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:cf7fd9a5141634fa3aa8d6b7be362e6ae1b4cda60da81388fa533e0b552c98fd"}, - {file = "tokenizers-0.15.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:44f2a832cd0825295f7179eaf173381dc45230f9227ec4b44378322d900447c9"}, - {file = "tokenizers-0.15.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8b9ec69247a23747669ec4b0ca10f8e3dfb3545d550258129bd62291aabe8605"}, - {file = "tokenizers-0.15.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:40b6a4c78da863ff26dbd5ad9a8ecc33d8a8d97b535172601cf00aee9d7ce9ce"}, - {file = "tokenizers-0.15.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:5ab2a4d21dcf76af60e05af8063138849eb1d6553a0d059f6534357bce8ba364"}, - {file = "tokenizers-0.15.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:a47acfac7e511f6bbfcf2d3fb8c26979c780a91e06fb5b9a43831b2c0153d024"}, - {file = "tokenizers-0.15.2-cp310-none-win32.whl", hash = "sha256:064ff87bb6acdbd693666de9a4b692add41308a2c0ec0770d6385737117215f2"}, - {file = "tokenizers-0.15.2-cp310-none-win_amd64.whl", hash = "sha256:3b919afe4df7eb6ac7cafd2bd14fb507d3f408db7a68c43117f579c984a73843"}, - {file = "tokenizers-0.15.2-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:89cd1cb93e4b12ff39bb2d626ad77e35209de9309a71e4d3d4672667b4b256e7"}, - {file = "tokenizers-0.15.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:cfed5c64e5be23d7ee0f0e98081a25c2a46b0b77ce99a4f0605b1ec43dd481fa"}, - {file = "tokenizers-0.15.2-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:a907d76dcfda37023ba203ab4ceeb21bc5683436ebefbd895a0841fd52f6f6f2"}, - {file = "tokenizers-0.15.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:20ea60479de6fc7b8ae756b4b097572372d7e4032e2521c1bbf3d90c90a99ff0"}, - {file = "tokenizers-0.15.2-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:48e2b9335be2bc0171df9281385c2ed06a15f5cf121c44094338306ab7b33f2c"}, - {file = "tokenizers-0.15.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:112a1dd436d2cc06e6ffdc0b06d55ac019a35a63afd26475205cb4b1bf0bfbff"}, - {file = "tokenizers-0.15.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4620cca5c2817177ee8706f860364cc3a8845bc1e291aaf661fb899e5d1c45b0"}, - {file = "tokenizers-0.15.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ccd73a82751c523b3fc31ff8194702e4af4db21dc20e55b30ecc2079c5d43cb7"}, - {file = "tokenizers-0.15.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:107089f135b4ae7817affe6264f8c7a5c5b4fd9a90f9439ed495f54fcea56fb4"}, - {file = "tokenizers-0.15.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:0ff110ecc57b7aa4a594396525a3451ad70988e517237fe91c540997c4e50e29"}, - {file = "tokenizers-0.15.2-cp311-none-win32.whl", hash = "sha256:6d76f00f5c32da36c61f41c58346a4fa7f0a61be02f4301fd30ad59834977cc3"}, - {file = "tokenizers-0.15.2-cp311-none-win_amd64.whl", hash = "sha256:cc90102ed17271cf0a1262babe5939e0134b3890345d11a19c3145184b706055"}, - {file = "tokenizers-0.15.2-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:f86593c18d2e6248e72fb91c77d413a815153b8ea4e31f7cd443bdf28e467670"}, - {file = "tokenizers-0.15.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0774bccc6608eca23eb9d620196687c8b2360624619623cf4ba9dc9bd53e8b51"}, - {file = "tokenizers-0.15.2-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:d0222c5b7c9b26c0b4822a82f6a7011de0a9d3060e1da176f66274b70f846b98"}, - {file = "tokenizers-0.15.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3835738be1de66624fff2f4f6f6684775da4e9c00bde053be7564cbf3545cc66"}, - {file = "tokenizers-0.15.2-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:0143e7d9dcd811855c1ce1ab9bf5d96d29bf5e528fd6c7824d0465741e8c10fd"}, - {file = "tokenizers-0.15.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:db35825f6d54215f6b6009a7ff3eedee0848c99a6271c870d2826fbbedf31a38"}, - {file = "tokenizers-0.15.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3f5e64b0389a2be47091d8cc53c87859783b837ea1a06edd9d8e04004df55a5c"}, - {file = "tokenizers-0.15.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9e0480c452217edd35eca56fafe2029fb4d368b7c0475f8dfa3c5c9c400a7456"}, - {file = "tokenizers-0.15.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:a33ab881c8fe70474980577e033d0bc9a27b7ab8272896e500708b212995d834"}, - {file = "tokenizers-0.15.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:a308a607ca9de2c64c1b9ba79ec9a403969715a1b8ba5f998a676826f1a7039d"}, - {file = "tokenizers-0.15.2-cp312-none-win32.whl", hash = "sha256:b8fcfa81bcb9447df582c5bc96a031e6df4da2a774b8080d4f02c0c16b42be0b"}, - {file = "tokenizers-0.15.2-cp312-none-win_amd64.whl", hash = "sha256:38d7ab43c6825abfc0b661d95f39c7f8af2449364f01d331f3b51c94dcff7221"}, - {file = "tokenizers-0.15.2-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:38bfb0204ff3246ca4d5e726e8cc8403bfc931090151e6eede54d0e0cf162ef0"}, - {file = "tokenizers-0.15.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:9c861d35e8286a53e06e9e28d030b5a05bcbf5ac9d7229e561e53c352a85b1fc"}, - {file = "tokenizers-0.15.2-cp313-cp313-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:936bf3842db5b2048eaa53dade907b1160f318e7c90c74bfab86f1e47720bdd6"}, - {file = "tokenizers-0.15.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:620beacc3373277700d0e27718aa8b25f7b383eb8001fba94ee00aeea1459d89"}, - {file = "tokenizers-0.15.2-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:2735ecbbf37e52db4ea970e539fd2d450d213517b77745114f92867f3fc246eb"}, - {file = "tokenizers-0.15.2-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:473c83c5e2359bb81b0b6fde870b41b2764fcdd36d997485e07e72cc3a62264a"}, - {file = "tokenizers-0.15.2-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:968fa1fb3c27398b28a4eca1cbd1e19355c4d3a6007f7398d48826bbe3a0f728"}, - {file = "tokenizers-0.15.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:865c60ae6eaebdde7da66191ee9b7db52e542ed8ee9d2c653b6d190a9351b980"}, - {file = "tokenizers-0.15.2-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:7c0d8b52664ab2d4a8d6686eb5effc68b78608a9008f086a122a7b2996befbab"}, - {file = "tokenizers-0.15.2-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:f33dfbdec3784093a9aebb3680d1f91336c56d86cc70ddf88708251da1fe9064"}, - {file = "tokenizers-0.15.2-cp37-cp37m-macosx_10_12_x86_64.whl", hash = "sha256:d44ba80988ff9424e33e0a49445072ac7029d8c0e1601ad25a0ca5f41ed0c1d6"}, - {file = "tokenizers-0.15.2-cp37-cp37m-macosx_11_0_arm64.whl", hash = "sha256:dce74266919b892f82b1b86025a613956ea0ea62a4843d4c4237be2c5498ed3a"}, - {file = "tokenizers-0.15.2-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:0ef06b9707baeb98b316577acb04f4852239d856b93e9ec3a299622f6084e4be"}, - {file = "tokenizers-0.15.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c73e2e74bbb07910da0d37c326869f34113137b23eadad3fc00856e6b3d9930c"}, - {file = "tokenizers-0.15.2-cp37-cp37m-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4eeb12daf02a59e29f578a865f55d87cd103ce62bd8a3a5874f8fdeaa82e336b"}, - {file = "tokenizers-0.15.2-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9ba9f6895af58487ca4f54e8a664a322f16c26bbb442effd01087eba391a719e"}, - {file = "tokenizers-0.15.2-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ccec77aa7150e38eec6878a493bf8c263ff1fa8a62404e16c6203c64c1f16a26"}, - {file = "tokenizers-0.15.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f3f40604f5042ff210ba82743dda2b6aa3e55aa12df4e9f2378ee01a17e2855e"}, - {file = "tokenizers-0.15.2-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:5645938a42d78c4885086767c70923abad047163d809c16da75d6b290cb30bbe"}, - {file = "tokenizers-0.15.2-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:05a77cbfebe28a61ab5c3891f9939cc24798b63fa236d84e5f29f3a85a200c00"}, - {file = "tokenizers-0.15.2-cp37-none-win32.whl", hash = "sha256:361abdc068e8afe9c5b818769a48624687fb6aaed49636ee39bec4e95e1a215b"}, - {file = "tokenizers-0.15.2-cp37-none-win_amd64.whl", hash = "sha256:7ef789f83eb0f9baeb4d09a86cd639c0a5518528f9992f38b28e819df397eb06"}, - {file = "tokenizers-0.15.2-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:4fe1f74a902bee74a3b25aff180fbfbf4f8b444ab37c4d496af7afd13a784ed2"}, - {file = "tokenizers-0.15.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:4c4b89038a684f40a6b15d6b09f49650ac64d951ad0f2a3ea9169687bbf2a8ba"}, - {file = "tokenizers-0.15.2-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:d05a1b06f986d41aed5f2de464c003004b2df8aaf66f2b7628254bcbfb72a438"}, - {file = "tokenizers-0.15.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:508711a108684111ec8af89d3a9e9e08755247eda27d0ba5e3c50e9da1600f6d"}, - {file = "tokenizers-0.15.2-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:daa348f02d15160cb35439098ac96e3a53bacf35885072611cd9e5be7d333daa"}, - {file = "tokenizers-0.15.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:494fdbe5932d3416de2a85fc2470b797e6f3226c12845cadf054dd906afd0442"}, - {file = "tokenizers-0.15.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c2d60f5246f4da9373f75ff18d64c69cbf60c3bca597290cea01059c336d2470"}, - {file = "tokenizers-0.15.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:93268e788825f52de4c7bdcb6ebc1fcd4a5442c02e730faa9b6b08f23ead0e24"}, - {file = "tokenizers-0.15.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:6fc7083ab404019fc9acafe78662c192673c1e696bd598d16dc005bd663a5cf9"}, - {file = "tokenizers-0.15.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:41e39b41e5531d6b2122a77532dbea60e171ef87a3820b5a3888daa847df4153"}, - {file = "tokenizers-0.15.2-cp38-none-win32.whl", hash = "sha256:06cd0487b1cbfabefb2cc52fbd6b1f8d4c37799bd6c6e1641281adaa6b2504a7"}, - {file = "tokenizers-0.15.2-cp38-none-win_amd64.whl", hash = "sha256:5179c271aa5de9c71712e31cb5a79e436ecd0d7532a408fa42a8dbfa4bc23fd9"}, - {file = "tokenizers-0.15.2-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:82f8652a74cc107052328b87ea8b34291c0f55b96d8fb261b3880216a9f9e48e"}, - {file = "tokenizers-0.15.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:02458bee6f5f3139f1ebbb6d042b283af712c0981f5bc50edf771d6b762d5e4f"}, - {file = "tokenizers-0.15.2-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:c9a09cd26cca2e1c349f91aa665309ddb48d71636370749414fbf67bc83c5343"}, - {file = "tokenizers-0.15.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:158be8ea8554e5ed69acc1ce3fbb23a06060bd4bbb09029431ad6b9a466a7121"}, - {file = "tokenizers-0.15.2-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:1ddba9a2b0c8c81633eca0bb2e1aa5b3a15362b1277f1ae64176d0f6eba78ab1"}, - {file = "tokenizers-0.15.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3ef5dd1d39797044642dbe53eb2bc56435308432e9c7907728da74c69ee2adca"}, - {file = "tokenizers-0.15.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:454c203164e07a860dbeb3b1f4a733be52b0edbb4dd2e5bd75023ffa8b49403a"}, - {file = "tokenizers-0.15.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0cf6b7f1d4dc59af960e6ffdc4faffe6460bbfa8dce27a58bf75755ffdb2526d"}, - {file = "tokenizers-0.15.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:2ef09bbc16519f6c25d0c7fc0c6a33a6f62923e263c9d7cca4e58b8c61572afb"}, - {file = "tokenizers-0.15.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:c9a2ebdd2ad4ec7a68e7615086e633857c85e2f18025bd05d2a4399e6c5f7169"}, - {file = "tokenizers-0.15.2-cp39-none-win32.whl", hash = "sha256:918fbb0eab96fe08e72a8c2b5461e9cce95585d82a58688e7f01c2bd546c79d0"}, - {file = "tokenizers-0.15.2-cp39-none-win_amd64.whl", hash = "sha256:524e60da0135e106b254bd71f0659be9f89d83f006ea9093ce4d1fab498c6d0d"}, - {file = "tokenizers-0.15.2-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:6a9b648a58281c4672212fab04e60648fde574877d0139cd4b4f93fe28ca8944"}, - {file = "tokenizers-0.15.2-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:7c7d18b733be6bbca8a55084027f7be428c947ddf871c500ee603e375013ffba"}, - {file = "tokenizers-0.15.2-pp310-pypy310_pp73-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:13ca3611de8d9ddfbc4dc39ef54ab1d2d4aaa114ac8727dfdc6a6ec4be017378"}, - {file = "tokenizers-0.15.2-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:237d1bf3361cf2e6463e6c140628e6406766e8b27274f5fcc62c747ae3c6f094"}, - {file = "tokenizers-0.15.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:67a0fe1e49e60c664915e9fb6b0cb19bac082ab1f309188230e4b2920230edb3"}, - {file = "tokenizers-0.15.2-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:4e022fe65e99230b8fd89ebdfea138c24421f91c1a4f4781a8f5016fd5cdfb4d"}, - {file = "tokenizers-0.15.2-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:d857be2df69763362ac699f8b251a8cd3fac9d21893de129bc788f8baaef2693"}, - {file = "tokenizers-0.15.2-pp37-pypy37_pp73-macosx_10_12_x86_64.whl", hash = "sha256:708bb3e4283177236309e698da5fcd0879ce8fd37457d7c266d16b550bcbbd18"}, - {file = "tokenizers-0.15.2-pp37-pypy37_pp73-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:64c35e09e9899b72a76e762f9854e8750213f67567787d45f37ce06daf57ca78"}, - {file = "tokenizers-0.15.2-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c1257f4394be0d3b00de8c9e840ca5601d0a4a8438361ce9c2b05c7d25f6057b"}, - {file = "tokenizers-0.15.2-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:02272fe48280e0293a04245ca5d919b2c94a48b408b55e858feae9618138aeda"}, - {file = "tokenizers-0.15.2-pp37-pypy37_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:dc3ad9ebc76eabe8b1d7c04d38be884b8f9d60c0cdc09b0aa4e3bcf746de0388"}, - {file = "tokenizers-0.15.2-pp37-pypy37_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:32e16bdeffa7c4f46bf2152172ca511808b952701d13e7c18833c0b73cb5c23f"}, - {file = "tokenizers-0.15.2-pp38-pypy38_pp73-macosx_10_12_x86_64.whl", hash = "sha256:fb16ba563d59003028b678d2361a27f7e4ae0ab29c7a80690efa20d829c81fdb"}, - {file = "tokenizers-0.15.2-pp38-pypy38_pp73-macosx_11_0_arm64.whl", hash = "sha256:2277c36d2d6cdb7876c274547921a42425b6810d38354327dd65a8009acf870c"}, - {file = "tokenizers-0.15.2-pp38-pypy38_pp73-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:1cf75d32e8d250781940d07f7eece253f2fe9ecdb1dc7ba6e3833fa17b82fcbc"}, - {file = "tokenizers-0.15.2-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f1b3b31884dc8e9b21508bb76da80ebf7308fdb947a17affce815665d5c4d028"}, - {file = "tokenizers-0.15.2-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b10122d8d8e30afb43bb1fe21a3619f62c3e2574bff2699cf8af8b0b6c5dc4a3"}, - {file = "tokenizers-0.15.2-pp38-pypy38_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:d88b96ff0fe8e91f6ef01ba50b0d71db5017fa4e3b1d99681cec89a85faf7bf7"}, - {file = "tokenizers-0.15.2-pp38-pypy38_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:37aaec5a52e959892870a7c47cef80c53797c0db9149d458460f4f31e2fb250e"}, - {file = "tokenizers-0.15.2-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:e2ea752f2b0fe96eb6e2f3adbbf4d72aaa1272079b0dfa1145507bd6a5d537e6"}, - {file = "tokenizers-0.15.2-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:4b19a808d8799fda23504a5cd31d2f58e6f52f140380082b352f877017d6342b"}, - {file = "tokenizers-0.15.2-pp39-pypy39_pp73-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:64c86e5e068ac8b19204419ed8ca90f9d25db20578f5881e337d203b314f4104"}, - {file = "tokenizers-0.15.2-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:de19c4dc503c612847edf833c82e9f73cd79926a384af9d801dcf93f110cea4e"}, - {file = "tokenizers-0.15.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ea09acd2fe3324174063d61ad620dec3bcf042b495515f27f638270a7d466e8b"}, - {file = "tokenizers-0.15.2-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:cf27fd43472e07b57cf420eee1e814549203d56de00b5af8659cb99885472f1f"}, - {file = "tokenizers-0.15.2-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:7ca22bd897537a0080521445d91a58886c8c04084a6a19e6c78c586e0cfa92a5"}, - {file = "tokenizers-0.15.2.tar.gz", hash = "sha256:e6e9c6e019dd5484be5beafc775ae6c925f4c69a3487040ed09b45e13df2cb91"}, + {file = "tokenizers-0.19.1-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:952078130b3d101e05ecfc7fc3640282d74ed26bcf691400f872563fca15ac97"}, + {file = "tokenizers-0.19.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:82c8b8063de6c0468f08e82c4e198763e7b97aabfe573fd4cf7b33930ca4df77"}, + {file = "tokenizers-0.19.1-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:f03727225feaf340ceeb7e00604825addef622d551cbd46b7b775ac834c1e1c4"}, + {file = "tokenizers-0.19.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:453e4422efdfc9c6b6bf2eae00d5e323f263fff62b29a8c9cd526c5003f3f642"}, + {file = "tokenizers-0.19.1-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:02e81bf089ebf0e7f4df34fa0207519f07e66d8491d963618252f2e0729e0b46"}, + {file = "tokenizers-0.19.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b07c538ba956843833fee1190cf769c60dc62e1cf934ed50d77d5502194d63b1"}, + {file = "tokenizers-0.19.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e28cab1582e0eec38b1f38c1c1fb2e56bce5dc180acb1724574fc5f47da2a4fe"}, + {file = "tokenizers-0.19.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8b01afb7193d47439f091cd8f070a1ced347ad0f9144952a30a41836902fe09e"}, + {file = "tokenizers-0.19.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:7fb297edec6c6841ab2e4e8f357209519188e4a59b557ea4fafcf4691d1b4c98"}, + {file = "tokenizers-0.19.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:2e8a3dd055e515df7054378dc9d6fa8c8c34e1f32777fb9a01fea81496b3f9d3"}, + {file = "tokenizers-0.19.1-cp310-none-win32.whl", hash = "sha256:7ff898780a155ea053f5d934925f3902be2ed1f4d916461e1a93019cc7250837"}, + {file = "tokenizers-0.19.1-cp310-none-win_amd64.whl", hash = "sha256:bea6f9947e9419c2fda21ae6c32871e3d398cba549b93f4a65a2d369662d9403"}, + {file = "tokenizers-0.19.1-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:5c88d1481f1882c2e53e6bb06491e474e420d9ac7bdff172610c4f9ad3898059"}, + {file = "tokenizers-0.19.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ddf672ed719b4ed82b51499100f5417d7d9f6fb05a65e232249268f35de5ed14"}, + {file = "tokenizers-0.19.1-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:dadc509cc8a9fe460bd274c0e16ac4184d0958117cf026e0ea8b32b438171594"}, + {file = "tokenizers-0.19.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dfedf31824ca4915b511b03441784ff640378191918264268e6923da48104acc"}, + {file = "tokenizers-0.19.1-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ac11016d0a04aa6487b1513a3a36e7bee7eec0e5d30057c9c0408067345c48d2"}, + {file = "tokenizers-0.19.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:76951121890fea8330d3a0df9a954b3f2a37e3ec20e5b0530e9a0044ca2e11fe"}, + {file = "tokenizers-0.19.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b342d2ce8fc8d00f376af068e3274e2e8649562e3bc6ae4a67784ded6b99428d"}, + {file = "tokenizers-0.19.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d16ff18907f4909dca9b076b9c2d899114dd6abceeb074eca0c93e2353f943aa"}, + {file = "tokenizers-0.19.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:706a37cc5332f85f26efbe2bdc9ef8a9b372b77e4645331a405073e4b3a8c1c6"}, + {file = "tokenizers-0.19.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:16baac68651701364b0289979ecec728546133e8e8fe38f66fe48ad07996b88b"}, + {file = "tokenizers-0.19.1-cp311-none-win32.whl", hash = "sha256:9ed240c56b4403e22b9584ee37d87b8bfa14865134e3e1c3fb4b2c42fafd3256"}, + {file = "tokenizers-0.19.1-cp311-none-win_amd64.whl", hash = "sha256:ad57d59341710b94a7d9dbea13f5c1e7d76fd8d9bcd944a7a6ab0b0da6e0cc66"}, + {file = "tokenizers-0.19.1-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:621d670e1b1c281a1c9698ed89451395d318802ff88d1fc1accff0867a06f153"}, + {file = "tokenizers-0.19.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:d924204a3dbe50b75630bd16f821ebda6a5f729928df30f582fb5aade90c818a"}, + {file = "tokenizers-0.19.1-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:4f3fefdc0446b1a1e6d81cd4c07088ac015665d2e812f6dbba4a06267d1a2c95"}, + {file = "tokenizers-0.19.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9620b78e0b2d52ef07b0d428323fb34e8ea1219c5eac98c2596311f20f1f9266"}, + {file = "tokenizers-0.19.1-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:04ce49e82d100594715ac1b2ce87d1a36e61891a91de774755f743babcd0dd52"}, + {file = "tokenizers-0.19.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c5c2ff13d157afe413bf7e25789879dd463e5a4abfb529a2d8f8473d8042e28f"}, + {file = "tokenizers-0.19.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3174c76efd9d08f836bfccaca7cfec3f4d1c0a4cf3acbc7236ad577cc423c840"}, + {file = "tokenizers-0.19.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7c9d5b6c0e7a1e979bec10ff960fae925e947aab95619a6fdb4c1d8ff3708ce3"}, + {file = "tokenizers-0.19.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:a179856d1caee06577220ebcfa332af046d576fb73454b8f4d4b0ba8324423ea"}, + {file = "tokenizers-0.19.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:952b80dac1a6492170f8c2429bd11fcaa14377e097d12a1dbe0ef2fb2241e16c"}, + {file = "tokenizers-0.19.1-cp312-none-win32.whl", hash = "sha256:01d62812454c188306755c94755465505836fd616f75067abcae529c35edeb57"}, + {file = "tokenizers-0.19.1-cp312-none-win_amd64.whl", hash = "sha256:b70bfbe3a82d3e3fb2a5e9b22a39f8d1740c96c68b6ace0086b39074f08ab89a"}, + {file = "tokenizers-0.19.1-cp37-cp37m-macosx_10_12_x86_64.whl", hash = "sha256:bb9dfe7dae85bc6119d705a76dc068c062b8b575abe3595e3c6276480e67e3f1"}, + {file = "tokenizers-0.19.1-cp37-cp37m-macosx_11_0_arm64.whl", hash = "sha256:1f0360cbea28ea99944ac089c00de7b2e3e1c58f479fb8613b6d8d511ce98267"}, + {file = "tokenizers-0.19.1-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:71e3ec71f0e78780851fef28c2a9babe20270404c921b756d7c532d280349214"}, + {file = "tokenizers-0.19.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b82931fa619dbad979c0ee8e54dd5278acc418209cc897e42fac041f5366d626"}, + {file = "tokenizers-0.19.1-cp37-cp37m-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e8ff5b90eabdcdaa19af697885f70fe0b714ce16709cf43d4952f1f85299e73a"}, + {file = "tokenizers-0.19.1-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e742d76ad84acbdb1a8e4694f915fe59ff6edc381c97d6dfdd054954e3478ad4"}, + {file = "tokenizers-0.19.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d8c5d59d7b59885eab559d5bc082b2985555a54cda04dda4c65528d90ad252ad"}, + {file = "tokenizers-0.19.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6b2da5c32ed869bebd990c9420df49813709e953674c0722ff471a116d97b22d"}, + {file = "tokenizers-0.19.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:638e43936cc8b2cbb9f9d8dde0fe5e7e30766a3318d2342999ae27f68fdc9bd6"}, + {file = "tokenizers-0.19.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:78e769eb3b2c79687d9cb0f89ef77223e8e279b75c0a968e637ca7043a84463f"}, + {file = "tokenizers-0.19.1-cp37-none-win32.whl", hash = "sha256:72791f9bb1ca78e3ae525d4782e85272c63faaef9940d92142aa3eb79f3407a3"}, + {file = "tokenizers-0.19.1-cp37-none-win_amd64.whl", hash = "sha256:f3bbb7a0c5fcb692950b041ae11067ac54826204318922da754f908d95619fbc"}, + {file = "tokenizers-0.19.1-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:07f9295349bbbcedae8cefdbcfa7f686aa420be8aca5d4f7d1ae6016c128c0c5"}, + {file = "tokenizers-0.19.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:10a707cc6c4b6b183ec5dbfc5c34f3064e18cf62b4a938cb41699e33a99e03c1"}, + {file = "tokenizers-0.19.1-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:6309271f57b397aa0aff0cbbe632ca9d70430839ca3178bf0f06f825924eca22"}, + {file = "tokenizers-0.19.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4ad23d37d68cf00d54af184586d79b84075ada495e7c5c0f601f051b162112dc"}, + {file = "tokenizers-0.19.1-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:427c4f0f3df9109314d4f75b8d1f65d9477033e67ffaec4bca53293d3aca286d"}, + {file = "tokenizers-0.19.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e83a31c9cf181a0a3ef0abad2b5f6b43399faf5da7e696196ddd110d332519ee"}, + {file = "tokenizers-0.19.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c27b99889bd58b7e301468c0838c5ed75e60c66df0d4db80c08f43462f82e0d3"}, + {file = "tokenizers-0.19.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bac0b0eb952412b0b196ca7a40e7dce4ed6f6926489313414010f2e6b9ec2adf"}, + {file = "tokenizers-0.19.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:8a6298bde623725ca31c9035a04bf2ef63208d266acd2bed8c2cb7d2b7d53ce6"}, + {file = "tokenizers-0.19.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:08a44864e42fa6d7d76d7be4bec62c9982f6f6248b4aa42f7302aa01e0abfd26"}, + {file = "tokenizers-0.19.1-cp38-none-win32.whl", hash = "sha256:1de5bc8652252d9357a666e609cb1453d4f8e160eb1fb2830ee369dd658e8975"}, + {file = "tokenizers-0.19.1-cp38-none-win_amd64.whl", hash = "sha256:0bcce02bf1ad9882345b34d5bd25ed4949a480cf0e656bbd468f4d8986f7a3f1"}, + {file = "tokenizers-0.19.1-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:0b9394bd204842a2a1fd37fe29935353742be4a3460b6ccbaefa93f58a8df43d"}, + {file = "tokenizers-0.19.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4692ab92f91b87769d950ca14dbb61f8a9ef36a62f94bad6c82cc84a51f76f6a"}, + {file = "tokenizers-0.19.1-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:6258c2ef6f06259f70a682491c78561d492e885adeaf9f64f5389f78aa49a051"}, + {file = "tokenizers-0.19.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c85cf76561fbd01e0d9ea2d1cbe711a65400092bc52b5242b16cfd22e51f0c58"}, + {file = "tokenizers-0.19.1-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:670b802d4d82bbbb832ddb0d41df7015b3e549714c0e77f9bed3e74d42400fbe"}, + {file = "tokenizers-0.19.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:85aa3ab4b03d5e99fdd31660872249df5e855334b6c333e0bc13032ff4469c4a"}, + {file = "tokenizers-0.19.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cbf001afbbed111a79ca47d75941e9e5361297a87d186cbfc11ed45e30b5daba"}, + {file = "tokenizers-0.19.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b4c89aa46c269e4e70c4d4f9d6bc644fcc39bb409cb2a81227923404dd6f5227"}, + {file = "tokenizers-0.19.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:39c1ec76ea1027438fafe16ecb0fb84795e62e9d643444c1090179e63808c69d"}, + {file = "tokenizers-0.19.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:c2a0d47a89b48d7daa241e004e71fb5a50533718897a4cd6235cb846d511a478"}, + {file = "tokenizers-0.19.1-cp39-none-win32.whl", hash = "sha256:61b7fe8886f2e104d4caf9218b157b106207e0f2a4905c9c7ac98890688aabeb"}, + {file = "tokenizers-0.19.1-cp39-none-win_amd64.whl", hash = "sha256:f97660f6c43efd3e0bfd3f2e3e5615bf215680bad6ee3d469df6454b8c6e8256"}, + {file = "tokenizers-0.19.1-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:3b11853f17b54c2fe47742c56d8a33bf49ce31caf531e87ac0d7d13d327c9334"}, + {file = "tokenizers-0.19.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:d26194ef6c13302f446d39972aaa36a1dda6450bc8949f5eb4c27f51191375bd"}, + {file = "tokenizers-0.19.1-pp310-pypy310_pp73-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:e8d1ed93beda54bbd6131a2cb363a576eac746d5c26ba5b7556bc6f964425594"}, + {file = "tokenizers-0.19.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ca407133536f19bdec44b3da117ef0d12e43f6d4b56ac4c765f37eca501c7bda"}, + {file = "tokenizers-0.19.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ce05fde79d2bc2e46ac08aacbc142bead21614d937aac950be88dc79f9db9022"}, + {file = "tokenizers-0.19.1-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:35583cd46d16f07c054efd18b5d46af4a2f070a2dd0a47914e66f3ff5efb2b1e"}, + {file = "tokenizers-0.19.1-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:43350270bfc16b06ad3f6f07eab21f089adb835544417afda0f83256a8bf8b75"}, + {file = "tokenizers-0.19.1-pp37-pypy37_pp73-macosx_10_12_x86_64.whl", hash = "sha256:b4399b59d1af5645bcee2072a463318114c39b8547437a7c2d6a186a1b5a0e2d"}, + {file = "tokenizers-0.19.1-pp37-pypy37_pp73-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:6852c5b2a853b8b0ddc5993cd4f33bfffdca4fcc5d52f89dd4b8eada99379285"}, + {file = "tokenizers-0.19.1-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bcd266ae85c3d39df2f7e7d0e07f6c41a55e9a3123bb11f854412952deacd828"}, + {file = "tokenizers-0.19.1-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ecb2651956eea2aa0a2d099434134b1b68f1c31f9a5084d6d53f08ed43d45ff2"}, + {file = "tokenizers-0.19.1-pp37-pypy37_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:b279ab506ec4445166ac476fb4d3cc383accde1ea152998509a94d82547c8e2a"}, + {file = "tokenizers-0.19.1-pp37-pypy37_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:89183e55fb86e61d848ff83753f64cded119f5d6e1f553d14ffee3700d0a4a49"}, + {file = "tokenizers-0.19.1-pp38-pypy38_pp73-macosx_10_12_x86_64.whl", hash = "sha256:b2edbc75744235eea94d595a8b70fe279dd42f3296f76d5a86dde1d46e35f574"}, + {file = "tokenizers-0.19.1-pp38-pypy38_pp73-macosx_11_0_arm64.whl", hash = "sha256:0e64bfde9a723274e9a71630c3e9494ed7b4c0f76a1faacf7fe294cd26f7ae7c"}, + {file = "tokenizers-0.19.1-pp38-pypy38_pp73-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:0b5ca92bfa717759c052e345770792d02d1f43b06f9e790ca0a1db62838816f3"}, + {file = "tokenizers-0.19.1-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6f8a20266e695ec9d7a946a019c1d5ca4eddb6613d4f466888eee04f16eedb85"}, + {file = "tokenizers-0.19.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:63c38f45d8f2a2ec0f3a20073cccb335b9f99f73b3c69483cd52ebc75369d8a1"}, + {file = "tokenizers-0.19.1-pp38-pypy38_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:dd26e3afe8a7b61422df3176e06664503d3f5973b94f45d5c45987e1cb711876"}, + {file = "tokenizers-0.19.1-pp38-pypy38_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:eddd5783a4a6309ce23432353cdb36220e25cbb779bfa9122320666508b44b88"}, + {file = "tokenizers-0.19.1-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:56ae39d4036b753994476a1b935584071093b55c7a72e3b8288e68c313ca26e7"}, + {file = "tokenizers-0.19.1-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:f9939ca7e58c2758c01b40324a59c034ce0cebad18e0d4563a9b1beab3018243"}, + {file = "tokenizers-0.19.1-pp39-pypy39_pp73-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:6c330c0eb815d212893c67a032e9dc1b38a803eccb32f3e8172c19cc69fbb439"}, + {file = "tokenizers-0.19.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ec11802450a2487cdf0e634b750a04cbdc1c4d066b97d94ce7dd2cb51ebb325b"}, + {file = "tokenizers-0.19.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a2b718f316b596f36e1dae097a7d5b91fc5b85e90bf08b01ff139bd8953b25af"}, + {file = "tokenizers-0.19.1-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:ed69af290c2b65169f0ba9034d1dc39a5db9459b32f1dd8b5f3f32a3fcf06eab"}, + {file = "tokenizers-0.19.1-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:f8a9c828277133af13f3859d1b6bf1c3cb6e9e1637df0e45312e6b7c2e622b1f"}, + {file = "tokenizers-0.19.1.tar.gz", hash = "sha256:ee59e6680ed0fdbe6b724cf38bd70400a0c1dd623b07ac729087270caeac88e3"}, ] [package.dependencies] -huggingface_hub = ">=0.16.4,<1.0" +huggingface-hub = ">=0.16.4,<1.0" [package.extras] dev = ["tokenizers[testing]"] -docs = ["setuptools_rust", "sphinx", "sphinx_rtd_theme"] -testing = ["black (==22.3)", "datasets", "numpy", "pytest", "requests"] +docs = ["setuptools-rust", "sphinx", "sphinx-rtd-theme"] +testing = ["black (==22.3)", "datasets", "numpy", "pytest", "requests", "ruff"] [[package]] name = "tomli" @@ -1038,24 +1028,24 @@ files = [ [[package]] name = "typing-extensions" -version = "4.12.1" +version = "4.12.2" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.12.1-py3-none-any.whl", hash = "sha256:6024b58b69089e5a89c347397254e35f1bf02a907728ec7fee9bf0fe837d203a"}, - {file = "typing_extensions-4.12.1.tar.gz", hash = "sha256:915f5e35ff76f56588223f15fdd5938f9a1cf9195c0de25130c627e4d597f6d1"}, + {file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"}, + {file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"}, ] [[package]] name = "urllib3" -version = "1.26.18" +version = "1.26.19" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7" files = [ - {file = "urllib3-1.26.18-py2.py3-none-any.whl", hash = "sha256:34b97092d7e0a3a8cf7cd10e386f401b3737364026c45e622aa02903dffe0f07"}, - {file = "urllib3-1.26.18.tar.gz", hash = "sha256:f8ecc1bba5667413457c529ab955bf8c67b45db799d159066261719e328580a0"}, + {file = "urllib3-1.26.19-py2.py3-none-any.whl", hash = "sha256:37a0344459b199fce0e80b0d3569837ec6b6937435c5244e7fd73fa6006830f3"}, + {file = "urllib3-1.26.19.tar.gz", hash = "sha256:3e3d753a8618b86d7de333b4223005f68720bcd6a7d2bcb9fbd2229ec7c1e429"}, ] [package.extras] @@ -1065,13 +1055,13 @@ socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] [[package]] name = "urllib3" -version = "2.2.1" +version = "2.2.2" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.8" files = [ - {file = "urllib3-2.2.1-py3-none-any.whl", hash = "sha256:450b20ec296a467077128bff42b73080516e71b56ff59a60a02bef2232c4fa9d"}, - {file = "urllib3-2.2.1.tar.gz", hash = "sha256:d0570876c61ab9e520d776c38acbbb5b05a776d3f9ff98a5c8fd5162a444cf19"}, + {file = "urllib3-2.2.2-py3-none-any.whl", hash = "sha256:a448b2f64d686155468037e1ace9f2d2199776e17f0a46610480d311f73e3472"}, + {file = "urllib3-2.2.2.tar.gz", hash = "sha256:dd505485549a7a552833da5e6063639d0d177c04f23bc3864e41e5dc5f612168"}, ] [package.extras] @@ -1083,4 +1073,4 @@ zstd = ["zstandard (>=0.18.0)"] [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "6bdd03c9249785eaa82547e033f9d2e8fdc7b46fa2a436fb3e41d8a59e80e3bf" +content-hash = "9b7a0f3e6027d6e2d5e1ec9c45a405f776b03c9c7935cb30b7fe8aec23683ce2" diff --git a/pyproject.toml b/pyproject.toml index a2600a662..8c3f9982f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cohere" -version = "5.5.7" +version = "5.5.8" description = "" readme = "README.md" authors = [] @@ -27,9 +27,6 @@ packages = [ { include = "cohere", from = "src"} ] -[tool.poetry.group.dev.dependencies] -parameterized = "^0.9.0" - [project.urls] Repository = 'https://github.com/cohere-ai/cohere-python' @@ -42,7 +39,7 @@ httpx-sse = "^0.4.0" parameterized = "^0.9.0" pydantic = ">= 1.9.2" requests = "^2.0.0" -tokenizers = "^0.15" +tokenizers = ">=0.15,<1" types-requests = "^2.0.0" typing_extensions = ">= 4.0.0" diff --git a/src/cohere/__init__.py b/src/cohere/__init__.py index a6cd2fffc..8456c1a2e 100644 --- a/src/cohere/__init__.py +++ b/src/cohere/__init__.py @@ -38,6 +38,7 @@ ClassifyResponseClassificationsItem, ClassifyResponseClassificationsItemClassificationType, ClassifyResponseClassificationsItemLabelsValue, + ClientClosedRequestErrorBody, CompatibleEndpoint, Connector, ConnectorAuthStatus, @@ -66,6 +67,7 @@ EmbeddingType, FinetuneDatasetMetrics, FinishReason, + GatewayTimeoutErrorBody, GenerateRequestReturnLikelihoods, GenerateRequestTruncate, GenerateStreamEnd, @@ -95,6 +97,7 @@ MetricsEmbedData, MetricsEmbedDataFieldsItem, NonStreamedChatResponse, + NotImplementedErrorBody, OAuthAuthorizeResponse, ParseInfo, RerankRequestDocumentsItem, @@ -127,16 +130,21 @@ ToolMessage, ToolParameterDefinitionsValue, ToolResult, + UnprocessableEntityErrorBody, UpdateConnectorResponse, ) from .errors import ( BadRequestError, + ClientClosedRequestError, ForbiddenError, + GatewayTimeoutError, InternalServerError, NotFoundError, + NotImplementedError, ServiceUnavailableError, TooManyRequestsError, UnauthorizedError, + UnprocessableEntityError, ) from . import connectors, datasets, embed_jobs, finetuning, models from .aws_client import AwsClient @@ -197,6 +205,8 @@ "ClassifyResponseClassificationsItemClassificationType", "ClassifyResponseClassificationsItemLabelsValue", "Client", + "ClientClosedRequestError", + "ClientClosedRequestErrorBody", "ClientEnvironment", "CompatibleEndpoint", "Connector", @@ -233,6 +243,8 @@ "FinetuneDatasetMetrics", "FinishReason", "ForbiddenError", + "GatewayTimeoutError", + "GatewayTimeoutErrorBody", "GenerateRequestReturnLikelihoods", "GenerateRequestTruncate", "GenerateStreamEnd", @@ -264,6 +276,8 @@ "MetricsEmbedDataFieldsItem", "NonStreamedChatResponse", "NotFoundError", + "NotImplementedError", + "NotImplementedErrorBody", "OAuthAuthorizeResponse", "ParseInfo", "RerankRequestDocumentsItem", @@ -300,6 +314,8 @@ "ToolParameterDefinitionsValue", "ToolResult", "UnauthorizedError", + "UnprocessableEntityError", + "UnprocessableEntityErrorBody", "UpdateConnectorResponse", "__version__", "connectors", diff --git a/src/cohere/base_client.py b/src/cohere/base_client.py index e9a771470..abda66bc3 100644 --- a/src/cohere/base_client.py +++ b/src/cohere/base_client.py @@ -16,8 +16,16 @@ from .embed_jobs.client import AsyncEmbedJobsClient, EmbedJobsClient from .environment import ClientEnvironment from .errors.bad_request_error import BadRequestError +from .errors.client_closed_request_error import ClientClosedRequestError +from .errors.forbidden_error import ForbiddenError +from .errors.gateway_timeout_error import GatewayTimeoutError from .errors.internal_server_error import InternalServerError +from .errors.not_found_error import NotFoundError +from .errors.not_implemented_error import NotImplementedError +from .errors.service_unavailable_error import ServiceUnavailableError from .errors.too_many_requests_error import TooManyRequestsError +from .errors.unauthorized_error import UnauthorizedError +from .errors.unprocessable_entity_error import UnprocessableEntityError from .finetuning.client import AsyncFinetuningClient, FinetuningClient from .models.client import AsyncModelsClient, ModelsClient from .types.chat_connector import ChatConnector @@ -30,11 +38,13 @@ from .types.classify_example import ClassifyExample from .types.classify_request_truncate import ClassifyRequestTruncate from .types.classify_response import ClassifyResponse +from .types.client_closed_request_error_body import ClientClosedRequestErrorBody from .types.detokenize_response import DetokenizeResponse from .types.embed_input_type import EmbedInputType from .types.embed_request_truncate import EmbedRequestTruncate from .types.embed_response import EmbedResponse from .types.embedding_type import EmbeddingType +from .types.gateway_timeout_error_body import GatewayTimeoutErrorBody from .types.generate_request_return_likelihoods import GenerateRequestReturnLikelihoods from .types.generate_request_truncate import GenerateRequestTruncate from .types.generate_stream_request_return_likelihoods import GenerateStreamRequestReturnLikelihoods @@ -43,6 +53,7 @@ from .types.generation import Generation from .types.message import Message from .types.non_streamed_chat_response import NonStreamedChatResponse +from .types.not_implemented_error_body import NotImplementedErrorBody from .types.rerank_request_documents_item import RerankRequestDocumentsItem from .types.rerank_response import RerankResponse from .types.streamed_chat_response import StreamedChatResponse @@ -54,6 +65,7 @@ from .types.too_many_requests_error_body import TooManyRequestsErrorBody from .types.tool import Tool from .types.tool_result import ToolResult +from .types.unprocessable_entity_error_body import UnprocessableEntityErrorBody # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -492,10 +504,50 @@ def chat_stream( yield typing.cast(StreamedChatResponse, construct_type(type_=StreamedChatResponse, object_=json.loads(_text))) # type: ignore return _response.read() + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -788,10 +840,50 @@ def chat( ) if 200 <= _response.status_code < 300: return typing.cast(NonStreamedChatResponse, construct_type(type_=NonStreamedChatResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -987,14 +1079,46 @@ def generate_stream( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -1168,14 +1292,46 @@ def generate( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -1281,14 +1437,46 @@ def embed( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -1383,10 +1571,50 @@ def rerank( ) if 200 <= _response.status_code < 300: return typing.cast(RerankResponse, construct_type(type_=RerankResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -1505,14 +1733,46 @@ def classify( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -1598,10 +1858,50 @@ def summarize( ) if 200 <= _response.status_code < 300: return typing.cast(SummarizeResponse, construct_type(type_=SummarizeResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -1652,14 +1952,46 @@ def tokenize( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -1710,10 +2042,50 @@ def detokenize( ) if 200 <= _response.status_code < 300: return typing.cast(DetokenizeResponse, construct_type(type_=DetokenizeResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -1749,10 +2121,50 @@ def check_api_key(self, *, request_options: typing.Optional[RequestOptions] = No ) if 200 <= _response.status_code < 300: return typing.cast(CheckApiKeyResponse, construct_type(type_=CheckApiKeyResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -2193,10 +2605,50 @@ async def chat_stream( yield typing.cast(StreamedChatResponse, construct_type(type_=StreamedChatResponse, object_=json.loads(_text))) # type: ignore return await _response.aread() + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -2489,10 +2941,50 @@ async def chat( ) if 200 <= _response.status_code < 300: return typing.cast(NonStreamedChatResponse, construct_type(type_=NonStreamedChatResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -2688,14 +3180,46 @@ async def generate_stream( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -2869,14 +3393,46 @@ async def generate( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -2982,14 +3538,46 @@ async def embed( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -3084,10 +3672,50 @@ async def rerank( ) if 200 <= _response.status_code < 300: return typing.cast(RerankResponse, construct_type(type_=RerankResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -3206,14 +3834,46 @@ async def classify( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -3299,10 +3959,50 @@ async def summarize( ) if 200 <= _response.status_code < 300: return typing.cast(SummarizeResponse, construct_type(type_=SummarizeResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -3353,14 +4053,46 @@ async def tokenize( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -3411,10 +4143,50 @@ async def detokenize( ) if 200 <= _response.status_code < 300: return typing.cast(DetokenizeResponse, construct_type(type_=DetokenizeResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -3450,10 +4222,50 @@ async def check_api_key(self, *, request_options: typing.Optional[RequestOptions ) if 200 <= _response.status_code < 300: return typing.cast(CheckApiKeyResponse, construct_type(type_=CheckApiKeyResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/cohere/connectors/client.py b/src/cohere/connectors/client.py index 8242833e0..abc168c49 100644 --- a/src/cohere/connectors/client.py +++ b/src/cohere/connectors/client.py @@ -9,18 +9,28 @@ from ..core.request_options import RequestOptions from ..core.unchecked_base_model import construct_type from ..errors.bad_request_error import BadRequestError +from ..errors.client_closed_request_error import ClientClosedRequestError from ..errors.forbidden_error import ForbiddenError +from ..errors.gateway_timeout_error import GatewayTimeoutError from ..errors.internal_server_error import InternalServerError from ..errors.not_found_error import NotFoundError +from ..errors.not_implemented_error import NotImplementedError +from ..errors.service_unavailable_error import ServiceUnavailableError from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.client_closed_request_error_body import ClientClosedRequestErrorBody from ..types.create_connector_o_auth import CreateConnectorOAuth from ..types.create_connector_response import CreateConnectorResponse from ..types.create_connector_service_auth import CreateConnectorServiceAuth from ..types.delete_connector_response import DeleteConnectorResponse +from ..types.gateway_timeout_error_body import GatewayTimeoutErrorBody from ..types.get_connector_response import GetConnectorResponse from ..types.list_connectors_response import ListConnectorsResponse +from ..types.not_implemented_error_body import NotImplementedErrorBody from ..types.o_auth_authorize_response import OAuthAuthorizeResponse from ..types.too_many_requests_error_body import TooManyRequestsErrorBody +from ..types.unprocessable_entity_error_body import UnprocessableEntityErrorBody from ..types.update_connector_response import UpdateConnectorResponse # this is used as the default value for optional parameters @@ -76,14 +86,46 @@ def list( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -175,18 +217,46 @@ def create( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) if _response.status_code == 403: raise ForbiddenError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -231,18 +301,46 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) if _response.status_code == 404: raise NotFoundError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -287,6 +385,10 @@ def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) if _response.status_code == 403: raise ForbiddenError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore @@ -295,14 +397,34 @@ def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = raise NotFoundError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -390,6 +512,10 @@ def update( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) if _response.status_code == 403: raise ForbiddenError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore @@ -398,14 +524,34 @@ def update( raise NotFoundError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -462,18 +608,46 @@ def o_auth_authorize( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) if _response.status_code == 404: raise NotFoundError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -530,14 +704,46 @@ async def list( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -629,18 +835,46 @@ async def create( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) if _response.status_code == 403: raise ForbiddenError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -685,18 +919,46 @@ async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) if _response.status_code == 404: raise NotFoundError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -743,6 +1005,10 @@ async def delete( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) if _response.status_code == 403: raise ForbiddenError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore @@ -751,14 +1017,34 @@ async def delete( raise NotFoundError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -846,6 +1132,10 @@ async def update( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) if _response.status_code == 403: raise ForbiddenError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore @@ -854,14 +1144,34 @@ async def update( raise NotFoundError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -918,18 +1228,46 @@ async def o_auth_authorize( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) if _response.status_code == 404: raise NotFoundError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/cohere/core/client_wrapper.py b/src/cohere/core/client_wrapper.py index 16db279e1..1875c140a 100644 --- a/src/cohere/core/client_wrapper.py +++ b/src/cohere/core/client_wrapper.py @@ -25,7 +25,7 @@ def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", "X-Fern-SDK-Name": "cohere", - "X-Fern-SDK-Version": "5.5.7", + "X-Fern-SDK-Version": "5.5.8", } if self._client_name is not None: headers["X-Client-Name"] = self._client_name diff --git a/src/cohere/core/http_client.py b/src/cohere/core/http_client.py index 8f8f67770..ed7cf5d3d 100644 --- a/src/cohere/core/http_client.py +++ b/src/cohere/core/http_client.py @@ -106,7 +106,11 @@ def maybe_filter_request_body( omit: typing.Optional[typing.Any], ) -> typing.Optional[typing.Any]: if data is None: - return None + return ( + jsonable_encoder(request_options.get("additional_body_parameters", {})) + if request_options is not None + else None + ) elif not isinstance(data, typing.Mapping): data_content = jsonable_encoder(data) else: diff --git a/src/cohere/core/unchecked_base_model.py b/src/cohere/core/unchecked_base_model.py index 7dbaf0488..a29d39c24 100644 --- a/src/cohere/core/unchecked_base_model.py +++ b/src/cohere/core/unchecked_base_model.py @@ -8,7 +8,7 @@ import typing_extensions from .datetime_utils import serialize_datetime -from .pydantic_utilities import IS_PYDANTIC_V2, pydantic_v1 +from .pydantic_utilities import pydantic_v1 class UnionMetadata: @@ -46,22 +46,20 @@ def construct( _fields_set = set(values.keys()) for name, field in cls.__fields__.items(): + # Key here is only used to pull data from the values dict + # you should always use the NAME of the field to for field_values, etc. + # because that's how the object is constructed from a pydantic perspective key = field.alias - if ( + if key is None or ( key not in values and config.allow_population_by_field_name ): # Added this to allow population by field name key = name if key in values: - if ( - values[key] is None and not field.required - ): # Moved this check since None value can be passed for Optional nested field - fields_values[name] = field.get_default() - else: - type_ = typing.cast(typing.Type, field.outer_type_) # type: ignore - fields_values[name] = construct_type(object_=values[key], type_=type_) + type_ = typing.cast(typing.Type, field.outer_type_) # type: ignore + fields_values[name] = construct_type(object_=values[key], type_=type_) _fields_set.add(name) - elif not field.required: + else: default = field.get_default() fields_values[name] = default @@ -69,26 +67,18 @@ def construct( # This effectively allows exclude_unset to work like exclude_none where # the latter passes through intentionally set none values. if default != None: - _fields_set.add(key) + _fields_set.add(name) # Add extras back in - _extra = {} + alias_fields = [field.alias for field in cls.__fields__.values()] for key, value in values.items(): - if key not in _fields_set: - _extra[key] = value - # In v2 we'll need to exclude extra fields from fields_values - if not IS_PYDANTIC_V2: - _fields_set.add(key) - fields_values[key] = value - - if IS_PYDANTIC_V2: - object.__setattr__(m, "__pydantic_private__", None) - object.__setattr__(m, "__pydantic_extra__", _extra) - object.__setattr__(m, "__pydantic_fields_set__", _fields_set) + if key not in alias_fields and key not in cls.__fields__: + _fields_set.add(key) + fields_values[key] = value object.__setattr__(m, "__dict__", fields_values) - object.__setattr__(m, "__fields_set__", _fields_set) m._init_private_attributes() + object.__setattr__(m, "__fields_set__", _fields_set) return m diff --git a/src/cohere/datasets/client.py b/src/cohere/datasets/client.py index 1e1ca9a40..e1bec9ad0 100644 --- a/src/cohere/datasets/client.py +++ b/src/cohere/datasets/client.py @@ -11,10 +11,24 @@ from ..core.jsonable_encoder import jsonable_encoder from ..core.request_options import RequestOptions from ..core.unchecked_base_model import construct_type +from ..errors.bad_request_error import BadRequestError +from ..errors.client_closed_request_error import ClientClosedRequestError +from ..errors.forbidden_error import ForbiddenError +from ..errors.gateway_timeout_error import GatewayTimeoutError +from ..errors.internal_server_error import InternalServerError +from ..errors.not_found_error import NotFoundError +from ..errors.not_implemented_error import NotImplementedError +from ..errors.service_unavailable_error import ServiceUnavailableError from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.client_closed_request_error_body import ClientClosedRequestErrorBody from ..types.dataset_type import DatasetType from ..types.dataset_validation_status import DatasetValidationStatus +from ..types.gateway_timeout_error_body import GatewayTimeoutErrorBody +from ..types.not_implemented_error_body import NotImplementedErrorBody from ..types.too_many_requests_error_body import TooManyRequestsErrorBody +from ..types.unprocessable_entity_error_body import UnprocessableEntityErrorBody from .types.datasets_create_response import DatasetsCreateResponse from .types.datasets_get_response import DatasetsGetResponse from .types.datasets_get_usage_response import DatasetsGetUsageResponse @@ -95,10 +109,50 @@ def list( ) if 200 <= _response.status_code < 300: return typing.cast(DatasetsListResponse, construct_type(type_=DatasetsListResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -201,10 +255,50 @@ def create( ) if 200 <= _response.status_code < 300: return typing.cast(DatasetsCreateResponse, construct_type(type_=DatasetsCreateResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -240,10 +334,50 @@ def get_usage(self, *, request_options: typing.Optional[RequestOptions] = None) ) if 200 <= _response.status_code < 300: return typing.cast(DatasetsGetUsageResponse, construct_type(type_=DatasetsGetUsageResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -283,10 +417,50 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non ) if 200 <= _response.status_code < 300: return typing.cast(DatasetsGetResponse, construct_type(type_=DatasetsGetResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -328,10 +502,50 @@ def delete( ) if 200 <= _response.status_code < 300: return typing.cast(typing.Dict[str, typing.Any], construct_type(type_=typing.Dict[str, typing.Any], object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -410,10 +624,50 @@ async def list( ) if 200 <= _response.status_code < 300: return typing.cast(DatasetsListResponse, construct_type(type_=DatasetsListResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -516,10 +770,50 @@ async def create( ) if 200 <= _response.status_code < 300: return typing.cast(DatasetsCreateResponse, construct_type(type_=DatasetsCreateResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -555,10 +849,50 @@ async def get_usage(self, *, request_options: typing.Optional[RequestOptions] = ) if 200 <= _response.status_code < 300: return typing.cast(DatasetsGetUsageResponse, construct_type(type_=DatasetsGetUsageResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -598,10 +932,50 @@ async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] ) if 200 <= _response.status_code < 300: return typing.cast(DatasetsGetResponse, construct_type(type_=DatasetsGetResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -643,10 +1017,50 @@ async def delete( ) if 200 <= _response.status_code < 300: return typing.cast(typing.Dict[str, typing.Any], construct_type(type_=typing.Dict[str, typing.Any], object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/cohere/embed_jobs/client.py b/src/cohere/embed_jobs/client.py index ed189b239..397744d77 100644 --- a/src/cohere/embed_jobs/client.py +++ b/src/cohere/embed_jobs/client.py @@ -9,15 +9,26 @@ from ..core.request_options import RequestOptions from ..core.unchecked_base_model import construct_type from ..errors.bad_request_error import BadRequestError +from ..errors.client_closed_request_error import ClientClosedRequestError +from ..errors.forbidden_error import ForbiddenError +from ..errors.gateway_timeout_error import GatewayTimeoutError from ..errors.internal_server_error import InternalServerError from ..errors.not_found_error import NotFoundError +from ..errors.not_implemented_error import NotImplementedError +from ..errors.service_unavailable_error import ServiceUnavailableError from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.client_closed_request_error_body import ClientClosedRequestErrorBody from ..types.create_embed_job_response import CreateEmbedJobResponse from ..types.embed_input_type import EmbedInputType from ..types.embed_job import EmbedJob from ..types.embedding_type import EmbeddingType +from ..types.gateway_timeout_error_body import GatewayTimeoutErrorBody from ..types.list_embed_job_response import ListEmbedJobResponse +from ..types.not_implemented_error_body import NotImplementedErrorBody from ..types.too_many_requests_error_body import TooManyRequestsErrorBody +from ..types.unprocessable_entity_error_body import UnprocessableEntityErrorBody from .types.create_embed_job_request_truncate import CreateEmbedJobRequestTruncate # this is used as the default value for optional parameters @@ -61,14 +72,46 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Li raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -167,14 +210,46 @@ def create( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -219,18 +294,46 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) if _response.status_code == 404: raise NotFoundError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -274,18 +377,46 @@ def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) if _response.status_code == 404: raise NotFoundError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -330,14 +461,46 @@ async def list(self, *, request_options: typing.Optional[RequestOptions] = None) raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -436,14 +599,46 @@ async def create( raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -488,18 +683,46 @@ async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) if _response.status_code == 404: raise NotFoundError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -543,18 +766,46 @@ async def cancel(self, id: str, *, request_options: typing.Optional[RequestOptio raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) if _response.status_code == 404: raise NotFoundError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/cohere/errors/__init__.py b/src/cohere/errors/__init__.py index 095e9c104..c48c1d74a 100644 --- a/src/cohere/errors/__init__.py +++ b/src/cohere/errors/__init__.py @@ -1,19 +1,27 @@ # This file was auto-generated by Fern from our API Definition. from .bad_request_error import BadRequestError +from .client_closed_request_error import ClientClosedRequestError from .forbidden_error import ForbiddenError +from .gateway_timeout_error import GatewayTimeoutError from .internal_server_error import InternalServerError from .not_found_error import NotFoundError +from .not_implemented_error import NotImplementedError from .service_unavailable_error import ServiceUnavailableError from .too_many_requests_error import TooManyRequestsError from .unauthorized_error import UnauthorizedError +from .unprocessable_entity_error import UnprocessableEntityError __all__ = [ "BadRequestError", + "ClientClosedRequestError", "ForbiddenError", + "GatewayTimeoutError", "InternalServerError", "NotFoundError", + "NotImplementedError", "ServiceUnavailableError", "TooManyRequestsError", "UnauthorizedError", + "UnprocessableEntityError", ] diff --git a/src/cohere/errors/client_closed_request_error.py b/src/cohere/errors/client_closed_request_error.py new file mode 100644 index 000000000..83e68c96d --- /dev/null +++ b/src/cohere/errors/client_closed_request_error.py @@ -0,0 +1,9 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.api_error import ApiError +from ..types.client_closed_request_error_body import ClientClosedRequestErrorBody + + +class ClientClosedRequestError(ApiError): + def __init__(self, body: ClientClosedRequestErrorBody): + super().__init__(status_code=499, body=body) diff --git a/src/cohere/errors/gateway_timeout_error.py b/src/cohere/errors/gateway_timeout_error.py new file mode 100644 index 000000000..8d1617d80 --- /dev/null +++ b/src/cohere/errors/gateway_timeout_error.py @@ -0,0 +1,9 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.api_error import ApiError +from ..types.gateway_timeout_error_body import GatewayTimeoutErrorBody + + +class GatewayTimeoutError(ApiError): + def __init__(self, body: GatewayTimeoutErrorBody): + super().__init__(status_code=504, body=body) diff --git a/src/cohere/errors/not_implemented_error.py b/src/cohere/errors/not_implemented_error.py new file mode 100644 index 000000000..7dc79f06c --- /dev/null +++ b/src/cohere/errors/not_implemented_error.py @@ -0,0 +1,9 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.api_error import ApiError +from ..types.not_implemented_error_body import NotImplementedErrorBody + + +class NotImplementedError(ApiError): + def __init__(self, body: NotImplementedErrorBody): + super().__init__(status_code=501, body=body) diff --git a/src/cohere/errors/service_unavailable_error.py b/src/cohere/errors/service_unavailable_error.py index 4a91fb443..145a331ec 100644 --- a/src/cohere/errors/service_unavailable_error.py +++ b/src/cohere/errors/service_unavailable_error.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. +import typing + from ..core.api_error import ApiError -from ..finetuning.finetuning.types.error import Error class ServiceUnavailableError(ApiError): - def __init__(self, body: Error): + def __init__(self, body: typing.Any): super().__init__(status_code=503, body=body) diff --git a/src/cohere/errors/unauthorized_error.py b/src/cohere/errors/unauthorized_error.py index 8705a2612..e5c83f604 100644 --- a/src/cohere/errors/unauthorized_error.py +++ b/src/cohere/errors/unauthorized_error.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. +import typing + from ..core.api_error import ApiError -from ..finetuning.finetuning.types.error import Error class UnauthorizedError(ApiError): - def __init__(self, body: Error): + def __init__(self, body: typing.Any): super().__init__(status_code=401, body=body) diff --git a/src/cohere/errors/unprocessable_entity_error.py b/src/cohere/errors/unprocessable_entity_error.py new file mode 100644 index 000000000..e27104ea7 --- /dev/null +++ b/src/cohere/errors/unprocessable_entity_error.py @@ -0,0 +1,9 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.api_error import ApiError +from ..types.unprocessable_entity_error_body import UnprocessableEntityErrorBody + + +class UnprocessableEntityError(ApiError): + def __init__(self, body: UnprocessableEntityErrorBody): + super().__init__(status_code=422, body=body) diff --git a/src/cohere/finetuning/__init__.py b/src/cohere/finetuning/__init__.py index 6586a6df6..dedb901c2 100644 --- a/src/cohere/finetuning/__init__.py +++ b/src/cohere/finetuning/__init__.py @@ -6,7 +6,6 @@ BaseType, CreateFinetunedModelResponse, DeleteFinetunedModelResponse, - Error, Event, FinetunedModel, GetFinetunedModelResponse, @@ -26,7 +25,6 @@ "BaseType", "CreateFinetunedModelResponse", "DeleteFinetunedModelResponse", - "Error", "Event", "FinetunedModel", "GetFinetunedModelResponse", diff --git a/src/cohere/finetuning/client.py b/src/cohere/finetuning/client.py index d86f4c357..a157c228a 100644 --- a/src/cohere/finetuning/client.py +++ b/src/cohere/finetuning/client.py @@ -17,7 +17,6 @@ from ..errors.unauthorized_error import UnauthorizedError from .finetuning.types.create_finetuned_model_response import CreateFinetunedModelResponse from .finetuning.types.delete_finetuned_model_response import DeleteFinetunedModelResponse -from .finetuning.types.error import Error from .finetuning.types.finetuned_model import FinetunedModel from .finetuning.types.get_finetuned_model_response import GetFinetunedModelResponse from .finetuning.types.list_events_response import ListEventsResponse @@ -93,7 +92,7 @@ def list_finetuned_models( ) if _response.status_code == 401: raise UnauthorizedError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) if _response.status_code == 403: raise ForbiddenError( @@ -109,7 +108,7 @@ def list_finetuned_models( ) if _response.status_code == 503: raise ServiceUnavailableError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) try: _response_json = _response.json() @@ -165,7 +164,7 @@ def create_finetuned_model( ) if _response.status_code == 401: raise UnauthorizedError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) if _response.status_code == 403: raise ForbiddenError( @@ -181,7 +180,7 @@ def create_finetuned_model( ) if _response.status_code == 503: raise ServiceUnavailableError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) try: _response_json = _response.json() @@ -229,7 +228,7 @@ def get_finetuned_model( ) if _response.status_code == 401: raise UnauthorizedError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) if _response.status_code == 403: raise ForbiddenError( @@ -245,7 +244,7 @@ def get_finetuned_model( ) if _response.status_code == 503: raise ServiceUnavailableError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) try: _response_json = _response.json() @@ -293,7 +292,7 @@ def delete_finetuned_model( ) if _response.status_code == 401: raise UnauthorizedError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) if _response.status_code == 403: raise ForbiddenError( @@ -309,7 +308,7 @@ def delete_finetuned_model( ) if _response.status_code == 503: raise ServiceUnavailableError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) try: _response_json = _response.json() @@ -418,7 +417,7 @@ def update_finetuned_model( ) if _response.status_code == 401: raise UnauthorizedError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) if _response.status_code == 403: raise ForbiddenError( @@ -434,7 +433,7 @@ def update_finetuned_model( ) if _response.status_code == 503: raise ServiceUnavailableError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) try: _response_json = _response.json() @@ -506,7 +505,7 @@ def list_events( ) if _response.status_code == 401: raise UnauthorizedError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) if _response.status_code == 403: raise ForbiddenError( @@ -522,7 +521,7 @@ def list_events( ) if _response.status_code == 503: raise ServiceUnavailableError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) try: _response_json = _response.json() @@ -584,7 +583,7 @@ def list_training_step_metrics( ) if _response.status_code == 401: raise UnauthorizedError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) if _response.status_code == 403: raise ForbiddenError( @@ -600,7 +599,7 @@ def list_training_step_metrics( ) if _response.status_code == 503: raise ServiceUnavailableError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) try: _response_json = _response.json() @@ -671,7 +670,7 @@ async def list_finetuned_models( ) if _response.status_code == 401: raise UnauthorizedError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) if _response.status_code == 403: raise ForbiddenError( @@ -687,7 +686,7 @@ async def list_finetuned_models( ) if _response.status_code == 503: raise ServiceUnavailableError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) try: _response_json = _response.json() @@ -743,7 +742,7 @@ async def create_finetuned_model( ) if _response.status_code == 401: raise UnauthorizedError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) if _response.status_code == 403: raise ForbiddenError( @@ -759,7 +758,7 @@ async def create_finetuned_model( ) if _response.status_code == 503: raise ServiceUnavailableError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) try: _response_json = _response.json() @@ -807,7 +806,7 @@ async def get_finetuned_model( ) if _response.status_code == 401: raise UnauthorizedError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) if _response.status_code == 403: raise ForbiddenError( @@ -823,7 +822,7 @@ async def get_finetuned_model( ) if _response.status_code == 503: raise ServiceUnavailableError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) try: _response_json = _response.json() @@ -871,7 +870,7 @@ async def delete_finetuned_model( ) if _response.status_code == 401: raise UnauthorizedError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) if _response.status_code == 403: raise ForbiddenError( @@ -887,7 +886,7 @@ async def delete_finetuned_model( ) if _response.status_code == 503: raise ServiceUnavailableError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) try: _response_json = _response.json() @@ -996,7 +995,7 @@ async def update_finetuned_model( ) if _response.status_code == 401: raise UnauthorizedError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) if _response.status_code == 403: raise ForbiddenError( @@ -1012,7 +1011,7 @@ async def update_finetuned_model( ) if _response.status_code == 503: raise ServiceUnavailableError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) try: _response_json = _response.json() @@ -1084,7 +1083,7 @@ async def list_events( ) if _response.status_code == 401: raise UnauthorizedError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) if _response.status_code == 403: raise ForbiddenError( @@ -1100,7 +1099,7 @@ async def list_events( ) if _response.status_code == 503: raise ServiceUnavailableError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) try: _response_json = _response.json() @@ -1162,7 +1161,7 @@ async def list_training_step_metrics( ) if _response.status_code == 401: raise UnauthorizedError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) if _response.status_code == 403: raise ForbiddenError( @@ -1178,7 +1177,7 @@ async def list_training_step_metrics( ) if _response.status_code == 503: raise ServiceUnavailableError( - typing.cast(Error, construct_type(type_=Error, object_=_response.json())) # type: ignore + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) try: _response_json = _response.json() diff --git a/src/cohere/finetuning/finetuning/__init__.py b/src/cohere/finetuning/finetuning/__init__.py index 0a8880915..97857724d 100644 --- a/src/cohere/finetuning/finetuning/__init__.py +++ b/src/cohere/finetuning/finetuning/__init__.py @@ -5,7 +5,6 @@ BaseType, CreateFinetunedModelResponse, DeleteFinetunedModelResponse, - Error, Event, FinetunedModel, GetFinetunedModelResponse, @@ -25,7 +24,6 @@ "BaseType", "CreateFinetunedModelResponse", "DeleteFinetunedModelResponse", - "Error", "Event", "FinetunedModel", "GetFinetunedModelResponse", diff --git a/src/cohere/finetuning/finetuning/types/__init__.py b/src/cohere/finetuning/finetuning/types/__init__.py index 1c2576ed6..00bdc6ba5 100644 --- a/src/cohere/finetuning/finetuning/types/__init__.py +++ b/src/cohere/finetuning/finetuning/types/__init__.py @@ -4,7 +4,6 @@ from .base_type import BaseType from .create_finetuned_model_response import CreateFinetunedModelResponse from .delete_finetuned_model_response import DeleteFinetunedModelResponse -from .error import Error from .event import Event from .finetuned_model import FinetunedModel from .get_finetuned_model_response import GetFinetunedModelResponse @@ -23,7 +22,6 @@ "BaseType", "CreateFinetunedModelResponse", "DeleteFinetunedModelResponse", - "Error", "Event", "FinetunedModel", "GetFinetunedModelResponse", diff --git a/src/cohere/models/client.py b/src/cohere/models/client.py index a095c954f..743b0bae2 100644 --- a/src/cohere/models/client.py +++ b/src/cohere/models/client.py @@ -9,12 +9,24 @@ from ..core.request_options import RequestOptions from ..core.unchecked_base_model import construct_type from ..errors.bad_request_error import BadRequestError +from ..errors.client_closed_request_error import ClientClosedRequestError +from ..errors.forbidden_error import ForbiddenError +from ..errors.gateway_timeout_error import GatewayTimeoutError from ..errors.internal_server_error import InternalServerError +from ..errors.not_found_error import NotFoundError +from ..errors.not_implemented_error import NotImplementedError +from ..errors.service_unavailable_error import ServiceUnavailableError from ..errors.too_many_requests_error import TooManyRequestsError +from ..errors.unauthorized_error import UnauthorizedError +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.client_closed_request_error_body import ClientClosedRequestErrorBody from ..types.compatible_endpoint import CompatibleEndpoint +from ..types.gateway_timeout_error_body import GatewayTimeoutErrorBody from ..types.get_model_response import GetModelResponse from ..types.list_models_response import ListModelsResponse +from ..types.not_implemented_error_body import NotImplementedErrorBody from ..types.too_many_requests_error_body import TooManyRequestsErrorBody +from ..types.unprocessable_entity_error_body import UnprocessableEntityErrorBody class ModelsClient: @@ -58,14 +70,46 @@ def get(self, model: str, *, request_options: typing.Optional[RequestOptions] = raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -130,10 +174,50 @@ def list( ) if 200 <= _response.status_code < 300: return typing.cast(ListModelsResponse, construct_type(type_=ListModelsResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -182,14 +266,46 @@ async def get(self, model: str, *, request_options: typing.Optional[RequestOptio raise BadRequestError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 500: raise InternalServerError( typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -254,10 +370,50 @@ async def list( ) if 200 <= _response.status_code < 300: return typing.cast(ListModelsResponse, construct_type(type_=ListModelsResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast(UnprocessableEntityErrorBody, construct_type(type_=UnprocessableEntityErrorBody, object_=_response.json())) # type: ignore + ) if _response.status_code == 429: raise TooManyRequestsError( typing.cast(TooManyRequestsErrorBody, construct_type(type_=TooManyRequestsErrorBody, object_=_response.json())) # type: ignore ) + if _response.status_code == 499: + raise ClientClosedRequestError( + typing.cast(ClientClosedRequestErrorBody, construct_type(type_=ClientClosedRequestErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 500: + raise InternalServerError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 501: + raise NotImplementedError( + typing.cast(NotImplementedErrorBody, construct_type(type_=NotImplementedErrorBody, object_=_response.json())) # type: ignore + ) + if _response.status_code == 503: + raise ServiceUnavailableError( + typing.cast(typing.Any, construct_type(type_=typing.Any, object_=_response.json())) # type: ignore + ) + if _response.status_code == 504: + raise GatewayTimeoutError( + typing.cast(GatewayTimeoutErrorBody, construct_type(type_=GatewayTimeoutErrorBody, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/cohere/types/__init__.py b/src/cohere/types/__init__.py index 81e472c60..cfec734ad 100644 --- a/src/cohere/types/__init__.py +++ b/src/cohere/types/__init__.py @@ -39,6 +39,7 @@ ClassifyResponseClassificationsItemClassificationType, ) from .classify_response_classifications_item_labels_value import ClassifyResponseClassificationsItemLabelsValue +from .client_closed_request_error_body import ClientClosedRequestErrorBody from .compatible_endpoint import CompatibleEndpoint from .connector import Connector from .connector_auth_status import ConnectorAuthStatus @@ -65,6 +66,7 @@ from .embedding_type import EmbeddingType from .finetune_dataset_metrics import FinetuneDatasetMetrics from .finish_reason import FinishReason +from .gateway_timeout_error_body import GatewayTimeoutErrorBody from .generate_request_return_likelihoods import GenerateRequestReturnLikelihoods from .generate_request_truncate import GenerateRequestTruncate from .generate_stream_end import GenerateStreamEnd @@ -92,6 +94,7 @@ from .metrics_embed_data import MetricsEmbedData from .metrics_embed_data_fields_item import MetricsEmbedDataFieldsItem from .non_streamed_chat_response import NonStreamedChatResponse +from .not_implemented_error_body import NotImplementedErrorBody from .o_auth_authorize_response import OAuthAuthorizeResponse from .parse_info import ParseInfo from .rerank_request_documents_item import RerankRequestDocumentsItem @@ -126,6 +129,7 @@ from .tool_message import ToolMessage from .tool_parameter_definitions_value import ToolParameterDefinitionsValue from .tool_result import ToolResult +from .unprocessable_entity_error_body import UnprocessableEntityErrorBody from .update_connector_response import UpdateConnectorResponse __all__ = [ @@ -166,6 +170,7 @@ "ClassifyResponseClassificationsItem", "ClassifyResponseClassificationsItemClassificationType", "ClassifyResponseClassificationsItemLabelsValue", + "ClientClosedRequestErrorBody", "CompatibleEndpoint", "Connector", "ConnectorAuthStatus", @@ -194,6 +199,7 @@ "EmbeddingType", "FinetuneDatasetMetrics", "FinishReason", + "GatewayTimeoutErrorBody", "GenerateRequestReturnLikelihoods", "GenerateRequestTruncate", "GenerateStreamEnd", @@ -223,6 +229,7 @@ "MetricsEmbedData", "MetricsEmbedDataFieldsItem", "NonStreamedChatResponse", + "NotImplementedErrorBody", "OAuthAuthorizeResponse", "ParseInfo", "RerankRequestDocumentsItem", @@ -255,5 +262,6 @@ "ToolMessage", "ToolParameterDefinitionsValue", "ToolResult", + "UnprocessableEntityErrorBody", "UpdateConnectorResponse", ] diff --git a/src/cohere/finetuning/finetuning/types/error.py b/src/cohere/types/client_closed_request_error_body.py similarity index 68% rename from src/cohere/finetuning/finetuning/types/error.py rename to src/cohere/types/client_closed_request_error_body.py index ba4a12a31..e1bf5580f 100644 --- a/src/cohere/finetuning/finetuning/types/error.py +++ b/src/cohere/types/client_closed_request_error_body.py @@ -3,20 +3,13 @@ import datetime as dt import typing -from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from ....core.unchecked_base_model import UncheckedBaseModel +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ..core.unchecked_base_model import UncheckedBaseModel -class Error(UncheckedBaseModel): - """ - Error is the response for any unsuccessful event. - """ - - message: typing.Optional[str] = pydantic_v1.Field(default=None) - """ - A developer-facing error message. - """ +class ClientClosedRequestErrorBody(UncheckedBaseModel): + data: typing.Optional[str] = None def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} diff --git a/src/cohere/types/gateway_timeout_error_body.py b/src/cohere/types/gateway_timeout_error_body.py new file mode 100644 index 000000000..dd8de6bff --- /dev/null +++ b/src/cohere/types/gateway_timeout_error_body.py @@ -0,0 +1,30 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ..core.unchecked_base_model import UncheckedBaseModel + + +class GatewayTimeoutErrorBody(UncheckedBaseModel): + data: typing.Optional[str] = None + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/cohere/types/not_implemented_error_body.py b/src/cohere/types/not_implemented_error_body.py new file mode 100644 index 000000000..4a6834dcf --- /dev/null +++ b/src/cohere/types/not_implemented_error_body.py @@ -0,0 +1,30 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ..core.unchecked_base_model import UncheckedBaseModel + + +class NotImplementedErrorBody(UncheckedBaseModel): + data: typing.Optional[str] = None + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/cohere/types/tool_call_delta.py b/src/cohere/types/tool_call_delta.py index 3b5f5fc73..7c56613c3 100644 --- a/src/cohere/types/tool_call_delta.py +++ b/src/cohere/types/tool_call_delta.py @@ -28,6 +28,11 @@ class ToolCallDelta(UncheckedBaseModel): Chunk of the tool parameters """ + text: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Chunk of the tool plan text + """ + def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) diff --git a/src/cohere/types/unprocessable_entity_error_body.py b/src/cohere/types/unprocessable_entity_error_body.py new file mode 100644 index 000000000..296c0c4f7 --- /dev/null +++ b/src/cohere/types/unprocessable_entity_error_body.py @@ -0,0 +1,30 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ..core.unchecked_base_model import UncheckedBaseModel + + +class UnprocessableEntityErrorBody(UncheckedBaseModel): + data: typing.Optional[str] = None + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime}