diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 161548ef..6c82dca2 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -3,10 +3,10 @@ id: 8b5fa338-9106-4734-abf0-e30d67044a90 management: docChecksum: 21f469b38bb72725739ee9d9d0fc8780 docVersion: 1.0.51 - speakeasyVersion: 1.418.1 - generationVersion: 2.438.3 - releaseVersion: 0.26.1 - configChecksum: 55ded3ef4f1b052725cdab6587da0ea4 + speakeasyVersion: 1.422.1 + generationVersion: 2.438.15 + releaseVersion: 0.26.2 + configChecksum: c46fa7f108a08d4565530aa29da677b5 repoURL: https://github.com/Unstructured-IO/unstructured-python-client.git repoSubDirectory: . installationURL: https://github.com/Unstructured-IO/unstructured-python-client.git diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 57722445..c141ae22 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,8 +1,8 @@ -speakeasyVersion: 1.418.1 +speakeasyVersion: 1.422.1 sources: my-source: sourceNamespace: my-source - sourceRevisionDigest: sha256:a820d523af3e56f0dd1fc84f4f29e15330edb26cc253e93981bddb4a5176ac3c + sourceRevisionDigest: sha256:31c94056ebc941cdfcf3fd4ba5e04880e978740963f7ce79169ba66cd033d74d sourceBlobDigest: sha256:27e4879df402e924f9f65d336ea6d2fc8b16a00b87b4a802866238f7e9f639d3 tags: - latest @@ -11,7 +11,7 @@ targets: unstructured-python: source: my-source sourceNamespace: my-source - sourceRevisionDigest: sha256:a820d523af3e56f0dd1fc84f4f29e15330edb26cc253e93981bddb4a5176ac3c + sourceRevisionDigest: sha256:31c94056ebc941cdfcf3fd4ba5e04880e978740963f7ce79169ba66cd033d74d sourceBlobDigest: sha256:27e4879df402e924f9f65d336ea6d2fc8b16a00b87b4a802866238f7e9f639d3 workflow: workflowVersion: 1.0.0 diff --git a/RELEASES.md b/RELEASES.md index 31d1b953..c61c51b4 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -704,4 +704,14 @@ Based on: ### Generated - [python v0.26.1] . ### Releases -- [PyPI v0.26.1] https://pypi.org/project/unstructured-client/0.26.1 - . \ No newline at end of file +- [PyPI v0.26.1] https://pypi.org/project/unstructured-client/0.26.1 - . + +## 2024-10-28 00:09:56 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.422.1 (2.438.15) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.26.2] . +### Releases +- [PyPI v0.26.2] https://pypi.org/project/unstructured-client/0.26.2 - . \ No newline at end of file diff --git a/gen.yaml b/gen.yaml index 9f242398..e1839039 100644 --- a/gen.yaml +++ b/gen.yaml @@ -10,7 +10,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: false python: - version: 0.26.1 + version: 0.26.2 additionalDependencies: dev: deepdiff: '>=6.0' diff --git a/pyproject.toml b/pyproject.toml index 0acb1067..1c78af7c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "unstructured-client" -version = "0.26.1" +version = "0.26.2" description = "Python Client SDK for Unstructured API" authors = ["Unstructured",] readme = "README-PYPI.md" diff --git a/src/unstructured_client/_version.py b/src/unstructured_client/_version.py index bad8f5de..e13ade30 100644 --- a/src/unstructured_client/_version.py +++ b/src/unstructured_client/_version.py @@ -3,7 +3,7 @@ import importlib.metadata __title__: str = "unstructured-client" -__version__: str = "0.26.1" +__version__: str = "0.26.2" try: if __package__ is not None: diff --git a/src/unstructured_client/general.py b/src/unstructured_client/general.py index f7019d57..adc4a6ab 100644 --- a/src/unstructured_client/general.py +++ b/src/unstructured_client/general.py @@ -99,18 +99,20 @@ def partition( data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) if utils.match_response(http_res, "4XX", "*"): + http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( - "API error occurred", http_res.status_code, http_res.text, http_res + "API error occurred", http_res.status_code, http_res_text, http_res ) if utils.match_response(http_res, "5XX", "application/json"): data = utils.unmarshal_json(http_res.text, errors.ServerErrorData) raise errors.ServerError(data=data) content_type = http_res.headers.get("Content-Type") + http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, - http_res.text, + http_res_text, http_res, ) @@ -204,17 +206,19 @@ async def partition_async( data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) if utils.match_response(http_res, "4XX", "*"): + http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( - "API error occurred", http_res.status_code, http_res.text, http_res + "API error occurred", http_res.status_code, http_res_text, http_res ) if utils.match_response(http_res, "5XX", "application/json"): data = utils.unmarshal_json(http_res.text, errors.ServerErrorData) raise errors.ServerError(data=data) content_type = http_res.headers.get("Content-Type") + http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, - http_res.text, + http_res_text, http_res, ) diff --git a/src/unstructured_client/sdkconfiguration.py b/src/unstructured_client/sdkconfiguration.py index 1a363e2d..0bb9ae83 100644 --- a/src/unstructured_client/sdkconfiguration.py +++ b/src/unstructured_client/sdkconfiguration.py @@ -34,9 +34,9 @@ class SDKConfiguration: server: Optional[str] = "" language: str = "python" openapi_doc_version: str = "1.0.51" - sdk_version: str = "0.26.1" - gen_version: str = "2.438.3" - user_agent: str = "speakeasy-sdk/python 0.26.1 2.438.3 1.0.51 unstructured-client" + sdk_version: str = "0.26.2" + gen_version: str = "2.438.15" + user_agent: str = "speakeasy-sdk/python 0.26.2 2.438.15 1.0.51 unstructured-client" retry_config: OptionalNullable[RetryConfig] = Field(default_factory=lambda: UNSET) timeout_ms: Optional[int] = None diff --git a/src/unstructured_client/utils/__init__.py b/src/unstructured_client/utils/__init__.py index d248ebc9..26d51ae8 100644 --- a/src/unstructured_client/utils/__init__.py +++ b/src/unstructured_client/utils/__init__.py @@ -27,6 +27,9 @@ serialize_float, serialize_int, stream_to_text, + stream_to_text_async, + stream_to_bytes, + stream_to_bytes_async, validate_const, validate_decimal, validate_float, @@ -80,6 +83,9 @@ "serialize_request_body", "SerializedRequestBody", "stream_to_text", + "stream_to_text_async", + "stream_to_bytes", + "stream_to_bytes_async", "template_url", "unmarshal", "unmarshal_json", diff --git a/src/unstructured_client/utils/serializers.py b/src/unstructured_client/utils/serializers.py index 605133c7..c5eb3659 100644 --- a/src/unstructured_client/utils/serializers.py +++ b/src/unstructured_client/utils/serializers.py @@ -185,6 +185,18 @@ def stream_to_text(stream: httpx.Response) -> str: return "".join(stream.iter_text()) +async def stream_to_text_async(stream: httpx.Response) -> str: + return "".join([chunk async for chunk in stream.aiter_text()]) + + +def stream_to_bytes(stream: httpx.Response) -> bytes: + return stream.content + + +async def stream_to_bytes_async(stream: httpx.Response) -> bytes: + return await stream.aread() + + def get_pydantic_model(data: Any, typ: Any) -> Any: if not _contains_pydantic_model(data): return unmarshal(data, typ)