Skip to content

Commit 03d48cf

Browse files
committed
fixed input to extractImageBlockType to be sent to the server properly
1 parent 4b38b39 commit 03d48cf

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/hooks/custom/common.ts

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export const PARTITION_FORM_SPLIT_PDF_PAGE_RANGE_KEY = "split_pdf_page_range";
1818
export const PARTITION_FORM_SPLIT_PDF_CONCURRENCY_LEVEL =
1919
"split_pdf_concurrency_level";
2020

21+
export const EXTRACT_IMAGE_BLOCK_TYPES = "extract_image_block_types";
22+
2123
export const DEFAULT_STARTING_PAGE_NUMBER = 1;
2224
export const DEFAULT_NUMBER_OF_PARALLEL_REQUESTS = 8;
2325
export const DEFAULT_SPLIT_PDF_ALLOW_FAILED_KEY = false;

src/hooks/custom/utils/request.ts

+10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
EXTRACT_IMAGE_BLOCK_TYPES,
23
PARTITION_FORM_FILES_KEY,
34
PARTITION_FORM_SPLIT_PDF_PAGE_KEY,
45
PARTITION_FORM_STARTING_PAGE_NUMBER_KEY,
@@ -90,5 +91,14 @@ export async function prepareRequestBody(
9091
PARTITION_FORM_STARTING_PAGE_NUMBER_KEY,
9192
startingPageNumber.toString()
9293
);
94+
95+
if (formData.has(EXTRACT_IMAGE_BLOCK_TYPES)) {
96+
newFormData.delete(EXTRACT_IMAGE_BLOCK_TYPES);
97+
const extractImageBlockTypes = (formData.get(EXTRACT_IMAGE_BLOCK_TYPES)?.toString() || "").split(",");
98+
for(const blockType of extractImageBlockTypes) {
99+
newFormData.append(EXTRACT_IMAGE_BLOCK_TYPES, blockType);
100+
}
101+
}
102+
93103
return newFormData;
94104
}

test/integration/SplitPdfHook.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,8 @@ describe("SplitPDF succeeds for large PDF with high concurrency", () => {
379379
splitPdfPage: true,
380380
strategy: Strategy.HiRes,
381381
splitPdfAllowFailed: false,
382-
splitPdfConcurrencyLevel: 15
382+
splitPdfConcurrencyLevel: 15,
383+
extractImageBlockTypes: ["Image", "Table"]
383384
};
384385

385386
const res: PartitionResponse = await client.general.partition({

0 commit comments

Comments
 (0)