| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
* Set the split_pdf_page default to true * Update the readme, add another reference back to our docs * Change some warning logs to info. The user should not be warned about default behavior for non pdf files
There was a problem hiding this comment.
Tested with non-pdf files, logging shows INFO then print out output elements
e.g.
INFO: Preparing to split document for partition.
INFO: Given file doesn't have '.pdf' extension, so splitting is not enabled.
INFO: Partitioning without split.
INFO: Successfully partitioned the document.
[
{
"type": "Title",
"element_id": "7366bfb62015d7f749e8c38e7284a60c",
"text": "Lorem ipsum dolor sit amet.",
"metadata": {
"category_depth": 0,
"filename": "fake.doc",
"languages": [
"por",
"cat"
],
"filetype": "application/msword"
}
}
]
Sorry, something went wrong.
Mirror of Unstructured-IO/unstructured-python-client#118 * Set the split_pdf_page default to true and run `make client-generate` locally. * Update the readme, add another reference back to our docs, bring back some autogenerated sections like in the python repo * Change some warning logs to info. The user should not be warned about default behavior for non pdf files # Testing Use the client locally and verify that split mode is the default, and that the dev experience is good * Create a new test dir and run `npm init -y; npm install typescript tsx` * Check out this branch and install from your test dir: `npm i file:~/repos/unstructured-js-client` * Run this sample script. Try some different files in and verify that the logging and results look acceptable. `npx tsx unstructured.ts` ``` import { UnstructuredClient } from "unstructured-client"; import { PartitionResponse } from "unstructured-client/sdk/models/operations"; import { Strategy } from "unstructured-client/sdk/models/shared"; import * as fs from "fs"; const key = "free-api-key"; const client = new UnstructuredClient({ security: { apiKeyAuth: key, }, }); const filename = "fake-html.html"; const data = fs.readFileSync(filename); client.general.partition({ partitionParameters: { files: { content: data, fileName: filename, }, strategy: Strategy.Auto, } }).then((res: PartitionResponse) => { if (res.statusCode == 200) { console.log(res.elements); } }).catch((e) => { if (e.statusCode) { console.log(e.statusCode); console.log(e.body); } else { console.log(e); } }); ```
| Back | FazBrowse Home | New Git URL |
Testing
Use the client locally and verify that split mode is the default, and that the client behavior is consistent with older versions.
from unstructured_client import UnstructuredClient from unstructured_client.models import shared, operations import json api_key = "free-api-key" filename = "_sample_docs/layout-parser-paper.pdf" s = UnstructuredClient( api_key_auth=api_key, ) with open(filename, "rb") as f: files=shared.Files( content=f.read(), file_name=filename, ) req = operations.PartitionRequest( shared.PartitionParameters( files=files, strategy=shared.Strategy.AUTO ), ) try: resp = s.general.partition(req) print(json.dumps(resp.elements, indent=4)) except Exception as e: print(e)