Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/hooks/custom/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export const PARTITION_FORM_SPLIT_PDF_PAGE_RANGE_KEY = "split_pdf_page_range";
export const PARTITION_FORM_SPLIT_PDF_CONCURRENCY_LEVEL =
"split_pdf_concurrency_level";

export const EXTRACT_IMAGE_BLOCK_TYPES = "extract_image_block_types";

export const DEFAULT_STARTING_PAGE_NUMBER = 1;
export const DEFAULT_NUMBER_OF_PARALLEL_REQUESTS = 8;
export const DEFAULT_SPLIT_PDF_ALLOW_FAILED_KEY = false;
Expand Down
10 changes: 10 additions & 0 deletions src/hooks/custom/utils/request.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
EXTRACT_IMAGE_BLOCK_TYPES,
PARTITION_FORM_FILES_KEY,
PARTITION_FORM_SPLIT_PDF_PAGE_KEY,
PARTITION_FORM_STARTING_PAGE_NUMBER_KEY,
Expand Down Expand Up @@ -90,5 +91,14 @@ export async function prepareRequestBody(
PARTITION_FORM_STARTING_PAGE_NUMBER_KEY,
startingPageNumber.toString()
);

if (formData.has(EXTRACT_IMAGE_BLOCK_TYPES)) {
newFormData.delete(EXTRACT_IMAGE_BLOCK_TYPES);
const extractImageBlockTypes = (formData.get(EXTRACT_IMAGE_BLOCK_TYPES)?.toString() || "").split(",");
for(const blockType of extractImageBlockTypes) {
newFormData.append(EXTRACT_IMAGE_BLOCK_TYPES, blockType);
}
}

return newFormData;
}
3 changes: 2 additions & 1 deletion test/integration/SplitPdfHook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ describe("SplitPDF succeeds for large PDF with high concurrency", () => {
splitPdfPage: true,
strategy: Strategy.HiRes,
splitPdfAllowFailed: false,
splitPdfConcurrencyLevel: 15
splitPdfConcurrencyLevel: 15,
extractImageBlockTypes: ["Image", "Table"]
};

const res: PartitionResponse = await client.general.partition({
Expand Down
Loading