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
@@ -115,9 +121,9 @@ Request parameters that correspond to file uploads can be passed as `bytes`, or
115
121
116
122
```python
117
123
from pathlib import Path
118
-
fromLandingAIAdeimportLandingai
124
+
fromlandingai_adeimportLandingAIADE
119
125
120
-
client =Landingai()
126
+
client =LandingAIADE()
121
127
122
128
client.parse(
123
129
document=Path("/path/to/file"),
@@ -128,27 +134,29 @@ The async client uses the exact same interface. If you pass a [`PathLike`](https
128
134
129
135
## Handling errors
130
136
131
-
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `LandingAIAde.APIConnectionError` is raised.
137
+
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `landingai_ade.APIConnectionError` is raised.
132
138
133
139
When the API returns a non-success status code (that is, 4xx or 5xx
134
-
response), a subclass of `LandingAIAde.APIStatusError` is raised, containing `status_code` and `response` properties.
140
+
response), a subclass of `landingai_ade.APIStatusError` is raised, containing `status_code` and `response` properties.
135
141
136
-
All errors inherit from `LandingAIAde.APIError`.
142
+
All errors inherit from `landingai_ade.APIError`.
137
143
138
144
```python
139
-
importLandingAIAde
140
-
fromLandingAIAdeimportLandingai
145
+
importlandingai_ade
146
+
fromlandingai_adeimportLandingAIADE
141
147
142
-
client =Landingai()
148
+
client =LandingAIADE()
143
149
144
150
try:
145
-
client.parse()
146
-
except LandingAIAde.APIConnectionError as e:
151
+
client.extract(
152
+
schema="schema",
153
+
)
154
+
except landingai_ade.APIConnectionError as e:
147
155
print("The server could not be reached")
148
156
print(e.__cause__) # an underlying Exception, likely raised within httpx.
149
-
exceptLandingAIAde.RateLimitError as e:
157
+
exceptlandingai_ade.RateLimitError as e:
150
158
print("A 429 status code was received; we should back off a bit.")
151
-
exceptLandingAIAde.APIStatusError as e:
159
+
exceptlandingai_ade.APIStatusError as e:
152
160
print("Another non-200-range status code was received")
153
161
print(e.status_code)
154
162
print(e.response)
@@ -176,16 +184,18 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ
176
184
You can use the `max_retries` option to configure or disable retry settings:
177
185
178
186
```python
179
-
fromLandingAIAdeimportLandingai
187
+
fromlandingai_adeimportLandingAIADE
180
188
181
189
# Configure the default for all requests:
182
-
client =Landingai(
190
+
client =LandingAIADE(
183
191
# default is 2
184
192
max_retries=0,
185
193
)
186
194
187
195
# Or, configure per-request:
188
-
client.with_options(max_retries=5).parse()
196
+
client.with_options(max_retries=5).extract(
197
+
schema="schema",
198
+
)
189
199
```
190
200
191
201
### Timeouts
@@ -194,21 +204,23 @@ By default requests time out after 1 minute. You can configure this with a `time
194
204
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:
@@ -221,10 +233,10 @@ Note that requests that time out are [retried twice by default](#retries).
221
233
222
234
We use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.
223
235
224
-
You can enable logging by setting the environment variable `LANDINGAI_LOG` to `info`.
236
+
You can enable logging by setting the environment variable `LANDINGAI_ADE_LOG` to `info`.
225
237
226
238
```shell
227
-
$ exportLANDINGAI_LOG=info
239
+
$ exportLANDINGAI_ADE_LOG=info
228
240
```
229
241
230
242
Or to `debug` for more verbose logging.
@@ -246,19 +258,21 @@ if response.my_field is None:
246
258
The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,
247
259
248
260
```py
249
-
fromLandingAIAdeimportLandingai
261
+
fromlandingai_adeimportLandingAIADE
250
262
251
-
client = Landingai()
252
-
response = client.with_raw_response.parse()
263
+
client = LandingAIADE()
264
+
response = client.with_raw_response.extract(
265
+
schema="schema",
266
+
)
253
267
print(response.headers.get('X-My-Header'))
254
268
255
-
client = response.parse() # get the object that `parse()` would have returned
256
-
print(client.chunks)
269
+
client = response.parse() # get the object that `extract()` would have returned
270
+
print(client.extraction)
257
271
```
258
272
259
-
These methods return an [`APIResponse`](https://github.com/landing-ai/ade-python/tree/main/src/LandingAIAde/_response.py) object.
273
+
These methods return an [`APIResponse`](https://github.com/landing-ai/ade-python/tree/main/src/landingai_ade/_response.py) object.
260
274
261
-
The async client returns an [`AsyncAPIResponse`](https://github.com/landing-ai/ade-python/tree/main/src/LandingAIAde/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
275
+
The async client returns an [`AsyncAPIResponse`](https://github.com/landing-ai/ade-python/tree/main/src/landingai_ade/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
262
276
263
277
#### `.with_streaming_response`
264
278
@@ -267,7 +281,9 @@ The above interface eagerly reads the full response body when you make the reque
267
281
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
268
282
269
283
```python
270
-
with client.with_streaming_response.parse() as response:
284
+
with client.with_streaming_response.extract(
285
+
schema="schema",
286
+
) as response:
271
287
print(response.headers.get("X-My-Header"))
272
288
273
289
for line in response.iter_lines():
@@ -320,10 +336,10 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c
By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.
344
360
345
361
```py
346
-
fromLandingAIAdeimportLandingai
362
+
fromlandingai_adeimportLandingAIADE
347
363
348
-
withLandingai() as client:
364
+
withLandingAIADE() as client:
349
365
# make requests here
350
366
...
351
367
@@ -371,8 +387,8 @@ If you've upgraded to the latest version but aren't seeing any new features you
371
387
You can determine the version that is being used at runtime with:
0 commit comments