From 9bc86b446608d49901ef8caebdd72ec2f9c04340 Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Wed, 26 Feb 2025 21:31:09 +0000 Subject: [PATCH 1/3] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.505.0 --- .speakeasy/gen.lock | 16 ++++----- .speakeasy/workflow.lock | 14 ++++---- README.md | 39 +++++++++++++++----- RELEASES.md | 10 ++++++ USAGE.md | 10 ++++-- codeSamples.yaml | 40 ++++++++++----------- docs/sdks/destinations/README.md | 25 ++++++++++--- docs/sdks/general/README.md | 5 ++- docs/sdks/jobs/README.md | 15 ++++++-- docs/sdks/sources/README.md | 25 ++++++++++--- docs/sdks/workflows/README.md | 30 ++++++++++++---- gen.yaml | 5 ++- pyproject.toml | 2 +- src/unstructured_client/_version.py | 6 ++-- src/unstructured_client/basesdk.py | 8 +++++ src/unstructured_client/httpclient.py | 6 ++-- src/unstructured_client/sdk.py | 32 +++++++++++------ src/unstructured_client/sdkconfiguration.py | 11 +++--- src/unstructured_client/utils/__init__.py | 2 ++ src/unstructured_client/utils/values.py | 5 ++- 20 files changed, 214 insertions(+), 92 deletions(-) diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index ef835b94..96d37100 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 8b5fa338-9106-4734-abf0-e30d67044a90 management: - docChecksum: 0f9100e28d13105be2af4e576ea4572c + docChecksum: c20df03926ecb29814c3c1c36c99ddae docVersion: 1.0.68 - speakeasyVersion: 1.490.0 - generationVersion: 2.512.0 - releaseVersion: 0.30.5 - configChecksum: 25a75f7add3305b685de164ad454cb9a + speakeasyVersion: 1.505.0 + generationVersion: 2.531.0 + releaseVersion: 0.31.0 + configChecksum: faf5191e78f1597b78cd7600af4f1d96 repoURL: https://github.com/Unstructured-IO/unstructured-python-client.git repoSubDirectory: . installationURL: https://github.com/Unstructured-IO/unstructured-python-client.git @@ -16,7 +16,7 @@ features: acceptHeaders: 3.0.0 additionalDependencies: 1.0.0 constsAndDefaults: 1.0.5 - core: 5.11.0 + core: 5.12.1 defaultEnabledRetries: 0.2.0 enumUnions: 0.1.0 envVarSecurityUsage: 0.3.2 @@ -27,11 +27,11 @@ features: methodServerURLs: 3.1.1 multipartFileContentType: 1.0.0 nameOverrides: 3.0.1 - nullables: 1.0.0 + nullables: 1.0.1 openEnums: 1.0.0 responseFormat: 1.0.1 retries: 3.0.2 - sdkHooks: 1.0.0 + sdkHooks: 1.0.1 serverIDs: 3.0.0 unions: 3.0.4 uploadStreams: 1.0.0 diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index b5b27aa7..b0d3c49b 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,21 +1,21 @@ -speakeasyVersion: 1.504.1 +speakeasyVersion: 1.505.0 sources: my-source: sourceNamespace: my-source - sourceRevisionDigest: sha256:4f63229dca06781c54905bcb9c2769ef714dccbd7b347d72ed6b9c0a57f768f9 - sourceBlobDigest: sha256:24d7c75ebda9119f02eec391b4ac5697e7f909341f1694177d9d164ff90e39be + sourceRevisionDigest: sha256:8cba0cf748e247efccefbb5d1839dbeb6e2e3210bb2c90f7b75b9034c22ae24a + sourceBlobDigest: sha256:69fef8ed681f1d68013e71f67927821d64fc1045d3956ace3775fe62ed76b8bb tags: - latest - - speakeasy-sdk-regen-1740499439 + - speakeasy-sdk-regen-1740605410 - 1.0.68 targets: unstructured-python: source: my-source sourceNamespace: my-source - sourceRevisionDigest: sha256:4f63229dca06781c54905bcb9c2769ef714dccbd7b347d72ed6b9c0a57f768f9 - sourceBlobDigest: sha256:24d7c75ebda9119f02eec391b4ac5697e7f909341f1694177d9d164ff90e39be + sourceRevisionDigest: sha256:8cba0cf748e247efccefbb5d1839dbeb6e2e3210bb2c90f7b75b9034c22ae24a + sourceBlobDigest: sha256:69fef8ed681f1d68013e71f67927821d64fc1045d3956ace3775fe62ed76b8bb codeSamplesNamespace: my-source-code-samples - codeSamplesRevisionDigest: sha256:c7f49ae4ef636cb4f1f872f62dbec7312d7cff92d59e1de774428843f0474b91 + codeSamplesRevisionDigest: sha256:d7a20fe1c8d687f377099cdb412c6d0dd733dd982ec4662052df0894da211da2 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/README.md b/README.md index fff05426..2f8354ad 100755 --- a/README.md +++ b/README.md @@ -113,7 +113,10 @@ from unstructured_client import UnstructuredClient from unstructured_client.models import shared from unstructured_client.utils import BackoffStrategy, RetryConfig -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.destinations.create_destination(request={ "create_destination_connector": { @@ -141,7 +144,9 @@ from unstructured_client import UnstructuredClient from unstructured_client.models import shared from unstructured_client.utils import BackoffStrategy, RetryConfig + with UnstructuredClient( + server_url="https://api.example.com", retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False), ) as uc_client: @@ -193,7 +198,10 @@ When custom error responses are specified for an operation, the SDK may also rai from unstructured_client import UnstructuredClient from unstructured_client.models import errors, shared -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = None try: @@ -325,7 +333,10 @@ Generally, the SDK will work well with most IDEs out of the box. However, when u from unstructured_client import UnstructuredClient from unstructured_client.models import shared -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.destinations.create_destination(request={ "create_destination_connector": { @@ -355,7 +366,10 @@ from unstructured_client import UnstructuredClient from unstructured_client.models import shared async def main(): - async with UnstructuredClient() as uc_client: + + async with UnstructuredClient( + server_url="https://api.example.com", + ) as uc_client: res = await uc_client.destinations.create_destination_async(request={ "create_destination_connector": { @@ -450,7 +464,10 @@ Certain SDK methods accept file objects as part of a request body or multi-part ```python from unstructured_client import UnstructuredClient -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.general.partition(request={ "partition_parameters": { @@ -483,13 +500,19 @@ The `UnstructuredClient` class implements the context manager protocol and regis ```python from unstructured_client import UnstructuredClient def main(): - with UnstructuredClient() as uc_client: + + with UnstructuredClient( + server_url="https://api.example.com", + ) as uc_client: # Rest of application here... # Or when using async: async def amain(): - async with UnstructuredClient() as uc_client: + + async with UnstructuredClient( + server_url="https://api.example.com", + ) as uc_client: # Rest of application here... ``` @@ -505,7 +528,7 @@ from unstructured_client import UnstructuredClient import logging logging.basicConfig(level=logging.DEBUG) -s = UnstructuredClient(debug_logger=logging.getLogger("unstructured_client")) +s = UnstructuredClient(server_url="https://example.com", debug_logger=logging.getLogger("unstructured_client")) ``` diff --git a/RELEASES.md b/RELEASES.md index 24787505..c56b711a 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -824,4 +824,14 @@ Based on: ### Generated - [python v0.31.0] . ### Releases +- [PyPI v0.31.0] https://pypi.org/project/unstructured-client/0.31.0 - . + +## 2025-02-26 21:29:54 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.505.0 (2.531.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.31.0] . +### Releases - [PyPI v0.31.0] https://pypi.org/project/unstructured-client/0.31.0 - . \ No newline at end of file diff --git a/USAGE.md b/USAGE.md index 808460d6..4151cac7 100644 --- a/USAGE.md +++ b/USAGE.md @@ -4,7 +4,10 @@ from unstructured_client import UnstructuredClient from unstructured_client.models import shared -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.destinations.create_destination(request={ "create_destination_connector": { @@ -34,7 +37,10 @@ from unstructured_client import UnstructuredClient from unstructured_client.models import shared async def main(): - async with UnstructuredClient() as uc_client: + + async with UnstructuredClient( + server_url="https://api.example.com", + ) as uc_client: res = await uc_client.destinations.create_destination_async(request={ "create_destination_connector": { diff --git a/codeSamples.yaml b/codeSamples.yaml index ced172de..37e062dc 100644 --- a/codeSamples.yaml +++ b/codeSamples.yaml @@ -8,118 +8,118 @@ actions: "x-codeSamples": - "lang": "python" "label": "list_destinations" - "source": "from unstructured_client import UnstructuredClient\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.destinations.list_destinations(request={})\n\n assert res.response_list_destinations is not None\n\n # Handle response\n print(res.response_list_destinations)" + "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.destinations.list_destinations(request={})\n\n assert res.response_list_destinations is not None\n\n # Handle response\n print(res.response_list_destinations)" - target: $["paths"]["/api/v1/destinations/"]["post"] update: "x-codeSamples": - "lang": "python" "label": "create_destination" - "source": "from unstructured_client import UnstructuredClient\nfrom unstructured_client.models import shared\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.destinations.create_destination(request={\n \"create_destination_connector\": {\n \"name\": \"\",\n \"type\": shared.DestinationConnectorType.AZURE_AI_SEARCH,\n \"config\": {\n \"collection_name\": \"\",\n \"batch_size\": 20,\n \"api_endpoint\": \"\",\n \"token\": \"\",\n },\n },\n })\n\n assert res.destination_connector_information is not None\n\n # Handle response\n print(res.destination_connector_information)" + "source": "from unstructured_client import UnstructuredClient\nfrom unstructured_client.models import shared\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.destinations.create_destination(request={\n \"create_destination_connector\": {\n \"name\": \"\",\n \"type\": shared.DestinationConnectorType.AZURE_AI_SEARCH,\n \"config\": {\n \"collection_name\": \"\",\n \"batch_size\": 20,\n \"api_endpoint\": \"\",\n \"token\": \"\",\n },\n },\n })\n\n assert res.destination_connector_information is not None\n\n # Handle response\n print(res.destination_connector_information)" - target: $["paths"]["/api/v1/destinations/{destination_id}"]["delete"] update: "x-codeSamples": - "lang": "python" "label": "delete_destination" - "source": "from unstructured_client import UnstructuredClient\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.destinations.delete_destination(request={\n \"destination_id\": \"10a88d76-65fb-4c88-8488-9e7d272c6373\",\n })\n\n assert res.any is not None\n\n # Handle response\n print(res.any)" + "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.destinations.delete_destination(request={\n \"destination_id\": \"10a88d76-65fb-4c88-8488-9e7d272c6373\",\n })\n\n assert res.any is not None\n\n # Handle response\n print(res.any)" - target: $["paths"]["/api/v1/destinations/{destination_id}"]["get"] update: "x-codeSamples": - "lang": "python" "label": "get_destination" - "source": "from unstructured_client import UnstructuredClient\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.destinations.get_destination(request={\n \"destination_id\": \"41ba03fb-faa3-4e9e-8cfb-27f133c4198a\",\n })\n\n assert res.destination_connector_information is not None\n\n # Handle response\n print(res.destination_connector_information)" + "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.destinations.get_destination(request={\n \"destination_id\": \"41ba03fb-faa3-4e9e-8cfb-27f133c4198a\",\n })\n\n assert res.destination_connector_information is not None\n\n # Handle response\n print(res.destination_connector_information)" - target: $["paths"]["/api/v1/destinations/{destination_id}"]["put"] update: "x-codeSamples": - "lang": "python" "label": "update_destination" - "source": "from unstructured_client import UnstructuredClient\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.destinations.update_destination(request={\n \"destination_id\": \"9ea9d27c-4e2e-4cb5-9a69-71bd7ec9d226\",\n \"update_destination_connector\": {\n \"config\": {\n \"host\": \"acidic-patroller.com\",\n \"database\": \"\",\n \"port\": 832931,\n \"username\": \"Salvador.Walsh-Thiel\",\n \"password\": \"vIMqbllzrdJBExE\",\n \"table_name\": \"\",\n \"batch_size\": 977983,\n },\n },\n })\n\n assert res.destination_connector_information is not None\n\n # Handle response\n print(res.destination_connector_information)" + "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.destinations.update_destination(request={\n \"destination_id\": \"9ea9d27c-4e2e-4cb5-9a69-71bd7ec9d226\",\n \"update_destination_connector\": {\n \"config\": {\n \"host\": \"acidic-patroller.com\",\n \"database\": \"\",\n \"port\": 832931,\n \"username\": \"Salvador.Walsh-Thiel\",\n \"password\": \"vIMqbllzrdJBExE\",\n \"table_name\": \"\",\n \"batch_size\": 977983,\n },\n },\n })\n\n assert res.destination_connector_information is not None\n\n # Handle response\n print(res.destination_connector_information)" - target: $["paths"]["/api/v1/jobs/"]["get"] update: "x-codeSamples": - "lang": "python" "label": "list_jobs" - "source": "from unstructured_client import UnstructuredClient\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.jobs.list_jobs(request={})\n\n assert res.response_list_jobs is not None\n\n # Handle response\n print(res.response_list_jobs)" + "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.jobs.list_jobs(request={})\n\n assert res.response_list_jobs is not None\n\n # Handle response\n print(res.response_list_jobs)" - target: $["paths"]["/api/v1/jobs/{job_id}"]["get"] update: "x-codeSamples": - "lang": "python" "label": "get_job" - "source": "from unstructured_client import UnstructuredClient\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.jobs.get_job(request={\n \"job_id\": \"6bb4cb72-a072-4398-9de3-194e59352a3c\",\n })\n\n assert res.job_information is not None\n\n # Handle response\n print(res.job_information)" + "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.jobs.get_job(request={\n \"job_id\": \"6bb4cb72-a072-4398-9de3-194e59352a3c\",\n })\n\n assert res.job_information is not None\n\n # Handle response\n print(res.job_information)" - target: $["paths"]["/api/v1/jobs/{job_id}/cancel"]["post"] update: "x-codeSamples": - "lang": "python" "label": "cancel_job" - "source": "from unstructured_client import UnstructuredClient\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.jobs.cancel_job(request={\n \"job_id\": \"ec29bf67-0f30-4793-b5ee-8fc0da196032\",\n })\n\n assert res.any is not None\n\n # Handle response\n print(res.any)" + "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.jobs.cancel_job(request={\n \"job_id\": \"ec29bf67-0f30-4793-b5ee-8fc0da196032\",\n })\n\n assert res.any is not None\n\n # Handle response\n print(res.any)" - target: $["paths"]["/api/v1/sources/"]["get"] update: "x-codeSamples": - "lang": "python" "label": "list_sources" - "source": "from unstructured_client import UnstructuredClient\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.sources.list_sources(request={})\n\n assert res.response_list_sources is not None\n\n # Handle response\n print(res.response_list_sources)" + "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.sources.list_sources(request={})\n\n assert res.response_list_sources is not None\n\n # Handle response\n print(res.response_list_sources)" - target: $["paths"]["/api/v1/sources/"]["post"] update: "x-codeSamples": - "lang": "python" "label": "create_source" - "source": "from unstructured_client import UnstructuredClient\nfrom unstructured_client.models import shared\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.sources.create_source(request={\n \"create_source_connector\": {\n \"name\": \"\",\n \"type\": shared.SourceConnectorType.SALESFORCE,\n \"config\": {\n \"username\": \"Eldora_Casper\",\n \"consumer_key\": \"\",\n \"private_key\": \"\",\n \"categories\": [\n \"\",\n ],\n },\n },\n })\n\n assert res.source_connector_information is not None\n\n # Handle response\n print(res.source_connector_information)" + "source": "from unstructured_client import UnstructuredClient\nfrom unstructured_client.models import shared\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.sources.create_source(request={\n \"create_source_connector\": {\n \"name\": \"\",\n \"type\": shared.SourceConnectorType.S3,\n \"config\": {\n \"username\": \"Eldora_Casper\",\n \"consumer_key\": \"\",\n \"private_key\": \"\",\n \"categories\": [\n \"\",\n ],\n },\n },\n })\n\n assert res.source_connector_information is not None\n\n # Handle response\n print(res.source_connector_information)" - target: $["paths"]["/api/v1/sources/{source_id}"]["delete"] update: "x-codeSamples": - "lang": "python" "label": "delete_source" - "source": "from unstructured_client import UnstructuredClient\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.sources.delete_source(request={\n \"source_id\": \"8a24d7ae-5524-45e9-83f9-b0adba5303d4\",\n })\n\n assert res.any is not None\n\n # Handle response\n print(res.any)" + "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.sources.delete_source(request={\n \"source_id\": \"8a24d7ae-5524-45e9-83f9-b0adba5303d4\",\n })\n\n assert res.any is not None\n\n # Handle response\n print(res.any)" - target: $["paths"]["/api/v1/sources/{source_id}"]["get"] update: "x-codeSamples": - "lang": "python" "label": "get_source" - "source": "from unstructured_client import UnstructuredClient\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.sources.get_source(request={\n \"source_id\": \"e02d8147-b614-4e4c-9c6d-0cd9c4492ea0\",\n })\n\n assert res.source_connector_information is not None\n\n # Handle response\n print(res.source_connector_information)" + "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.sources.get_source(request={\n \"source_id\": \"e02d8147-b614-4e4c-9c6d-0cd9c4492ea0\",\n })\n\n assert res.source_connector_information is not None\n\n # Handle response\n print(res.source_connector_information)" - target: $["paths"]["/api/v1/sources/{source_id}"]["put"] update: "x-codeSamples": - "lang": "python" "label": "update_source" - "source": "from unstructured_client import UnstructuredClient\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.sources.update_source(request={\n \"source_id\": \"196d27d0-3173-4749-b69d-2ee5d8e2396e\",\n \"update_source_connector\": {\n \"config\": {\n \"client_id\": \"\",\n \"client_cred\": \"\",\n \"recursive\": False,\n \"user_email\": \"\",\n },\n },\n })\n\n assert res.source_connector_information is not None\n\n # Handle response\n print(res.source_connector_information)" + "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.sources.update_source(request={\n \"source_id\": \"7d031737-4969-4d2e-ae5d-8e2396edec43\",\n \"update_source_connector\": {\n \"config\": {\n \"client_id\": \"\",\n \"tenant\": \"\",\n \"authority_url\": \"https://pleasing-hammock.org/\",\n \"user_pname\": \"\",\n \"client_cred\": \"\",\n \"recursive\": False,\n \"path\": \"/etc/namedb\",\n },\n },\n })\n\n assert res.source_connector_information is not None\n\n # Handle response\n print(res.source_connector_information)" - target: $["paths"]["/api/v1/workflows/"]["get"] update: "x-codeSamples": - "lang": "python" "label": "list_workflows" - "source": "from unstructured_client import UnstructuredClient\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.workflows.list_workflows(request={})\n\n assert res.response_list_workflows is not None\n\n # Handle response\n print(res.response_list_workflows)" + "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.workflows.list_workflows(request={})\n\n assert res.response_list_workflows is not None\n\n # Handle response\n print(res.response_list_workflows)" - target: $["paths"]["/api/v1/workflows/"]["post"] update: "x-codeSamples": - "lang": "python" "label": "create_workflow" - "source": "from unstructured_client import UnstructuredClient\nfrom unstructured_client.models import shared\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.workflows.create_workflow(request={\n \"create_workflow\": {\n \"name\": \"\",\n \"source_id\": \"b5baba90-bc88-4ea4-b45f-e894788e3f38\",\n \"destination_id\": \"0efa0612-4dfe-411e-b84d-d7cfa1e3fe9e\",\n \"workflow_type\": shared.WorkflowType.ADVANCED,\n },\n })\n\n assert res.workflow_information is not None\n\n # Handle response\n print(res.workflow_information)" + "source": "from unstructured_client import UnstructuredClient\nfrom unstructured_client.models import shared\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.workflows.create_workflow(request={\n \"create_workflow\": {\n \"name\": \"\",\n \"source_id\": \"b5baba90-bc88-4ea4-b45f-e894788e3f38\",\n \"destination_id\": \"0efa0612-4dfe-411e-b84d-d7cfa1e3fe9e\",\n \"workflow_type\": shared.WorkflowType.ADVANCED,\n },\n })\n\n assert res.workflow_information is not None\n\n # Handle response\n print(res.workflow_information)" - target: $["paths"]["/api/v1/workflows/{workflow_id}"]["delete"] update: "x-codeSamples": - "lang": "python" "label": "delete_workflow" - "source": "from unstructured_client import UnstructuredClient\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.workflows.delete_workflow(request={\n \"workflow_id\": \"26c0bd77-269e-4239-86b8-71541359440c\",\n })\n\n assert res.any is not None\n\n # Handle response\n print(res.any)" + "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.workflows.delete_workflow(request={\n \"workflow_id\": \"26c0bd77-269e-4239-86b8-71541359440c\",\n })\n\n assert res.any is not None\n\n # Handle response\n print(res.any)" - target: $["paths"]["/api/v1/workflows/{workflow_id}"]["get"] update: "x-codeSamples": - "lang": "python" "label": "get_workflow" - "source": "from unstructured_client import UnstructuredClient\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.workflows.get_workflow(request={\n \"workflow_id\": \"270d9bb5-13f1-4e4d-bb84-4bcc30c93967\",\n })\n\n assert res.workflow_information is not None\n\n # Handle response\n print(res.workflow_information)" + "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.workflows.get_workflow(request={\n \"workflow_id\": \"270d9bb5-13f1-4e4d-bb84-4bcc30c93967\",\n })\n\n assert res.workflow_information is not None\n\n # Handle response\n print(res.workflow_information)" - target: $["paths"]["/api/v1/workflows/{workflow_id}"]["put"] update: "x-codeSamples": - "lang": "python" "label": "update_workflow" - "source": "from unstructured_client import UnstructuredClient\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.workflows.update_workflow(request={\n \"workflow_id\": \"b63b90df-08ba-41e1-b15b-bc744e5781fa\",\n \"update_workflow\": {},\n })\n\n assert res.workflow_information is not None\n\n # Handle response\n print(res.workflow_information)" + "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.workflows.update_workflow(request={\n \"workflow_id\": \"b63b90df-08ba-41e1-b15b-bc744e5781fa\",\n \"update_workflow\": {},\n })\n\n assert res.workflow_information is not None\n\n # Handle response\n print(res.workflow_information)" - target: $["paths"]["/api/v1/workflows/{workflow_id}/run"]["post"] update: "x-codeSamples": - "lang": "python" "label": "run_workflow" - "source": "from unstructured_client import UnstructuredClient\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.workflows.run_workflow(request={\n \"workflow_id\": \"6b67be6d-98e9-440c-88fd-721e5d2d0036\",\n })\n\n assert res.workflow_information is not None\n\n # Handle response\n print(res.workflow_information)" + "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.workflows.run_workflow(request={\n \"workflow_id\": \"6b67be6d-98e9-440c-88fd-721e5d2d0036\",\n })\n\n assert res.workflow_information is not None\n\n # Handle response\n print(res.workflow_information)" - target: $["paths"]["/general/v0/general"]["post"] update: "x-codeSamples": - "lang": "python" "label": "partition" - "source": "from unstructured_client import UnstructuredClient\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.general.partition(request={\n \"partition_parameters\": {\n \"files\": {\n \"file_name\": \"example.file\",\n \"content\": open(\"example.file\", \"rb\"),\n },\n \"split_pdf_page_range\": [\n 1,\n 10,\n ],\n },\n })\n\n assert res.elements is not None\n\n # Handle response\n print(res.elements)" + "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient(\n server_url=\"https://api.example.com\",\n) as uc_client:\n\n res = uc_client.general.partition(request={\n \"partition_parameters\": {\n \"files\": {\n \"file_name\": \"example.file\",\n \"content\": open(\"example.file\", \"rb\"),\n },\n \"split_pdf_page_range\": [\n 1,\n 10,\n ],\n },\n })\n\n assert res.elements is not None\n\n # Handle response\n print(res.elements)" diff --git a/docs/sdks/destinations/README.md b/docs/sdks/destinations/README.md index bbaacac1..024fe0d0 100644 --- a/docs/sdks/destinations/README.md +++ b/docs/sdks/destinations/README.md @@ -21,7 +21,10 @@ Create a new destination connector using the provided configuration and name. from unstructured_client import UnstructuredClient from unstructured_client.models import shared -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.destinations.create_destination(request={ "create_destination_connector": { @@ -70,7 +73,10 @@ Delete a specific destination connector by its ID. ```python from unstructured_client import UnstructuredClient -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.destinations.delete_destination(request={ "destination_id": "10a88d76-65fb-4c88-8488-9e7d272c6373", @@ -111,7 +117,10 @@ Retrieve detailed information for a specific destination connector by its ID. ```python from unstructured_client import UnstructuredClient -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.destinations.get_destination(request={ "destination_id": "41ba03fb-faa3-4e9e-8cfb-27f133c4198a", @@ -152,7 +161,10 @@ Retrieve a list of available destination connectors. ```python from unstructured_client import UnstructuredClient -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.destinations.list_destinations(request={}) @@ -191,7 +203,10 @@ Update the configuration of an existing destination connector. ```python from unstructured_client import UnstructuredClient -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.destinations.update_destination(request={ "update_destination_connector": { diff --git a/docs/sdks/general/README.md b/docs/sdks/general/README.md index 42d934a9..ce26851e 100644 --- a/docs/sdks/general/README.md +++ b/docs/sdks/general/README.md @@ -16,7 +16,10 @@ Description ```python from unstructured_client import UnstructuredClient -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.general.partition(request={ "partition_parameters": { diff --git a/docs/sdks/jobs/README.md b/docs/sdks/jobs/README.md index b92d2baa..ad61e13f 100644 --- a/docs/sdks/jobs/README.md +++ b/docs/sdks/jobs/README.md @@ -18,7 +18,10 @@ Cancel the specified job. ```python from unstructured_client import UnstructuredClient -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.jobs.cancel_job(request={ "job_id": "ec29bf67-0f30-4793-b5ee-8fc0da196032", @@ -59,7 +62,10 @@ Retrieve detailed information for a specific job by its ID. ```python from unstructured_client import UnstructuredClient -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.jobs.get_job(request={ "job_id": "6bb4cb72-a072-4398-9de3-194e59352a3c", @@ -100,7 +106,10 @@ Retrieve a list of jobs with optional filtering by workflow ID or job status. ```python from unstructured_client import UnstructuredClient -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.jobs.list_jobs(request={}) diff --git a/docs/sdks/sources/README.md b/docs/sdks/sources/README.md index 49b165c8..1be3a698 100644 --- a/docs/sdks/sources/README.md +++ b/docs/sdks/sources/README.md @@ -21,7 +21,10 @@ Create a new source connector using the provided configuration and name. from unstructured_client import UnstructuredClient from unstructured_client.models import shared -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.sources.create_source(request={ "create_source_connector": { @@ -75,7 +78,10 @@ Delete a specific source connector identified by its ID. ```python from unstructured_client import UnstructuredClient -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.sources.delete_source(request={ "source_id": "8a24d7ae-5524-45e9-83f9-b0adba5303d4", @@ -116,7 +122,10 @@ Retrieve detailed information for a specific source connector by its ID. ```python from unstructured_client import UnstructuredClient -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.sources.get_source(request={ "source_id": "e02d8147-b614-4e4c-9c6d-0cd9c4492ea0", @@ -157,7 +166,10 @@ Retrieve a list of available source connectors. ```python from unstructured_client import UnstructuredClient -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.sources.list_sources(request={}) @@ -196,7 +208,10 @@ Update the configuration of an existing source connector. ```python from unstructured_client import UnstructuredClient -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.sources.update_source(request={ "update_source_connector": { diff --git a/docs/sdks/workflows/README.md b/docs/sdks/workflows/README.md index a420809a..f21326ef 100644 --- a/docs/sdks/workflows/README.md +++ b/docs/sdks/workflows/README.md @@ -22,7 +22,10 @@ Create a new workflow, either custom or auto, and configure its settings. from unstructured_client import UnstructuredClient from unstructured_client.models import shared -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.workflows.create_workflow(request={ "create_workflow": { @@ -69,7 +72,10 @@ Delete a workflow by its ID. ```python from unstructured_client import UnstructuredClient -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.workflows.delete_workflow(request={ "workflow_id": "26c0bd77-269e-4239-86b8-71541359440c", @@ -110,7 +116,10 @@ Retrieve detailed information for a specific workflow by its ID. ```python from unstructured_client import UnstructuredClient -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.workflows.get_workflow(request={ "workflow_id": "270d9bb5-13f1-4e4d-bb84-4bcc30c93967", @@ -151,7 +160,10 @@ Retrieve a list of workflows, optionally filtered by source, destination, or sta ```python from unstructured_client import UnstructuredClient -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.workflows.list_workflows(request={}) @@ -190,7 +202,10 @@ Run a workflow by triggering a new job if none is currently active. ```python from unstructured_client import UnstructuredClient -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.workflows.run_workflow(request={ "workflow_id": "6b67be6d-98e9-440c-88fd-721e5d2d0036", @@ -231,7 +246,10 @@ Update an existing workflow's name, connectors, schedule, or workflow type. ```python from unstructured_client import UnstructuredClient -with UnstructuredClient() as uc_client: + +with UnstructuredClient( + server_url="https://api.example.com", +) as uc_client: res = uc_client.workflows.update_workflow(request={ "update_workflow": {}, diff --git a/gen.yaml b/gen.yaml index 0b16d552..0063214f 100644 --- a/gen.yaml +++ b/gen.yaml @@ -4,16 +4,15 @@ generation: usageSnippets: optionalPropertyRendering: withExample fixes: - nameResolutionDec2023: false + nameResolutionFeb2025: false parameterOrderingFeb2024: false requestResponseComponentNamesFeb2024: false securityFeb2025: false - nameResolutionFeb2025: false auth: oAuth2ClientCredentialsEnabled: false oAuth2PasswordEnabled: false python: - version: 0.30.5 + version: 0.31.0 additionalDependencies: dev: deepdiff: '>=6.0' diff --git a/pyproject.toml b/pyproject.toml index c2ad1c3f..f098ea67 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "unstructured-client" -version = "0.30.5" +version = "0.31.0" description = "Python Client SDK for Unstructured API" authors = [{ name = "Unstructured" },] readme = "README-PYPI.md" diff --git a/src/unstructured_client/_version.py b/src/unstructured_client/_version.py index e157e7e2..6f3f643d 100644 --- a/src/unstructured_client/_version.py +++ b/src/unstructured_client/_version.py @@ -3,10 +3,10 @@ import importlib.metadata __title__: str = "unstructured-client" -__version__: str = "0.30.5" +__version__: str = "0.31.0" __openapi_doc_version__: str = "1.0.68" -__gen_version__: str = "2.512.0" -__user_agent__: str = "speakeasy-sdk/python 0.30.5 2.512.0 1.0.68 unstructured-client" +__gen_version__: str = "2.531.0" +__user_agent__: str = "speakeasy-sdk/python 0.31.0 2.531.0 1.0.68 unstructured-client" try: if __package__ is not None: diff --git a/src/unstructured_client/basesdk.py b/src/unstructured_client/basesdk.py index 7dbda808..56998813 100644 --- a/src/unstructured_client/basesdk.py +++ b/src/unstructured_client/basesdk.py @@ -236,6 +236,10 @@ def do(): req.headers, get_body_content(req), ) + + if client is None: + raise ValueError("client is required") + http_res = client.send(req, stream=stream) except Exception as e: _, e = self.sdk_configuration.get_hooks().after_error( @@ -308,6 +312,10 @@ async def do(): req.headers, get_body_content(req), ) + + if client is None: + raise ValueError("client is required") + http_res = await client.send(req, stream=stream) except Exception as e: _, e = self.sdk_configuration.get_hooks().after_error( diff --git a/src/unstructured_client/httpclient.py b/src/unstructured_client/httpclient.py index 9dc43cb0..1e426352 100644 --- a/src/unstructured_client/httpclient.py +++ b/src/unstructured_client/httpclient.py @@ -94,7 +94,9 @@ class ClientOwner(Protocol): def close_clients( owner: ClientOwner, sync_client: Union[HttpClient, None], + sync_client_supplied: bool, async_client: Union[AsyncHttpClient, None], + async_client_supplied: bool, ) -> None: """ A finalizer function that is meant to be used with weakref.finalize to close @@ -107,13 +109,13 @@ def close_clients( owner.client = None owner.async_client = None - if sync_client is not None: + if sync_client is not None and not sync_client_supplied: try: sync_client.close() except Exception: pass - if async_client is not None: + if async_client is not None and not async_client_supplied: is_async = False try: asyncio.get_running_loop() diff --git a/src/unstructured_client/sdk.py b/src/unstructured_client/sdk.py index e21b56e2..4dd607d5 100644 --- a/src/unstructured_client/sdk.py +++ b/src/unstructured_client/sdk.py @@ -6,8 +6,7 @@ from .utils.logger import Logger, get_default_logger from .utils.retries import RetryConfig import httpx -from typing import Any, Callable, Dict, Optional, Union, cast -from unstructured_client import utils +from typing import Any, Callable, Optional, Union, cast from unstructured_client._hooks import SDKHooks from unstructured_client.destinations import Destinations from unstructured_client.general import General @@ -28,11 +27,10 @@ class UnstructuredClient(BaseSDK): def __init__( self, + server_url: str, api_key_auth: Optional[ Union[Optional[str], Callable[[], Optional[str]]] ] = None, - server_url: Optional[str] = None, - url_params: Optional[Dict[str, str]] = None, client: Optional[HttpClient] = None, async_client: Optional[AsyncHttpClient] = None, retry_config: OptionalNullable[RetryConfig] = UNSET, @@ -49,15 +47,19 @@ def __init__( :param retry_config: The retry configuration to use for all supported methods :param timeout_ms: Optional request timeout applied to each operation in milliseconds """ + client_supplied = True if client is None: client = httpx.Client() + client_supplied = False assert issubclass( type(client), HttpClient ), "The provided client must implement the HttpClient protocol." + async_client_supplied = True if async_client is None: async_client = httpx.AsyncClient() + async_client_supplied = False if debug_logger is None: debug_logger = get_default_logger() @@ -73,15 +75,13 @@ def __init__( else: security = shared.Security(api_key_auth=api_key_auth) - if server_url is not None: - if url_params is not None: - server_url = utils.template_url(server_url, url_params) - BaseSDK.__init__( self, SDKConfiguration( client=client, + client_supplied=client_supplied, async_client=async_client, + async_client_supplied=async_client_supplied, security=security, server_url=server_url, retry_config=retry_config, @@ -94,7 +94,7 @@ def __init__( current_server_url, *_ = self.sdk_configuration.get_server_details() server_url, self.sdk_configuration.client = hooks.sdk_init( - current_server_url, self.sdk_configuration.client + current_server_url, client ) if current_server_url != server_url: self.sdk_configuration.server_url = server_url @@ -107,7 +107,9 @@ def __init__( close_clients, cast(ClientOwner, self.sdk_configuration), self.sdk_configuration.client, + self.sdk_configuration.client_supplied, self.sdk_configuration.async_client, + self.sdk_configuration.async_client_supplied, ) self._init_sdks() @@ -126,9 +128,17 @@ async def __aenter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): - if self.sdk_configuration.client is not None: + if ( + self.sdk_configuration.client is not None + and not self.sdk_configuration.client_supplied + ): self.sdk_configuration.client.close() + self.sdk_configuration.client = None async def __aexit__(self, exc_type, exc_val, exc_tb): - if self.sdk_configuration.async_client is not None: + if ( + self.sdk_configuration.async_client is not None + and not self.sdk_configuration.async_client_supplied + ): await self.sdk_configuration.async_client.aclose() + self.sdk_configuration.async_client = None diff --git a/src/unstructured_client/sdkconfiguration.py b/src/unstructured_client/sdkconfiguration.py index 5850fb5d..42e290a7 100644 --- a/src/unstructured_client/sdkconfiguration.py +++ b/src/unstructured_client/sdkconfiguration.py @@ -18,11 +18,13 @@ @dataclass class SDKConfiguration: - client: HttpClient - async_client: AsyncHttpClient + client: Union[HttpClient, None] + client_supplied: bool + async_client: Union[AsyncHttpClient, None] + async_client_supplied: bool debug_logger: Logger + server_url: str security: Optional[Union[shared.Security, Callable[[], shared.Security]]] = None - server_url: Optional[str] = "" language: str = "python" openapi_doc_version: str = __openapi_doc_version__ sdk_version: str = __version__ @@ -35,9 +37,6 @@ def __post_init__(self): self._hooks = SDKHooks() def get_server_details(self) -> Tuple[str, Dict[str, str]]: - if self.server_url is None: - return "", {} - return remove_suffix(self.server_url, "/"), {} def get_hooks(self) -> SDKHooks: diff --git a/src/unstructured_client/utils/__init__.py b/src/unstructured_client/utils/__init__.py index 26d51ae8..3cded8fe 100644 --- a/src/unstructured_client/utils/__init__.py +++ b/src/unstructured_client/utils/__init__.py @@ -42,6 +42,7 @@ match_content_type, match_status_codes, match_response, + cast_partial, ) from .logger import Logger, get_body_content, get_default_logger @@ -94,4 +95,5 @@ "validate_float", "validate_int", "validate_open_enum", + "cast_partial", ] diff --git a/src/unstructured_client/utils/values.py b/src/unstructured_client/utils/values.py index 2b4b6832..dae01a44 100644 --- a/src/unstructured_client/utils/values.py +++ b/src/unstructured_client/utils/values.py @@ -3,8 +3,9 @@ from datetime import datetime from enum import Enum from email.message import Message +from functools import partial import os -from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union +from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union, cast from httpx import Response from pydantic import BaseModel @@ -51,6 +52,8 @@ def match_status_codes(status_codes: List[str], status_code: int) -> bool: T = TypeVar("T") +def cast_partial(typ): + return partial(cast, typ) def get_global_from_env( value: Optional[T], env_key: str, type_cast: Callable[[str], T] From 08c612ce37e7b29dc63b51bb55775eaa4410643b Mon Sep 17 00:00:00 2001 From: Austin Walker Date: Wed, 26 Feb 2025 17:05:59 -0500 Subject: [PATCH 2/3] Revert to speakeasy==1.490.0 Regenerate with Serverless VLM params added --- .speakeasy/gen.lock | 22 ++++--- README.md | 42 ++++--------- USAGE.md | 10 +-- docs/models/shared/partitionparameters.md | 2 + .../partitionparametersschemasstrategy.md | 16 +++++ .../shared/partitionparametersstrategy.md | 21 +++++++ docs/models/shared/strategy.md | 3 +- docs/sdks/destinations/README.md | 25 ++------ docs/sdks/general/README.md | 8 +-- docs/sdks/jobs/README.md | 15 +---- docs/sdks/sources/README.md | 25 ++------ docs/sdks/workflows/README.md | 30 ++------- gen.yaml | 5 +- pyproject.toml | 2 +- src/unstructured_client/_version.py | 8 +-- src/unstructured_client/basesdk.py | 8 --- src/unstructured_client/httpclient.py | 6 +- .../models/shared/__init__.py | 4 ++ .../models/shared/partition_parameters.py | 62 +++++++++++++++++++ src/unstructured_client/sdk.py | 32 ++++------ src/unstructured_client/sdkconfiguration.py | 11 ++-- src/unstructured_client/utils/__init__.py | 2 - src/unstructured_client/utils/values.py | 5 +- 23 files changed, 183 insertions(+), 181 deletions(-) create mode 100644 docs/models/shared/partitionparametersschemasstrategy.md create mode 100644 docs/models/shared/partitionparametersstrategy.md diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 96d37100..619f3586 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 8b5fa338-9106-4734-abf0-e30d67044a90 management: - docChecksum: c20df03926ecb29814c3c1c36c99ddae - docVersion: 1.0.68 - speakeasyVersion: 1.505.0 - generationVersion: 2.531.0 - releaseVersion: 0.31.0 - configChecksum: faf5191e78f1597b78cd7600af4f1d96 + docChecksum: 83f88cfa4bd77e1d3065b11a97119361 + docVersion: 1.0.78 + speakeasyVersion: 1.490.0 + generationVersion: 2.512.0 + releaseVersion: 0.35.6 + configChecksum: 25ef7f396b3ae9baaa0c7d624b520182 repoURL: https://github.com/Unstructured-IO/unstructured-python-client.git repoSubDirectory: . installationURL: https://github.com/Unstructured-IO/unstructured-python-client.git @@ -16,7 +16,7 @@ features: acceptHeaders: 3.0.0 additionalDependencies: 1.0.0 constsAndDefaults: 1.0.5 - core: 5.12.1 + core: 5.11.0 defaultEnabledRetries: 0.2.0 enumUnions: 0.1.0 envVarSecurityUsage: 0.3.2 @@ -27,11 +27,11 @@ features: methodServerURLs: 3.1.1 multipartFileContentType: 1.0.0 nameOverrides: 3.0.1 - nullables: 1.0.1 + nullables: 1.0.0 openEnums: 1.0.0 responseFormat: 1.0.1 retries: 3.0.2 - sdkHooks: 1.0.1 + sdkHooks: 1.0.0 serverIDs: 3.0.0 unions: 3.0.4 uploadStreams: 1.0.0 @@ -143,6 +143,8 @@ generatedFiles: - docs/models/shared/outlooksourceconnectorconfiginput.md - docs/models/shared/outputformat.md - docs/models/shared/partitionparameters.md + - docs/models/shared/partitionparametersschemasstrategy.md + - docs/models/shared/partitionparametersstrategy.md - docs/models/shared/postgresdestinationconnectorconfig.md - docs/models/shared/postgresdestinationconnectorconfiginput.md - docs/models/shared/qdrantclouddestinationconnectorconfig.md @@ -536,7 +538,7 @@ examples: partition: speakeasy-default-partition: requestBody: - multipart/form-data: {"chunking_strategy": "by_title", "combine_under_n_chars": null, "content_type": null, "coordinates": false, "encoding": null, "files": {"": "{\"summary\":\"File to be partitioned\",\"externalValue\":\"https://github.com/Unstructured-IO/unstructured/blob/98d3541909f64290b5efb65a226fc3ee8a7cc5ee/example-docs/layout-parser-paper.pdf\"}"}, "gz_uncompressed_content_type": null, "hi_res_model_name": null, "include_orig_elements": null, "include_page_breaks": false, "include_slide_notes": true, "max_characters": null, "multipage_sections": true, "new_after_n_chars": null, "output_format": "application/json", "overlap": 0, "overlap_all": false, "pdf_infer_table_structure": true, "similarity_threshold": null, "split_pdf_allow_failed": false, "split_pdf_cache_tmp_data": false, "split_pdf_cache_tmp_data_dir": "", "split_pdf_concurrency_level": 5, "split_pdf_page": true, "split_pdf_page_range": [1, 10], "starting_page_number": null, "strategy": "hi_res", "table_ocr_agent": null, "unique_element_ids": false, "xml_keep_tags": false} + multipart/form-data: {"chunking_strategy": "by_title", "combine_under_n_chars": null, "content_type": null, "coordinates": false, "encoding": null, "files": {"": "{\"summary\":\"File to be partitioned\",\"externalValue\":\"https://github.com/Unstructured-IO/unstructured/blob/98d3541909f64290b5efb65a226fc3ee8a7cc5ee/example-docs/layout-parser-paper.pdf\"}"}, "gz_uncompressed_content_type": null, "hi_res_model_name": null, "include_orig_elements": null, "include_page_breaks": false, "include_slide_notes": true, "max_characters": null, "multipage_sections": true, "new_after_n_chars": null, "output_format": "application/json", "overlap": 0, "overlap_all": false, "pdf_infer_table_structure": true, "similarity_threshold": null, "split_pdf_allow_failed": false, "split_pdf_cache_tmp_data": false, "split_pdf_cache_tmp_data_dir": "", "split_pdf_concurrency_level": 5, "split_pdf_page": true, "split_pdf_page_range": [1, 10], "starting_page_number": null, "strategy": "vlm", "table_ocr_agent": null, "unique_element_ids": false, "vlm_model": "gpt-4o", "vlm_model_provider": "openai", "xml_keep_tags": false} responses: "200": application/json: [{"type": "Title", "element_id": "6aa0ff22f91bbe7e26e8e25ca8052acd", "text": "LayoutParser: A Unified Toolkit for Deep Learning Based Document Image Analysis", "metadata": {"languages": ["eng"], "page_number": 1, "filename": "layout-parser-paper.pdf", "filetype": "application/pdf"}}] diff --git a/README.md b/README.md index 2f8354ad..075d2bee 100755 --- a/README.md +++ b/README.md @@ -113,10 +113,7 @@ from unstructured_client import UnstructuredClient from unstructured_client.models import shared from unstructured_client.utils import BackoffStrategy, RetryConfig - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.destinations.create_destination(request={ "create_destination_connector": { @@ -144,9 +141,7 @@ from unstructured_client import UnstructuredClient from unstructured_client.models import shared from unstructured_client.utils import BackoffStrategy, RetryConfig - with UnstructuredClient( - server_url="https://api.example.com", retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False), ) as uc_client: @@ -198,10 +193,7 @@ When custom error responses are specified for an operation, the SDK may also rai from unstructured_client import UnstructuredClient from unstructured_client.models import errors, shared - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = None try: @@ -333,10 +325,7 @@ Generally, the SDK will work well with most IDEs out of the box. However, when u from unstructured_client import UnstructuredClient from unstructured_client.models import shared - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.destinations.create_destination(request={ "create_destination_connector": { @@ -366,10 +355,7 @@ from unstructured_client import UnstructuredClient from unstructured_client.models import shared async def main(): - - async with UnstructuredClient( - server_url="https://api.example.com", - ) as uc_client: + async with UnstructuredClient() as uc_client: res = await uc_client.destinations.create_destination_async(request={ "create_destination_connector": { @@ -463,11 +449,9 @@ Certain SDK methods accept file objects as part of a request body or multi-part ```python from unstructured_client import UnstructuredClient +from unstructured_client.models import shared - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.general.partition(request={ "partition_parameters": { @@ -479,6 +463,8 @@ with UnstructuredClient( 1, 10, ], + "vlm_model": shared.PartitionParametersStrategy.GPT_4O, + "vlm_model_provider": shared.PartitionParametersSchemasStrategy.OPENAI, }, }) @@ -500,19 +486,13 @@ The `UnstructuredClient` class implements the context manager protocol and regis ```python from unstructured_client import UnstructuredClient def main(): - - with UnstructuredClient( - server_url="https://api.example.com", - ) as uc_client: + with UnstructuredClient() as uc_client: # Rest of application here... # Or when using async: async def amain(): - - async with UnstructuredClient( - server_url="https://api.example.com", - ) as uc_client: + async with UnstructuredClient() as uc_client: # Rest of application here... ``` @@ -528,7 +508,7 @@ from unstructured_client import UnstructuredClient import logging logging.basicConfig(level=logging.DEBUG) -s = UnstructuredClient(server_url="https://example.com", debug_logger=logging.getLogger("unstructured_client")) +s = UnstructuredClient(debug_logger=logging.getLogger("unstructured_client")) ``` diff --git a/USAGE.md b/USAGE.md index 4151cac7..808460d6 100644 --- a/USAGE.md +++ b/USAGE.md @@ -4,10 +4,7 @@ from unstructured_client import UnstructuredClient from unstructured_client.models import shared - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.destinations.create_destination(request={ "create_destination_connector": { @@ -37,10 +34,7 @@ from unstructured_client import UnstructuredClient from unstructured_client.models import shared async def main(): - - async with UnstructuredClient( - server_url="https://api.example.com", - ) as uc_client: + async with UnstructuredClient() as uc_client: res = await uc_client.destinations.create_destination_async(request={ "create_destination_connector": { diff --git a/docs/models/shared/partitionparameters.md b/docs/models/shared/partitionparameters.md index d6cafeaf..e1946c1d 100644 --- a/docs/models/shared/partitionparameters.md +++ b/docs/models/shared/partitionparameters.md @@ -38,4 +38,6 @@ | `strategy` | [Optional[shared.Strategy]](../../models/shared/strategy.md) | :heavy_minus_sign: | The strategy to use for partitioning PDF/image. Options are fast, hi_res, auto. Default: hi_res | auto | | `table_ocr_agent` | *OptionalNullable[str]* | :heavy_minus_sign: | The OCR agent to use for table ocr inference. | | | `unique_element_ids` | *Optional[bool]* | :heavy_minus_sign: | When `True`, assign UUIDs to element IDs, which guarantees their uniqueness (useful when using them as primary keys in database). Otherwise a SHA-256 of element text is used. Default: `False` | | +| `vlm_model` | [Optional[shared.PartitionParametersStrategy]](../../models/shared/partitionparametersstrategy.md) | :heavy_minus_sign: | The VLM Model to use. | gpt-4o | +| `vlm_model_provider` | [Optional[shared.PartitionParametersSchemasStrategy]](../../models/shared/partitionparametersschemasstrategy.md) | :heavy_minus_sign: | The VLM Model provider to use. | openai | | `xml_keep_tags` | *Optional[bool]* | :heavy_minus_sign: | If `True`, will retain the XML tags in the output. Otherwise it will simply extract the text from within the tags. Only applies to XML documents. | | \ No newline at end of file diff --git a/docs/models/shared/partitionparametersschemasstrategy.md b/docs/models/shared/partitionparametersschemasstrategy.md new file mode 100644 index 00000000..dd9f12ec --- /dev/null +++ b/docs/models/shared/partitionparametersschemasstrategy.md @@ -0,0 +1,16 @@ +# PartitionParametersSchemasStrategy + +The VLM Model provider to use. + + +## Values + +| Name | Value | +| ------------------- | ------------------- | +| `OPENAI` | openai | +| `ANTHROPIC` | anthropic | +| `BEDROCK` | bedrock | +| `ANTHROPIC_BEDROCK` | anthropic_bedrock | +| `VERTEXAI` | vertexai | +| `GOOGLE` | google | +| `AZURE_OPENAI` | azure_openai | \ No newline at end of file diff --git a/docs/models/shared/partitionparametersstrategy.md b/docs/models/shared/partitionparametersstrategy.md new file mode 100644 index 00000000..9e656abd --- /dev/null +++ b/docs/models/shared/partitionparametersstrategy.md @@ -0,0 +1,21 @@ +# PartitionParametersStrategy + +The VLM Model to use. + + +## Values + +| Name | Value | +| ---------------------------------------------- | ---------------------------------------------- | +| `CLAUDE_3_5_SONNET_20241022` | claude-3-5-sonnet-20241022 | +| `GPT_4O` | gpt-4o | +| `GEMINI_1_5_PRO` | gemini-1.5-pro | +| `US_AMAZON_NOVA_PRO_V1_0` | us.amazon.nova-pro-v1:0 | +| `US_AMAZON_NOVA_LITE_V1_0` | us.amazon.nova-lite-v1:0 | +| `US_ANTHROPIC_CLAUDE_3_5_SONNET_20241022_V2_0` | us.anthropic.claude-3-5-sonnet-20241022-v2:0 | +| `US_ANTHROPIC_CLAUDE_3_OPUS_20240229_V1_0` | us.anthropic.claude-3-opus-20240229-v1:0 | +| `US_ANTHROPIC_CLAUDE_3_HAIKU_20240307_V1_0` | us.anthropic.claude-3-haiku-20240307-v1:0 | +| `US_ANTHROPIC_CLAUDE_3_SONNET_20240229_V1_0` | us.anthropic.claude-3-sonnet-20240229-v1:0 | +| `US_META_LLAMA3_2_90B_INSTRUCT_V1_0` | us.meta.llama3-2-90b-instruct-v1:0 | +| `US_META_LLAMA3_2_11B_INSTRUCT_V1_0` | us.meta.llama3-2-11b-instruct-v1:0 | +| `GEMINI_2_0_FLASH_001` | gemini-2.0-flash-001 | \ No newline at end of file diff --git a/docs/models/shared/strategy.md b/docs/models/shared/strategy.md index 4bad9a6e..f331220e 100644 --- a/docs/models/shared/strategy.md +++ b/docs/models/shared/strategy.md @@ -11,4 +11,5 @@ The strategy to use for partitioning PDF/image. Options are fast, hi_res, auto. | `HI_RES` | hi_res | | `AUTO` | auto | | `OCR_ONLY` | ocr_only | -| `OD_ONLY` | od_only | \ No newline at end of file +| `OD_ONLY` | od_only | +| `VLM` | vlm | \ No newline at end of file diff --git a/docs/sdks/destinations/README.md b/docs/sdks/destinations/README.md index 024fe0d0..bbaacac1 100644 --- a/docs/sdks/destinations/README.md +++ b/docs/sdks/destinations/README.md @@ -21,10 +21,7 @@ Create a new destination connector using the provided configuration and name. from unstructured_client import UnstructuredClient from unstructured_client.models import shared - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.destinations.create_destination(request={ "create_destination_connector": { @@ -73,10 +70,7 @@ Delete a specific destination connector by its ID. ```python from unstructured_client import UnstructuredClient - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.destinations.delete_destination(request={ "destination_id": "10a88d76-65fb-4c88-8488-9e7d272c6373", @@ -117,10 +111,7 @@ Retrieve detailed information for a specific destination connector by its ID. ```python from unstructured_client import UnstructuredClient - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.destinations.get_destination(request={ "destination_id": "41ba03fb-faa3-4e9e-8cfb-27f133c4198a", @@ -161,10 +152,7 @@ Retrieve a list of available destination connectors. ```python from unstructured_client import UnstructuredClient - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.destinations.list_destinations(request={}) @@ -203,10 +191,7 @@ Update the configuration of an existing destination connector. ```python from unstructured_client import UnstructuredClient - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.destinations.update_destination(request={ "update_destination_connector": { diff --git a/docs/sdks/general/README.md b/docs/sdks/general/README.md index ce26851e..d23f3888 100644 --- a/docs/sdks/general/README.md +++ b/docs/sdks/general/README.md @@ -15,11 +15,9 @@ Description ```python from unstructured_client import UnstructuredClient +from unstructured_client.models import shared - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.general.partition(request={ "partition_parameters": { @@ -31,6 +29,8 @@ with UnstructuredClient( 1, 10, ], + "vlm_model": shared.PartitionParametersStrategy.GPT_4O, + "vlm_model_provider": shared.PartitionParametersSchemasStrategy.OPENAI, }, }) diff --git a/docs/sdks/jobs/README.md b/docs/sdks/jobs/README.md index ad61e13f..b92d2baa 100644 --- a/docs/sdks/jobs/README.md +++ b/docs/sdks/jobs/README.md @@ -18,10 +18,7 @@ Cancel the specified job. ```python from unstructured_client import UnstructuredClient - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.jobs.cancel_job(request={ "job_id": "ec29bf67-0f30-4793-b5ee-8fc0da196032", @@ -62,10 +59,7 @@ Retrieve detailed information for a specific job by its ID. ```python from unstructured_client import UnstructuredClient - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.jobs.get_job(request={ "job_id": "6bb4cb72-a072-4398-9de3-194e59352a3c", @@ -106,10 +100,7 @@ Retrieve a list of jobs with optional filtering by workflow ID or job status. ```python from unstructured_client import UnstructuredClient - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.jobs.list_jobs(request={}) diff --git a/docs/sdks/sources/README.md b/docs/sdks/sources/README.md index 1be3a698..49b165c8 100644 --- a/docs/sdks/sources/README.md +++ b/docs/sdks/sources/README.md @@ -21,10 +21,7 @@ Create a new source connector using the provided configuration and name. from unstructured_client import UnstructuredClient from unstructured_client.models import shared - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.sources.create_source(request={ "create_source_connector": { @@ -78,10 +75,7 @@ Delete a specific source connector identified by its ID. ```python from unstructured_client import UnstructuredClient - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.sources.delete_source(request={ "source_id": "8a24d7ae-5524-45e9-83f9-b0adba5303d4", @@ -122,10 +116,7 @@ Retrieve detailed information for a specific source connector by its ID. ```python from unstructured_client import UnstructuredClient - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.sources.get_source(request={ "source_id": "e02d8147-b614-4e4c-9c6d-0cd9c4492ea0", @@ -166,10 +157,7 @@ Retrieve a list of available source connectors. ```python from unstructured_client import UnstructuredClient - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.sources.list_sources(request={}) @@ -208,10 +196,7 @@ Update the configuration of an existing source connector. ```python from unstructured_client import UnstructuredClient - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.sources.update_source(request={ "update_source_connector": { diff --git a/docs/sdks/workflows/README.md b/docs/sdks/workflows/README.md index f21326ef..a420809a 100644 --- a/docs/sdks/workflows/README.md +++ b/docs/sdks/workflows/README.md @@ -22,10 +22,7 @@ Create a new workflow, either custom or auto, and configure its settings. from unstructured_client import UnstructuredClient from unstructured_client.models import shared - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.workflows.create_workflow(request={ "create_workflow": { @@ -72,10 +69,7 @@ Delete a workflow by its ID. ```python from unstructured_client import UnstructuredClient - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.workflows.delete_workflow(request={ "workflow_id": "26c0bd77-269e-4239-86b8-71541359440c", @@ -116,10 +110,7 @@ Retrieve detailed information for a specific workflow by its ID. ```python from unstructured_client import UnstructuredClient - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.workflows.get_workflow(request={ "workflow_id": "270d9bb5-13f1-4e4d-bb84-4bcc30c93967", @@ -160,10 +151,7 @@ Retrieve a list of workflows, optionally filtered by source, destination, or sta ```python from unstructured_client import UnstructuredClient - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.workflows.list_workflows(request={}) @@ -202,10 +190,7 @@ Run a workflow by triggering a new job if none is currently active. ```python from unstructured_client import UnstructuredClient - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.workflows.run_workflow(request={ "workflow_id": "6b67be6d-98e9-440c-88fd-721e5d2d0036", @@ -246,10 +231,7 @@ Update an existing workflow's name, connectors, schedule, or workflow type. ```python from unstructured_client import UnstructuredClient - -with UnstructuredClient( - server_url="https://api.example.com", -) as uc_client: +with UnstructuredClient() as uc_client: res = uc_client.workflows.update_workflow(request={ "update_workflow": {}, diff --git a/gen.yaml b/gen.yaml index 0063214f..239822ec 100644 --- a/gen.yaml +++ b/gen.yaml @@ -4,15 +4,16 @@ generation: usageSnippets: optionalPropertyRendering: withExample fixes: - nameResolutionFeb2025: false + nameResolutionDec2023: false parameterOrderingFeb2024: false requestResponseComponentNamesFeb2024: false securityFeb2025: false + nameResolutionFeb2025: false auth: oAuth2ClientCredentialsEnabled: false oAuth2PasswordEnabled: false python: - version: 0.31.0 + version: 0.35.6 additionalDependencies: dev: deepdiff: '>=6.0' diff --git a/pyproject.toml b/pyproject.toml index f098ea67..50455a7c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "unstructured-client" -version = "0.31.0" +version = "0.35.6" description = "Python Client SDK for Unstructured API" authors = [{ name = "Unstructured" },] readme = "README-PYPI.md" diff --git a/src/unstructured_client/_version.py b/src/unstructured_client/_version.py index 6f3f643d..a3a83d13 100644 --- a/src/unstructured_client/_version.py +++ b/src/unstructured_client/_version.py @@ -3,10 +3,10 @@ import importlib.metadata __title__: str = "unstructured-client" -__version__: str = "0.31.0" -__openapi_doc_version__: str = "1.0.68" -__gen_version__: str = "2.531.0" -__user_agent__: str = "speakeasy-sdk/python 0.31.0 2.531.0 1.0.68 unstructured-client" +__version__: str = "0.35.6" +__openapi_doc_version__: str = "1.0.78" +__gen_version__: str = "2.512.0" +__user_agent__: str = "speakeasy-sdk/python 0.35.6 2.512.0 1.0.78 unstructured-client" try: if __package__ is not None: diff --git a/src/unstructured_client/basesdk.py b/src/unstructured_client/basesdk.py index 56998813..7dbda808 100644 --- a/src/unstructured_client/basesdk.py +++ b/src/unstructured_client/basesdk.py @@ -236,10 +236,6 @@ def do(): req.headers, get_body_content(req), ) - - if client is None: - raise ValueError("client is required") - http_res = client.send(req, stream=stream) except Exception as e: _, e = self.sdk_configuration.get_hooks().after_error( @@ -312,10 +308,6 @@ async def do(): req.headers, get_body_content(req), ) - - if client is None: - raise ValueError("client is required") - http_res = await client.send(req, stream=stream) except Exception as e: _, e = self.sdk_configuration.get_hooks().after_error( diff --git a/src/unstructured_client/httpclient.py b/src/unstructured_client/httpclient.py index 1e426352..9dc43cb0 100644 --- a/src/unstructured_client/httpclient.py +++ b/src/unstructured_client/httpclient.py @@ -94,9 +94,7 @@ class ClientOwner(Protocol): def close_clients( owner: ClientOwner, sync_client: Union[HttpClient, None], - sync_client_supplied: bool, async_client: Union[AsyncHttpClient, None], - async_client_supplied: bool, ) -> None: """ A finalizer function that is meant to be used with weakref.finalize to close @@ -109,13 +107,13 @@ def close_clients( owner.client = None owner.async_client = None - if sync_client is not None and not sync_client_supplied: + if sync_client is not None: try: sync_client.close() except Exception: pass - if async_client is not None and not async_client_supplied: + if async_client is not None: is_async = False try: asyncio.get_running_loop() diff --git a/src/unstructured_client/models/shared/__init__.py b/src/unstructured_client/models/shared/__init__.py index f12f7a47..50a97a07 100644 --- a/src/unstructured_client/models/shared/__init__.py +++ b/src/unstructured_client/models/shared/__init__.py @@ -211,6 +211,8 @@ FilesTypedDict, OutputFormat, PartitionParameters, + PartitionParametersSchemasStrategy, + PartitionParametersStrategy, PartitionParametersTypedDict, Strategy, ) @@ -451,6 +453,8 @@ "OutlookSourceConnectorConfigTypedDict", "OutputFormat", "PartitionParameters", + "PartitionParametersSchemasStrategy", + "PartitionParametersStrategy", "PartitionParametersTypedDict", "PostgresDestinationConnectorConfig", "PostgresDestinationConnectorConfigInput", diff --git a/src/unstructured_client/models/shared/partition_parameters.py b/src/unstructured_client/models/shared/partition_parameters.py index adf54e13..638deb5e 100644 --- a/src/unstructured_client/models/shared/partition_parameters.py +++ b/src/unstructured_client/models/shared/partition_parameters.py @@ -61,6 +61,44 @@ class Strategy(str, Enum, metaclass=utils.OpenEnumMeta): AUTO = "auto" OCR_ONLY = "ocr_only" OD_ONLY = "od_only" + VLM = "vlm" + + +class PartitionParametersStrategy(str, Enum, metaclass=utils.OpenEnumMeta): + r"""The VLM Model to use.""" + + CLAUDE_3_5_SONNET_20241022 = "claude-3-5-sonnet-20241022" + GPT_4O = "gpt-4o" + GEMINI_1_5_PRO = "gemini-1.5-pro" + US_AMAZON_NOVA_PRO_V1_0 = "us.amazon.nova-pro-v1:0" + US_AMAZON_NOVA_LITE_V1_0 = "us.amazon.nova-lite-v1:0" + US_ANTHROPIC_CLAUDE_3_5_SONNET_20241022_V2_0 = ( + "us.anthropic.claude-3-5-sonnet-20241022-v2:0" + ) + US_ANTHROPIC_CLAUDE_3_OPUS_20240229_V1_0 = ( + "us.anthropic.claude-3-opus-20240229-v1:0" + ) + US_ANTHROPIC_CLAUDE_3_HAIKU_20240307_V1_0 = ( + "us.anthropic.claude-3-haiku-20240307-v1:0" + ) + US_ANTHROPIC_CLAUDE_3_SONNET_20240229_V1_0 = ( + "us.anthropic.claude-3-sonnet-20240229-v1:0" + ) + US_META_LLAMA3_2_90B_INSTRUCT_V1_0 = "us.meta.llama3-2-90b-instruct-v1:0" + US_META_LLAMA3_2_11B_INSTRUCT_V1_0 = "us.meta.llama3-2-11b-instruct-v1:0" + GEMINI_2_0_FLASH_001 = "gemini-2.0-flash-001" + + +class PartitionParametersSchemasStrategy(str, Enum, metaclass=utils.OpenEnumMeta): + r"""The VLM Model provider to use.""" + + OPENAI = "openai" + ANTHROPIC = "anthropic" + BEDROCK = "bedrock" + ANTHROPIC_BEDROCK = "anthropic_bedrock" + VERTEXAI = "vertexai" + GOOGLE = "google" + AZURE_OPENAI = "azure_openai" class PartitionParametersTypedDict(TypedDict): @@ -130,6 +168,10 @@ class PartitionParametersTypedDict(TypedDict): r"""The OCR agent to use for table ocr inference.""" unique_element_ids: NotRequired[bool] r"""When `True`, assign UUIDs to element IDs, which guarantees their uniqueness (useful when using them as primary keys in database). Otherwise a SHA-256 of element text is used. Default: `False`""" + vlm_model: NotRequired[PartitionParametersStrategy] + r"""The VLM Model to use.""" + vlm_model_provider: NotRequired[PartitionParametersSchemasStrategy] + r"""The VLM Model provider to use.""" xml_keep_tags: NotRequired[bool] r"""If `True`, will retain the XML tags in the output. Otherwise it will simply extract the text from within the tags. Only applies to XML documents.""" @@ -278,6 +320,24 @@ class PartitionParameters(BaseModel): unique_element_ids: Annotated[Optional[bool], FieldMetadata(multipart=True)] = False r"""When `True`, assign UUIDs to element IDs, which guarantees their uniqueness (useful when using them as primary keys in database). Otherwise a SHA-256 of element text is used. Default: `False`""" + vlm_model: Annotated[ + Annotated[ + Optional[PartitionParametersStrategy], + PlainValidator(validate_open_enum(False)), + ], + FieldMetadata(multipart=True), + ] = None + r"""The VLM Model to use.""" + + vlm_model_provider: Annotated[ + Annotated[ + Optional[PartitionParametersSchemasStrategy], + PlainValidator(validate_open_enum(False)), + ], + FieldMetadata(multipart=True), + ] = None + r"""The VLM Model provider to use.""" + xml_keep_tags: Annotated[Optional[bool], FieldMetadata(multipart=True)] = False r"""If `True`, will retain the XML tags in the output. Otherwise it will simply extract the text from within the tags. Only applies to XML documents.""" @@ -316,6 +376,8 @@ def serialize_model(self, handler): "strategy", "table_ocr_agent", "unique_element_ids", + "vlm_model", + "vlm_model_provider", "xml_keep_tags", ] nullable_fields = [ diff --git a/src/unstructured_client/sdk.py b/src/unstructured_client/sdk.py index 4dd607d5..e21b56e2 100644 --- a/src/unstructured_client/sdk.py +++ b/src/unstructured_client/sdk.py @@ -6,7 +6,8 @@ from .utils.logger import Logger, get_default_logger from .utils.retries import RetryConfig import httpx -from typing import Any, Callable, Optional, Union, cast +from typing import Any, Callable, Dict, Optional, Union, cast +from unstructured_client import utils from unstructured_client._hooks import SDKHooks from unstructured_client.destinations import Destinations from unstructured_client.general import General @@ -27,10 +28,11 @@ class UnstructuredClient(BaseSDK): def __init__( self, - server_url: str, api_key_auth: Optional[ Union[Optional[str], Callable[[], Optional[str]]] ] = None, + server_url: Optional[str] = None, + url_params: Optional[Dict[str, str]] = None, client: Optional[HttpClient] = None, async_client: Optional[AsyncHttpClient] = None, retry_config: OptionalNullable[RetryConfig] = UNSET, @@ -47,19 +49,15 @@ def __init__( :param retry_config: The retry configuration to use for all supported methods :param timeout_ms: Optional request timeout applied to each operation in milliseconds """ - client_supplied = True if client is None: client = httpx.Client() - client_supplied = False assert issubclass( type(client), HttpClient ), "The provided client must implement the HttpClient protocol." - async_client_supplied = True if async_client is None: async_client = httpx.AsyncClient() - async_client_supplied = False if debug_logger is None: debug_logger = get_default_logger() @@ -75,13 +73,15 @@ def __init__( else: security = shared.Security(api_key_auth=api_key_auth) + if server_url is not None: + if url_params is not None: + server_url = utils.template_url(server_url, url_params) + BaseSDK.__init__( self, SDKConfiguration( client=client, - client_supplied=client_supplied, async_client=async_client, - async_client_supplied=async_client_supplied, security=security, server_url=server_url, retry_config=retry_config, @@ -94,7 +94,7 @@ def __init__( current_server_url, *_ = self.sdk_configuration.get_server_details() server_url, self.sdk_configuration.client = hooks.sdk_init( - current_server_url, client + current_server_url, self.sdk_configuration.client ) if current_server_url != server_url: self.sdk_configuration.server_url = server_url @@ -107,9 +107,7 @@ def __init__( close_clients, cast(ClientOwner, self.sdk_configuration), self.sdk_configuration.client, - self.sdk_configuration.client_supplied, self.sdk_configuration.async_client, - self.sdk_configuration.async_client_supplied, ) self._init_sdks() @@ -128,17 +126,9 @@ async def __aenter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): - if ( - self.sdk_configuration.client is not None - and not self.sdk_configuration.client_supplied - ): + if self.sdk_configuration.client is not None: self.sdk_configuration.client.close() - self.sdk_configuration.client = None async def __aexit__(self, exc_type, exc_val, exc_tb): - if ( - self.sdk_configuration.async_client is not None - and not self.sdk_configuration.async_client_supplied - ): + if self.sdk_configuration.async_client is not None: await self.sdk_configuration.async_client.aclose() - self.sdk_configuration.async_client = None diff --git a/src/unstructured_client/sdkconfiguration.py b/src/unstructured_client/sdkconfiguration.py index 42e290a7..5850fb5d 100644 --- a/src/unstructured_client/sdkconfiguration.py +++ b/src/unstructured_client/sdkconfiguration.py @@ -18,13 +18,11 @@ @dataclass class SDKConfiguration: - client: Union[HttpClient, None] - client_supplied: bool - async_client: Union[AsyncHttpClient, None] - async_client_supplied: bool + client: HttpClient + async_client: AsyncHttpClient debug_logger: Logger - server_url: str security: Optional[Union[shared.Security, Callable[[], shared.Security]]] = None + server_url: Optional[str] = "" language: str = "python" openapi_doc_version: str = __openapi_doc_version__ sdk_version: str = __version__ @@ -37,6 +35,9 @@ def __post_init__(self): self._hooks = SDKHooks() def get_server_details(self) -> Tuple[str, Dict[str, str]]: + if self.server_url is None: + return "", {} + return remove_suffix(self.server_url, "/"), {} def get_hooks(self) -> SDKHooks: diff --git a/src/unstructured_client/utils/__init__.py b/src/unstructured_client/utils/__init__.py index 3cded8fe..26d51ae8 100644 --- a/src/unstructured_client/utils/__init__.py +++ b/src/unstructured_client/utils/__init__.py @@ -42,7 +42,6 @@ match_content_type, match_status_codes, match_response, - cast_partial, ) from .logger import Logger, get_body_content, get_default_logger @@ -95,5 +94,4 @@ "validate_float", "validate_int", "validate_open_enum", - "cast_partial", ] diff --git a/src/unstructured_client/utils/values.py b/src/unstructured_client/utils/values.py index dae01a44..2b4b6832 100644 --- a/src/unstructured_client/utils/values.py +++ b/src/unstructured_client/utils/values.py @@ -3,9 +3,8 @@ from datetime import datetime from enum import Enum from email.message import Message -from functools import partial import os -from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union, cast +from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union from httpx import Response from pydantic import BaseModel @@ -52,8 +51,6 @@ def match_status_codes(status_codes: List[str], status_code: int) -> bool: T = TypeVar("T") -def cast_partial(typ): - return partial(cast, typ) def get_global_from_env( value: Optional[T], env_key: str, type_cast: Callable[[str], T] From 7d5fc43432c8bf2e0b4b645886bad7018be77e38 Mon Sep 17 00:00:00 2001 From: Austin Walker Date: Wed, 26 Feb 2025 17:10:08 -0500 Subject: [PATCH 3/3] Fix release version --- .speakeasy/gen.lock | 4 ++-- RELEASES.md | 4 ++-- gen.yaml | 2 +- pyproject.toml | 2 +- src/unstructured_client/_version.py | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 619f3586..7905f94a 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -5,8 +5,8 @@ management: docVersion: 1.0.78 speakeasyVersion: 1.490.0 generationVersion: 2.512.0 - releaseVersion: 0.35.6 - configChecksum: 25ef7f396b3ae9baaa0c7d624b520182 + releaseVersion: 0.30.6 + configChecksum: c946e26d3a3b2fe2756ff169416b448c repoURL: https://github.com/Unstructured-IO/unstructured-python-client.git repoSubDirectory: . installationURL: https://github.com/Unstructured-IO/unstructured-python-client.git diff --git a/RELEASES.md b/RELEASES.md index c56b711a..7a7a0c0e 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -832,6 +832,6 @@ Based on: - OpenAPI Doc - Speakeasy CLI 1.505.0 (2.531.0) https://github.com/speakeasy-api/speakeasy ### Generated -- [python v0.31.0] . +- [python v0.30.6] . ### Releases -- [PyPI v0.31.0] https://pypi.org/project/unstructured-client/0.31.0 - . \ No newline at end of file +- [PyPI v0.30.6] https://pypi.org/project/unstructured-client/0.30.6 - . diff --git a/gen.yaml b/gen.yaml index 239822ec..0d5851fd 100644 --- a/gen.yaml +++ b/gen.yaml @@ -13,7 +13,7 @@ generation: oAuth2ClientCredentialsEnabled: false oAuth2PasswordEnabled: false python: - version: 0.35.6 + version: 0.30.6 additionalDependencies: dev: deepdiff: '>=6.0' diff --git a/pyproject.toml b/pyproject.toml index 50455a7c..c7e7bb9c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "unstructured-client" -version = "0.35.6" +version = "0.30.6" description = "Python Client SDK for Unstructured API" authors = [{ name = "Unstructured" },] readme = "README-PYPI.md" diff --git a/src/unstructured_client/_version.py b/src/unstructured_client/_version.py index a3a83d13..a1c80daf 100644 --- a/src/unstructured_client/_version.py +++ b/src/unstructured_client/_version.py @@ -3,10 +3,10 @@ import importlib.metadata __title__: str = "unstructured-client" -__version__: str = "0.35.6" +__version__: str = "0.30.6" __openapi_doc_version__: str = "1.0.78" __gen_version__: str = "2.512.0" -__user_agent__: str = "speakeasy-sdk/python 0.35.6 2.512.0 1.0.78 unstructured-client" +__user_agent__: str = "speakeasy-sdk/python 0.30.6 2.512.0 1.0.78 unstructured-client" try: if __package__ is not None: