Skip to content

Commit 0f96076

Browse files
committed
Regenerate on v2
1 parent 37f3628 commit 0f96076

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2999
-1608
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
pyrightconfig.json
12
venv/
23
src/*.egg-info/
34
__pycache__/
45
.pytest_cache/
56
.python-version
67
.DS_Store
7-
88
# human-added igore files
99
.ipynb_checkpoints/
1010
.idea/

.speakeasy/gen.lock

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,76 @@
11
lockVersion: 2.0.0
22
id: 8b5fa338-9106-4734-abf0-e30d67044a90
33
management:
4-
docChecksum: 774e507b2df4f671362defe668d4d0d6
5-
docVersion: 1.0.39
6-
speakeasyVersion: 1.335.0
7-
generationVersion: 2.370.2
8-
releaseVersion: 0.24.1
9-
configChecksum: 7ebed47354cd1fd023aebb9420561b04
4+
docChecksum: c20db13bfb07ee6d97a80d72980a238c
5+
docVersion: 1.0.41
6+
speakeasyVersion: 1.346.0
7+
generationVersion: 2.379.3
8+
releaseVersion: 0.25.0
9+
configChecksum: 7d86c81e5c2aaef79b43b261bbdf9035
1010
repoURL: https://github.com/Unstructured-IO/unstructured-python-client.git
1111
repoSubDirectory: .
1212
installationURL: https://github.com/Unstructured-IO/unstructured-python-client.git
1313
published: true
1414
features:
1515
python:
16-
additionalDependencies: 0.1.0
17-
constsAndDefaults: 0.1.3
18-
core: 4.8.1
19-
examples: 2.81.3
20-
globalSecurity: 2.83.5
21-
globalSecurityCallbacks: 0.1.0
22-
globalSecurityFlattening: 0.1.0
23-
globalServerURLs: 2.82.2
24-
nameOverrides: 2.81.2
25-
nullables: 0.1.0
26-
openEnums: 0.1.0
27-
responseFormat: 0.1.0
28-
retries: 2.82.2
29-
sdkHooks: 0.1.0
30-
serverIDs: 2.81.1
31-
unions: 2.82.8
16+
additionalDependencies: 1.0.0
17+
constsAndDefaults: 1.0.0
18+
core: 5.2.4
19+
defaultEnabledRetries: 0.2.0
20+
envVarSecurityUsage: 0.2.0
21+
examples: 3.0.0
22+
globalSecurity: 3.0.0
23+
globalSecurityCallbacks: 1.0.0
24+
globalSecurityFlattening: 1.0.0
25+
globalServerURLs: 3.0.0
26+
multipartFileContentType: 1.0.0
27+
nameOverrides: 3.0.0
28+
nullables: 1.0.0
29+
openEnums: 1.0.0
30+
responseFormat: 1.0.0
31+
retries: 3.0.0
32+
sdkHooks: 1.0.0
33+
serverIDs: 3.0.0
34+
unions: 3.0.1
35+
uploadStreams: 1.0.0
3236
generatedFiles:
3337
- src/unstructured_client/sdkconfiguration.py
3438
- src/unstructured_client/general.py
3539
- src/unstructured_client/sdk.py
40+
- .vscode/settings.json
3641
- py.typed
3742
- pylintrc
43+
- pyproject.toml
3844
- scripts/publish.sh
39-
- setup.py
4045
- src/unstructured_client/__init__.py
46+
- src/unstructured_client/basesdk.py
47+
- src/unstructured_client/httpclient.py
48+
- src/unstructured_client/py.typed
49+
- src/unstructured_client/types/__init__.py
50+
- src/unstructured_client/types/basemodel.py
4151
- src/unstructured_client/utils/__init__.py
52+
- src/unstructured_client/utils/annotations.py
4253
- src/unstructured_client/utils/enums.py
54+
- src/unstructured_client/utils/eventstreaming.py
55+
- src/unstructured_client/utils/forms.py
56+
- src/unstructured_client/utils/headers.py
57+
- src/unstructured_client/utils/metadata.py
58+
- src/unstructured_client/utils/queryparams.py
59+
- src/unstructured_client/utils/requestbodies.py
4360
- src/unstructured_client/utils/retries.py
44-
- src/unstructured_client/utils/utils.py
61+
- src/unstructured_client/utils/security.py
62+
- src/unstructured_client/utils/serializers.py
63+
- src/unstructured_client/utils/url.py
64+
- src/unstructured_client/utils/values.py
4565
- src/unstructured_client/models/errors/sdkerror.py
4666
- src/unstructured_client/models/operations/partition.py
67+
- src/unstructured_client/models/operations/__init__.py
4768
- src/unstructured_client/models/errors/httpvalidationerror.py
4869
- src/unstructured_client/models/errors/servererror.py
70+
- src/unstructured_client/models/errors/__init__.py
4971
- src/unstructured_client/models/shared/validationerror.py
5072
- src/unstructured_client/models/shared/partition_parameters.py
5173
- src/unstructured_client/models/shared/security.py
52-
- src/unstructured_client/models/__init__.py
53-
- src/unstructured_client/models/errors/__init__.py
54-
- src/unstructured_client/models/operations/__init__.py
5574
- src/unstructured_client/models/shared/__init__.py
5675
- docs/models/operations/partitionrequest.md
5776
- docs/models/operations/partitionresponse.md
@@ -71,3 +90,4 @@ generatedFiles:
7190
- src/unstructured_client/_hooks/sdkhooks.py
7291
- src/unstructured_client/_hooks/types.py
7392
- src/unstructured_client/_hooks/__init__.py
93+
- CONTRIBUTING.md

CONTRIBUTING.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Contributing to This Repository
2+
3+
Thank you for your interest in contributing to this repository. Please note that this repository contains generated code. As such, we do not accept direct changes or pull requests. Instead, we encourage you to follow the guidelines below to report issues and suggest improvements.
4+
5+
## How to Report Issues
6+
7+
If you encounter any bugs or have suggestions for improvements, please open an issue on GitHub. When reporting an issue, please provide as much detail as possible to help us reproduce the problem. This includes:
8+
9+
- A clear and descriptive title
10+
- Steps to reproduce the issue
11+
- Expected and actual behavior
12+
- Any relevant logs, screenshots, or error messages
13+
- Information about your environment (e.g., operating system, software versions)
14+
- For example can be collected using the `npx envinfo` command from your terminal if you have Node.js installed
15+
16+
## Issue Triage and Upstream Fixes
17+
18+
We will review and triage issues as quickly as possible. Our goal is to address bugs and incorporate improvements in the upstream source code. Fixes will be included in the next generation of the generated code.
19+
20+
## Contact
21+
22+
If you have any questions or need further assistance, please feel free to reach out by opening an issue.
23+
24+
Thank you for your understanding and cooperation!
25+
26+
The Maintainers

README.md

Lines changed: 148 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,15 @@ Please refer to the [Unstructured docs](https://docs.unstructured.io/api-referen
3030
<!-- Start SDK Installation [installation] -->
3131
## SDK Installation
3232

33+
PIP
3334
```bash
3435
pip install unstructured-client
3536
```
37+
38+
Poetry
39+
```bash
40+
poetry add unstructured-client
41+
```
3642
<!-- End SDK Installation [installation] -->
3743

3844
## SDK Example Usage
@@ -116,29 +122,30 @@ Some of the endpoints in this SDK support retries. If you use the SDK without an
116122

117123
To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call:
118124
```python
119-
import unstructured_client
120-
from unstructured_client.models import operations, shared
125+
from unstructured_client import UnstructuredClient
126+
from unstructured_client.models import shared
121127
from unstructured_client.utils import BackoffStrategy, RetryConfig
122128

123-
s = unstructured_client.UnstructuredClient(
129+
s = UnstructuredClient(
124130
api_key_auth="YOUR_API_KEY",
125131
)
126132

127133

128-
res = s.general.partition(request=operations.PartitionRequest(
129-
partition_parameters=shared.PartitionParameters(
130-
files=shared.Files(
131-
content='0x2cC94b2FEF'.encode(),
132-
file_name='your_file_here',
133-
),
134-
split_pdf_page_range=[
134+
res = s.general.partition(request={
135+
"partition_parameters": {
136+
"files": {
137+
"content": open("<file_path>", "rb"),
138+
"file_name": "your_file_here",
139+
},
140+
"chunking_strategy": shared.ChunkingStrategy.BY_TITLE,
141+
"split_pdf_page_range": [
135142
1,
136143
10,
137144
],
138-
strategy=shared.Strategy.AUTO,
139-
),
140-
),
141-
RetryConfig('backoff', BackoffStrategy(1, 50, 1.1, 100), False))
145+
"strategy": shared.Strategy.HI_RES,
146+
},
147+
},
148+
RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
142149

143150
if res.elements is not None:
144151
# handle response
@@ -148,29 +155,30 @@ if res.elements is not None:
148155

149156
If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK:
150157
```python
151-
import unstructured_client
152-
from unstructured_client.models import operations, shared
158+
from unstructured_client import UnstructuredClient
159+
from unstructured_client.models import shared
153160
from unstructured_client.utils import BackoffStrategy, RetryConfig
154161

155-
s = unstructured_client.UnstructuredClient(
156-
retry_config=RetryConfig('backoff', BackoffStrategy(1, 50, 1.1, 100), False),
162+
s = UnstructuredClient(
163+
retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
157164
api_key_auth="YOUR_API_KEY",
158165
)
159166

160167

161-
res = s.general.partition(request=operations.PartitionRequest(
162-
partition_parameters=shared.PartitionParameters(
163-
files=shared.Files(
164-
content='0x2cC94b2FEF'.encode(),
165-
file_name='your_file_here',
166-
),
167-
split_pdf_page_range=[
168+
res = s.general.partition(request={
169+
"partition_parameters": {
170+
"files": {
171+
"content": open("<file_path>", "rb"),
172+
"file_name": "your_file_here",
173+
},
174+
"chunking_strategy": shared.ChunkingStrategy.BY_TITLE,
175+
"split_pdf_page_range": [
168176
1,
169177
10,
170178
],
171-
strategy=shared.Strategy.AUTO,
172-
),
173-
))
179+
"strategy": shared.Strategy.HI_RES,
180+
},
181+
})
174182

175183
if res.elements is not None:
176184
# handle response
@@ -182,16 +190,81 @@ if res.elements is not None:
182190
<!-- Start Custom HTTP Client [http-client] -->
183191
## Custom HTTP Client
184192

185-
The Python SDK makes API calls using the [requests](https://pypi.org/project/requests/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom `requests.Session` object.
193+
The Python SDK makes API calls using the [httpx](https://www.python-httpx.org/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.
194+
Depending on whether you are using the sync or async version of the SDK, you can pass an instance of `HttpClient` or `AsyncHttpClient` respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls.
195+
This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of `httpx.Client` or `httpx.AsyncClient` directly.
186196

187197
For example, you could specify a header for every request that this sdk makes as follows:
188198
```python
189-
import unstructured_client
190-
import requests
199+
from unstructured_client import UnstructuredClient
200+
import httpx
201+
202+
http_client = httpx.Client(headers={"x-custom-header": "someValue"})
203+
s = UnstructuredClient(client=http_client)
204+
```
191205

192-
http_client = requests.Session()
193-
http_client.headers.update({'x-custom-header': 'someValue'})
194-
s = unstructured_client.UnstructuredClient(client=http_client)
206+
or you could wrap the client with your own custom logic:
207+
```python
208+
from unstructured_client import UnstructuredClient
209+
from unstructured_client.httpclient import AsyncHttpClient
210+
import httpx
211+
212+
class CustomClient(AsyncHttpClient):
213+
client: AsyncHttpClient
214+
215+
def __init__(self, client: AsyncHttpClient):
216+
self.client = client
217+
218+
async def send(
219+
self,
220+
request: httpx.Request,
221+
*,
222+
stream: bool = False,
223+
auth: Union[
224+
httpx._types.AuthTypes, httpx._client.UseClientDefault, None
225+
] = httpx.USE_CLIENT_DEFAULT,
226+
follow_redirects: Union[
227+
bool, httpx._client.UseClientDefault
228+
] = httpx.USE_CLIENT_DEFAULT,
229+
) -> httpx.Response:
230+
request.headers["Client-Level-Header"] = "added by client"
231+
232+
return await self.client.send(
233+
request, stream=stream, auth=auth, follow_redirects=follow_redirects
234+
)
235+
236+
def build_request(
237+
self,
238+
method: str,
239+
url: httpx._types.URLTypes,
240+
*,
241+
content: Optional[httpx._types.RequestContent] = None,
242+
data: Optional[httpx._types.RequestData] = None,
243+
files: Optional[httpx._types.RequestFiles] = None,
244+
json: Optional[Any] = None,
245+
params: Optional[httpx._types.QueryParamTypes] = None,
246+
headers: Optional[httpx._types.HeaderTypes] = None,
247+
cookies: Optional[httpx._types.CookieTypes] = None,
248+
timeout: Union[
249+
httpx._types.TimeoutTypes, httpx._client.UseClientDefault
250+
] = httpx.USE_CLIENT_DEFAULT,
251+
extensions: Optional[httpx._types.RequestExtensions] = None,
252+
) -> httpx.Request:
253+
return self.client.build_request(
254+
method,
255+
url,
256+
content=content,
257+
data=data,
258+
files=files,
259+
json=json,
260+
params=params,
261+
headers=headers,
262+
cookies=cookies,
263+
timeout=timeout,
264+
extensions=extensions,
265+
)
266+
267+
s = UnstructuredClient(async_client=CustomClient(httpx.AsyncClient()))
195268
```
196269
<!-- End Custom HTTP Client [http-client] -->
197270

@@ -202,6 +275,47 @@ s = unstructured_client.UnstructuredClient(client=http_client)
202275
<!-- No Server Selection -->
203276
<!-- No Authentication -->
204277

278+
<!-- Start File uploads [file-upload] -->
279+
## File uploads
280+
281+
Certain SDK methods accept file objects as part of a request body or multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.
282+
283+
> [!TIP]
284+
>
285+
> For endpoints that handle file uploads bytes arrays can also be used. However, using streams is recommended for large files.
286+
>
287+
288+
```python
289+
from unstructured_client import UnstructuredClient
290+
from unstructured_client.models import shared
291+
292+
s = UnstructuredClient(
293+
api_key_auth="YOUR_API_KEY",
294+
)
295+
296+
297+
res = s.general.partition(request={
298+
"partition_parameters": {
299+
"files": {
300+
"content": open("<file_path>", "rb"),
301+
"file_name": "your_file_here",
302+
},
303+
"chunking_strategy": shared.ChunkingStrategy.BY_TITLE,
304+
"split_pdf_page_range": [
305+
1,
306+
10,
307+
],
308+
"strategy": shared.Strategy.HI_RES,
309+
},
310+
})
311+
312+
if res.elements is not None:
313+
# handle response
314+
pass
315+
316+
```
317+
<!-- End File uploads [file-upload] -->
318+
205319
<!-- Placeholder for Future Speakeasy SDK Sections -->
206320

207321
### Maturity

0 commit comments

Comments
 (0)