You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+191Lines changed: 191 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -96,6 +96,197 @@ s = unstructured_client.UnstructuredClient(
96
96
97
97
<!-- No Pagination -->
98
98
99
+
100
+
101
+
<!-- Start Error Handling -->
102
+
# Error Handling
103
+
104
+
Handling errors in your SDK should largely match your expectations. All operations return a response object or raise an error. If Error objects are specified in your OpenAPI Spec, the SDK will raise the appropriate Error type.
105
+
106
+
107
+
## Example
108
+
109
+
```python
110
+
import unstructured_client
111
+
from unstructured_client.models import shared
112
+
113
+
s = unstructured_client.UnstructuredClient(
114
+
api_key_auth="YOUR_API_KEY",
115
+
)
116
+
117
+
req = shared.PartitionParameters(
118
+
chunking_strategy='by_title',
119
+
combine_under_n_chars=500,
120
+
encoding='utf-8',
121
+
files=shared.PartitionParametersFiles(
122
+
content='+WmI5Q)|yy'.encode(),
123
+
files='string',
124
+
),
125
+
gz_uncompressed_content_type='application/pdf',
126
+
hi_res_model_name='yolox',
127
+
languages=[
128
+
'[',
129
+
'e',
130
+
'n',
131
+
'g',
132
+
']',
133
+
],
134
+
new_after_n_chars=1500,
135
+
output_format='application/json',
136
+
skip_infer_table_types=[
137
+
'p',
138
+
'd',
139
+
'f',
140
+
],
141
+
strategy='hi_res',
142
+
)
143
+
144
+
res =None
145
+
try:
146
+
res = s.general.partition(req)
147
+
148
+
except (HTTPValidationError) as e:
149
+
print(e) # handle exception
150
+
151
+
152
+
if res.elements isnotNone:
153
+
# handle response
154
+
pass
155
+
```
156
+
<!-- End Error Handling -->
157
+
158
+
159
+
160
+
<!-- Start Server Selection -->
161
+
# Server Selection
162
+
163
+
## Select Server by Name
164
+
165
+
You can override the default server globally by passing a server name to the `server: str` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:
166
+
167
+
| Name | Server | Variables |
168
+
| ----- | ------ | --------- |
169
+
|`prod`|`https://api.unstructured.io`| None |
170
+
|`local`|`http://localhost:8000`| None |
171
+
172
+
For example:
173
+
174
+
175
+
```python
176
+
import unstructured_client
177
+
from unstructured_client.models import shared
178
+
179
+
s = unstructured_client.UnstructuredClient(
180
+
api_key_auth="YOUR_API_KEY",
181
+
server="local"
182
+
)
183
+
184
+
req = shared.PartitionParameters(
185
+
chunking_strategy='by_title',
186
+
combine_under_n_chars=500,
187
+
encoding='utf-8',
188
+
files=shared.PartitionParametersFiles(
189
+
content='+WmI5Q)|yy'.encode(),
190
+
files='string',
191
+
),
192
+
gz_uncompressed_content_type='application/pdf',
193
+
hi_res_model_name='yolox',
194
+
languages=[
195
+
'[',
196
+
'e',
197
+
'n',
198
+
'g',
199
+
']',
200
+
],
201
+
new_after_n_chars=1500,
202
+
output_format='application/json',
203
+
skip_infer_table_types=[
204
+
'p',
205
+
'd',
206
+
'f',
207
+
],
208
+
strategy='hi_res',
209
+
)
210
+
211
+
res = s.general.partition(req)
212
+
213
+
if res.elements isnotNone:
214
+
# handle response
215
+
pass
216
+
```
217
+
218
+
219
+
## Override Server URL Per-Client
220
+
221
+
The default server can also be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
222
+
223
+
224
+
```python
225
+
import unstructured_client
226
+
from unstructured_client.models import shared
227
+
228
+
s = unstructured_client.UnstructuredClient(
229
+
api_key_auth="YOUR_API_KEY",
230
+
server_url="https://api.unstructured.io"
231
+
)
232
+
233
+
req = shared.PartitionParameters(
234
+
chunking_strategy='by_title',
235
+
combine_under_n_chars=500,
236
+
encoding='utf-8',
237
+
files=shared.PartitionParametersFiles(
238
+
content='+WmI5Q)|yy'.encode(),
239
+
files='string',
240
+
),
241
+
gz_uncompressed_content_type='application/pdf',
242
+
hi_res_model_name='yolox',
243
+
languages=[
244
+
'[',
245
+
'e',
246
+
'n',
247
+
'g',
248
+
']',
249
+
],
250
+
new_after_n_chars=1500,
251
+
output_format='application/json',
252
+
skip_infer_table_types=[
253
+
'p',
254
+
'd',
255
+
'f',
256
+
],
257
+
strategy='hi_res',
258
+
)
259
+
260
+
res = s.general.partition(req)
261
+
262
+
if res.elements isnotNone:
263
+
# handle response
264
+
pass
265
+
```
266
+
<!-- End Server Selection -->
267
+
268
+
269
+
270
+
<!-- Start Custom HTTP Client -->
271
+
# Custom HTTP Client
272
+
273
+
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.
274
+
275
+
276
+
For example, you could specify a header for every request that your sdk makes as follows:
0 commit comments