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,53 @@
# Custom Plugin Usage Pattern
Demonstrate the pattern for using registered plugins during document extraction.
```typescript title="WASM"
import init, { extractBytes, registerPostProcessor } from "kreuzberg-wasm";
await init();
// Register a custom post-processor
const customProcessor = {
processingStage: () => "post-extraction",
process: (result) => {
console.log("Post-processor: enriching extraction result");
return {
...result,
metadata: {
...result.metadata,
enriched: true,
processorApplied: "customProcessor",
},
};
},
};
registerPostProcessor(customProcessor);
// Extract document with registered plugin
async function extractWithPlugins(fileBytes, mimeType) {
const config = {
ocr: null,
chunking: null,
enableQualityProcessing: false,
};
// Extraction automatically applies registered post-processors
const result = await extractBytes(fileBytes, mimeType, config);
console.log("Extraction complete");
console.log("Plugins applied:", result.metadata?.enriched);
return result;
}
// Usage
const pdfBytes = new Uint8Array([
/* PDF content */
]);
const result = await extractWithPlugins(pdfBytes, "application/pdf");
console.log("Final result:", result);
```
The extraction pipeline automatically applies all registered plugins in the correct order.