@llamaindex/liteparse 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -90,6 +90,34 @@ for (const s of screenshots) {
90
90
  }
91
91
  ```
92
92
 
93
+ ## Document Complexity
94
+
95
+ Before committing to a full parse, check whether a document needs OCR or heavier
96
+ processing. `isComplex` is a cheap, text-layer-only pass that returns one entry per page
97
+ with a `needsOcr` verdict and the signals behind it — useful for routing documents to
98
+ different pipelines, rejecting ones you can't handle, or estimating cost.
99
+
100
+ ```typescript
101
+ const parser = new LiteParse();
102
+ const pages = await parser.isComplex('document.pdf');
103
+
104
+ if (pages.some((p) => p.needsOcr)) {
105
+ // Route to the OCR-enabled pipeline
106
+ const result = await parser.parse('document.pdf');
107
+ } else {
108
+ // Cheap path — skip OCR entirely
109
+ const result = await new LiteParse({ ocrEnabled: false }).parse('document.pdf');
110
+ }
111
+
112
+ // Inspect why specific pages were flagged
113
+ for (const page of pages.filter((p) => p.needsOcr)) {
114
+ console.log(`Page ${page.pageNumber}: ${page.reasons.join(', ')}`);
115
+ }
116
+ ```
117
+
118
+ `reasons` is one of `"scanned"`, `"no-text"`, `"sparse-text"`, `"embedded-images"`,
119
+ `"garbled"`, or `"vector-text"`. Raw bytes work here too.
120
+
93
121
  ## Supported Formats
94
122
 
95
123
  - PDF (`.pdf`)
@@ -107,4 +135,5 @@ lit parse document.pdf
107
135
  lit parse document.pdf --format json -o output.json
108
136
  lit screenshot document.pdf -o ./screenshots
109
137
  lit batch-parse ./input ./output
138
+ lit is-complex document.pdf
110
139
  ```
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llamaindex/liteparse",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Fast, lightweight PDF and document parsing with spatial text extraction",
5
5
  "type": "module",
6
6
  "main": "./dist/lib.js",
@@ -54,13 +54,13 @@
54
54
  "typescript": "~5.9.2"
55
55
  },
56
56
  "optionalDependencies": {
57
- "@llamaindex/liteparse-darwin-arm64": "2.2.0",
58
- "@llamaindex/liteparse-darwin-x64": "2.2.0",
59
- "@llamaindex/liteparse-linux-arm64-gnu": "2.2.0",
60
- "@llamaindex/liteparse-linux-x64-gnu": "2.2.0",
61
- "@llamaindex/liteparse-win32-arm64-msvc": "2.2.0",
62
- "@llamaindex/liteparse-win32-x64-msvc": "2.2.0",
63
- "@llamaindex/liteparse-linux-x64-musl": "2.2.0"
57
+ "@llamaindex/liteparse-darwin-arm64": "2.2.1",
58
+ "@llamaindex/liteparse-darwin-x64": "2.2.1",
59
+ "@llamaindex/liteparse-linux-arm64-gnu": "2.2.1",
60
+ "@llamaindex/liteparse-linux-x64-gnu": "2.2.1",
61
+ "@llamaindex/liteparse-win32-arm64-msvc": "2.2.1",
62
+ "@llamaindex/liteparse-win32-x64-msvc": "2.2.1",
63
+ "@llamaindex/liteparse-linux-x64-musl": "2.2.1"
64
64
  },
65
65
  "engines": {
66
66
  "node": ">=18.0.0"