Nomad changes
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s

This commit is contained in:
Henrik Jess Nielsen
2026-06-01 23:40:55 +02:00
parent 72b1a0a6ed
commit b4c07d3693
5723 changed files with 1130655 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import type { ExtractionConfig } from "@kreuzberg/wasm";
import { extractBytes, initWasm } from "@kreuzberg/wasm";
async function extractWithConditionalConfig(fileSize: number) {
await initWasm();
const config: ExtractionConfig = {};
if (fileSize > 10 * 1024 * 1024) {
config.chunking = {
maxChars: 500,
chunkOverlap: 50,
};
}
if (fileSize < 1 * 1024 * 1024) {
config.images = {
extractImages: true,
targetDpi: 300,
};
}
config.ocr = {
enabled: fileSize < 50 * 1024 * 1024,
};
const bytes = new Uint8Array(await fetch("document.pdf").then((r) => r.arrayBuffer()));
const result = await extractBytes(bytes, "application/pdf", config);
return result;
}
extractWithConditionalConfig(5 * 1024 * 1024).then((_r) => console.log("Done"));