Skip to content

Commit da4191f

Browse files
authored
Update example snippet
1 parent 4f160ae commit da4191f

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

README.md

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,40 +35,37 @@ yarn add unstructured-client
3535
Only the `files` parameter is required. See the [general partition]([General](docs/sdks/general/README.md)) page for all available parameters.
3636

3737
```typescript
38-
import { Unstructured } from "unstructured-client";
38+
import { UnstructuredClient } from "unstructured-client";
3939
import { PartitionResponse } from "unstructured-client/dist/sdk/models/operations";
40+
import * as fs from "fs";
4041

41-
const sdk = new Unstructured({
42-
security: {
43-
apiKeyAuth: "YOUR_API_KEY",
44-
},
42+
const key = "YOUR-API-KEY";
43+
44+
const client = new UnstructuredClient({
45+
security: {
46+
apiKeyAuth: key,
47+
},
4548
});
4649

47-
sdk.general.partition({
48-
coordinates: false,
49-
encoding: "utf-8",
50-
files: {
51-
content: "distinctio".encode(),
52-
files: "quibusdam",
53-
},
54-
gzUncompressedContentType: "application/pdf",
55-
hiResModelName: "yolox",
56-
includePageBreaks: false,
57-
ocrLanguages: [
58-
"eng",
59-
],
60-
outputFormat: "application/json",
61-
pdfInferTableStructure: false,
62-
skipInferTableTypes: [
63-
"pdf",
64-
],
65-
strategy: "hi_res",
66-
xmlKeepTags: false,
50+
const filename = "sample-docs/layout-parser-paper.pdf";
51+
const data = fs.readFileSync(filename);
52+
53+
client.general.partition({
54+
files: {
55+
content: data,
56+
files: filename,
57+
},
58+
// Other partition params
59+
strategy: "fast",
6760
}).then((res: PartitionResponse) => {
68-
if (res.statusCode == 200) {
69-
// handle response
70-
}
61+
if (res.statusCode == 200) {
62+
console.log(res.elements);
63+
}
64+
}).catch((e) => {
65+
console.log(e.statusCode);
66+
console.log(e.body);
7167
});
68+
7269
```
7370

7471
<!-- Start Dev Containers -->

0 commit comments

Comments
 (0)