@heripo/pdf-parser 0.1.28 → 0.1.29

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.
Files changed (3) hide show
  1. package/README.ko.md +87 -10
  2. package/README.md +88 -10
  3. package/package.json +5 -5
package/README.ko.md CHANGED
@@ -21,6 +21,7 @@
21
21
  - [설치](#설치)
22
22
  - [사용법](#사용법)
23
23
  - [OCR 전략 시스템](#ocr-전략-시스템)
24
+ - [Review Assistance](#review-assistance)
24
25
  - [문서 유형 검증](#문서-유형-검증)
25
26
  - [대용량 PDF 청크 변환](#대용량-pdf-청크-변환)
26
27
  - [이미지 PDF 폴백](#이미지-pdf-폴백)
@@ -30,6 +31,7 @@
30
31
  - [시스템 의존성 상세](#시스템-의존성-상세)
31
32
  - [API 문서](#api-문서)
32
33
  - [문제 해결](#문제-해결)
34
+ - [후원](#후원)
33
35
  - [라이선스](#라이선스)
34
36
 
35
37
  ## 주요 기능
@@ -42,6 +44,7 @@
42
44
  - **문서 유형 검증**: LLM 기반 고고학 보고서 여부 검증 (선택)
43
45
  - **청크 변환**: 대용량 PDF를 청크로 분할하여 안정적으로 처리
44
46
  - **이미지 PDF 폴백**: 변환 실패 시 이미지 기반 PDF로 자동 재시도
47
+ - **Review Assistance**: 선택적 page-level VLM review로 audit proposal을 기록하고 고신뢰도 수정만 자동 적용
45
48
  - **AbortSignal 지원**: 진행 중인 파싱 작업 취소
46
49
  - **서버 크래시 복구**: ECONNREFUSED 발생 시 docling-serve 자동 재시작
47
50
 
@@ -49,7 +52,7 @@
49
52
 
50
53
  ### 시스템 요구사항
51
54
 
52
- - **macOS** with Apple Silicon (M1/M2/M3) - 최적 성능을 위해 권장
55
+ - **macOS** with Apple Silicon (M1/M2/M3/M4/M5) - 최적 성능을 위해 권장
53
56
  - **macOS** with Intel - 지원되지만 속도가 느림
54
57
  - **Linux/Windows** - 현재 지원하지 않음
55
58
 
@@ -61,7 +64,7 @@
61
64
  brew install node
62
65
  ```
63
66
 
64
- #### 2. pnpm >= 9.0.0
67
+ #### 2. pnpm >= 10.0.0
65
68
 
66
69
  ```bash
67
70
  npm install -g pnpm
@@ -123,13 +126,13 @@ brew install imagemagick ghostscript
123
126
 
124
127
  ```bash
125
128
  # npm으로 설치
126
- npm install @heripo/pdf-parser
129
+ npm install @heripo/pdf-parser @heripo/logger
127
130
 
128
131
  # pnpm으로 설치
129
- pnpm add @heripo/pdf-parser
132
+ pnpm add @heripo/pdf-parser @heripo/logger
130
133
 
131
134
  # yarn으로 설치
132
- yarn add @heripo/pdf-parser
135
+ yarn add @heripo/pdf-parser @heripo/logger
133
136
  ```
134
137
 
135
138
  ## 사용법
@@ -140,7 +143,12 @@ yarn add @heripo/pdf-parser
140
143
  import { Logger } from '@heripo/logger';
141
144
  import { PDFParser } from '@heripo/pdf-parser';
142
145
 
143
- const logger = Logger(...);
146
+ const logger = new Logger({
147
+ debug: (...args) => console.debug('[heripo]', ...args),
148
+ info: (...args) => console.info('[heripo]', ...args),
149
+ warn: (...args) => console.warn('[heripo]', ...args),
150
+ error: (...args) => console.error('[heripo]', ...args),
151
+ });
144
152
 
145
153
  // PDFParser 인스턴스 생성 (logger는 필수)
146
154
  const pdfParser = new PDFParser({
@@ -154,13 +162,13 @@ await pdfParser.init();
154
162
  // PDF 파싱
155
163
  const tokenUsageReport = await pdfParser.parse(
156
164
  'file:///path/to/report.pdf', // PDF URL (file:// 또는 http://)
157
- 'report-001', // 리포트 ID
165
+ 'report-001', // 리포트 ID
158
166
  async (outputPath) => {
159
167
  // 변환 완료 콜백
160
168
  console.log('PDF 변환 완료:', outputPath);
161
169
  },
162
- false, // cleanupAfterCallback
163
- {}, // PDFConvertOptions
170
+ false, // cleanupAfterCallback
171
+ {}, // PDFConvertOptions
164
172
  );
165
173
 
166
174
  // 토큰 사용량 리포트 (LLM 사용이 없으면 null)
@@ -201,6 +209,15 @@ const tokenUsageReport = await pdfParser.parse(
201
209
  // 문서 유형 검증
202
210
  documentValidationModel: openai('gpt-5.1'),
203
211
 
212
+ // 선택적 page-level review assistance
213
+ reviewAssistance: {
214
+ enabled: true,
215
+ autoApplyThreshold: 0.85,
216
+ proposalThreshold: 0.5,
217
+ outputLanguage: 'ko-KR',
218
+ },
219
+ onReviewAssistanceProgress: (event) => console.log(event),
220
+
204
221
  // 대용량 PDF 청크 변환
205
222
  chunkedConversion: true,
206
223
  chunkSize: 50,
@@ -273,6 +290,42 @@ const tokenUsageReport = await pdfParser.parse(
273
290
  );
274
291
  ```
275
292
 
293
+ ## Review Assistance
294
+
295
+ `reviewAssistance`는 Docling 변환 후 선택적으로 실행되는 page-level VLM
296
+ review입니다. 렌더링된 페이지 이미지, 텍스트, 테이블, 캡션, 그림, reading
297
+ order, role, bounding box, 도메인 패턴을 점검하고, 고신뢰도 수정만
298
+ `result.json`에 적용하면서 audit report를 남깁니다.
299
+
300
+ ```typescript
301
+ const tokenUsageReport = await pdfParser.parse(
302
+ 'file:///path/to/input.pdf',
303
+ 'report-001',
304
+ async (outputPath) => console.log(outputPath),
305
+ false,
306
+ {
307
+ strategySamplerModel: openai('gpt-5.1'),
308
+ vlmProcessorModel: openai('gpt-5.1'),
309
+ reviewAssistance: {
310
+ enabled: true,
311
+ autoApplyThreshold: 0.85,
312
+ proposalThreshold: 0.5,
313
+ maxRetries: 3,
314
+ temperature: 0,
315
+ outputLanguage: 'ko-KR',
316
+ },
317
+ onReviewAssistanceProgress: (event) => {
318
+ console.log(event.substage, event.status, event.pageNo);
319
+ },
320
+ },
321
+ );
322
+ ```
323
+
324
+ Review Assistance는 로컬 `file://` PDF와 `vlmProcessorModel` 또는
325
+ `strategySamplerModel`이 필요합니다. 고신뢰도 수정은 `result.json`에 적용하고,
326
+ 원본 snapshot은 `result_review_origin.json`, `result_ocr_origin.json`에 보존하며,
327
+ 페이지별 결정, 이슈, proposal, 요약 count는 `review_assistance.json`에 기록합니다.
328
+
276
329
  ## 문서 유형 검증
277
330
 
278
331
  LLM 기반으로 PDF가 고고학 발굴조사보고서인지 검증하는 선택적 기능입니다. `documentValidationModel`을 제공하면 파서가 PDF에서 텍스트를 추출하고 LLM을 사용하여 문서 유형을 확인한 후 처리합니다. 검증에 실패하면 `InvalidDocumentTypeError`가 발생합니다.
@@ -404,7 +457,7 @@ try {
404
457
  ### 핵심 장점
405
458
 
406
459
  - **비용**: 클라우드 OCR 대비 100배 이상 저렴 (무료)
407
- - **성능**: Apple Silicon M1/M2/M3에서 GPU 가속으로 빠른 처리
460
+ - **성능**: Apple Silicon M1/M2/M3/M4/M5에서 GPU 가속으로 빠른 처리
408
461
  - **품질**: 복잡한 레이아웃의 문서도 정확히 인식
409
462
  - **프라이버시**: 문서가 외부 서버로 전송되지 않음
410
463
 
@@ -525,6 +578,10 @@ type PDFConvertOptions = {
525
578
  document_timeout?: number; // 문서 처리 타임아웃 (초)
526
579
  documentValidationModel?: LanguageModel; // 문서 유형 검증용 LLM
527
580
 
581
+ // Review Assistance
582
+ reviewAssistance?: boolean | ReviewAssistanceOptions; // 선택적 page-level review
583
+ onReviewAssistanceProgress?: (event: ReviewAssistanceProgressEvent) => void; // 진행 상황 callback
584
+
528
585
  // 청크 변환 (대용량 PDF)
529
586
  chunkedConversion?: boolean; // 청크 변환 활성화
530
587
  chunkSize?: number; // 청크당 페이지 수
@@ -537,6 +594,19 @@ type PDFConvertOptions = {
537
594
  };
538
595
  ```
539
596
 
597
+ ### ReviewAssistanceOptions
598
+
599
+ ```typescript
600
+ interface ReviewAssistanceOptions {
601
+ enabled?: boolean; // page-level review assistance 활성화
602
+ autoApplyThreshold?: number; // 자동 적용 최소 confidence (기본값: 0.85)
603
+ proposalThreshold?: number; // sidecar proposal 최소 confidence (기본값: 0.5)
604
+ maxRetries?: number; // page-level VLM 호출별 최대 재시도 횟수 (기본값: 3)
605
+ temperature?: number; // VLM 생성 temperature (기본값: 0)
606
+ outputLanguage?: string; // 사람이 읽는 review reason 언어 (기본값: en-US)
607
+ }
608
+ ```
609
+
540
610
  ### ConvertWithStrategyResult
541
611
 
542
612
  ```typescript
@@ -665,6 +735,13 @@ Docling SDK의 로컬 OCR은 macOS에서 Apple Metal GPU 가속을 활용해 성
665
735
  - [@heripo/document-processor](../document-processor) - 문서 구조 분석 및 LLM 처리
666
736
  - [@heripo/model](../model) - 데이터 모델 및 타입 정의
667
737
 
738
+ ## 후원
739
+
740
+ heripo lab의 오픈소스 연구를 후원하려면 다음 경로를 이용할 수 있습니다:
741
+
742
+ - [Open Collective](https://opencollective.com/heripo-project): 전반적인 프로젝트 후원
743
+ - [fairy.hada.io/@heripo](https://fairy.hada.io/@heripo): 한국인 개인 후원자를 위한 원화 결제
744
+
668
745
  ## 라이선스
669
746
 
670
747
  이 패키지는 [Apache License 2.0](../../LICENSE) 라이선스 하에 배포됩니다.
package/README.md CHANGED
@@ -21,6 +21,7 @@
21
21
  - [Installation](#installation)
22
22
  - [Usage](#usage)
23
23
  - [OCR Strategy System](#ocr-strategy-system)
24
+ - [Review Assistance](#review-assistance)
24
25
  - [Document Type Validation](#document-type-validation)
25
26
  - [Large PDF Chunked Conversion](#large-pdf-chunked-conversion)
26
27
  - [Image PDF Fallback](#image-pdf-fallback)
@@ -30,6 +31,7 @@
30
31
  - [System Dependencies Details](#system-dependencies-details)
31
32
  - [API Documentation](#api-documentation)
32
33
  - [Troubleshooting](#troubleshooting)
34
+ - [Sponsor](#sponsor)
33
35
  - [License](#license)
34
36
 
35
37
  ## Key Features
@@ -42,6 +44,7 @@
42
44
  - **Document Type Validation**: Optional LLM-based validation that a PDF is an archaeological report
43
45
  - **Chunked Conversion**: Split large PDFs into chunks for reliable processing
44
46
  - **Image PDF Fallback**: Automatic fallback to image-based PDF when conversion fails
47
+ - **Review Assistance**: Optional page-level VLM review that writes audit proposals and can auto-apply high-confidence fixes
45
48
  - **AbortSignal Support**: Cancel ongoing parsing operations
46
49
  - **Server Crash Recovery**: Automatic restart of docling-serve on ECONNREFUSED
47
50
 
@@ -49,7 +52,7 @@
49
52
 
50
53
  ### System Requirements
51
54
 
52
- - **macOS** with Apple Silicon (M1/M2/M3) - Recommended for optimal performance
55
+ - **macOS** with Apple Silicon (M1/M2/M3/M4/M5) - Recommended for optimal performance
53
56
  - **macOS** with Intel - Supported but slower
54
57
  - **Linux/Windows** - Currently not supported
55
58
 
@@ -61,7 +64,7 @@
61
64
  brew install node
62
65
  ```
63
66
 
64
- #### 2. pnpm >= 9.0.0
67
+ #### 2. pnpm >= 10.0.0
65
68
 
66
69
  ```bash
67
70
  npm install -g pnpm
@@ -123,13 +126,13 @@ This setup runs only once and may take 5-10 minutes depending on internet connec
123
126
 
124
127
  ```bash
125
128
  # Install with npm
126
- npm install @heripo/pdf-parser
129
+ npm install @heripo/pdf-parser @heripo/logger
127
130
 
128
131
  # Install with pnpm
129
- pnpm add @heripo/pdf-parser
132
+ pnpm add @heripo/pdf-parser @heripo/logger
130
133
 
131
134
  # Install with yarn
132
- yarn add @heripo/pdf-parser
135
+ yarn add @heripo/pdf-parser @heripo/logger
133
136
  ```
134
137
 
135
138
  ## Usage
@@ -140,7 +143,12 @@ yarn add @heripo/pdf-parser
140
143
  import { Logger } from '@heripo/logger';
141
144
  import { PDFParser } from '@heripo/pdf-parser';
142
145
 
143
- const logger = Logger(...);
146
+ const logger = new Logger({
147
+ debug: (...args) => console.debug('[heripo]', ...args),
148
+ info: (...args) => console.info('[heripo]', ...args),
149
+ warn: (...args) => console.warn('[heripo]', ...args),
150
+ error: (...args) => console.error('[heripo]', ...args),
151
+ });
144
152
 
145
153
  // Create PDFParser instance (logger is required)
146
154
  const pdfParser = new PDFParser({
@@ -154,13 +162,13 @@ await pdfParser.init();
154
162
  // Parse PDF
155
163
  const tokenUsageReport = await pdfParser.parse(
156
164
  'file:///path/to/report.pdf', // PDF URL (file:// or http://)
157
- 'report-001', // Report ID
165
+ 'report-001', // Report ID
158
166
  async (outputPath) => {
159
167
  // Conversion complete callback
160
168
  console.log('PDF conversion complete:', outputPath);
161
169
  },
162
- false, // cleanupAfterCallback
163
- {}, // PDFConvertOptions
170
+ false, // cleanupAfterCallback
171
+ {}, // PDFConvertOptions
164
172
  );
165
173
 
166
174
  // Token usage report (null when no LLM usage)
@@ -201,6 +209,15 @@ const tokenUsageReport = await pdfParser.parse(
201
209
  // Document validation
202
210
  documentValidationModel: openai('gpt-5.1'),
203
211
 
212
+ // Optional page-level review assistance
213
+ reviewAssistance: {
214
+ enabled: true,
215
+ autoApplyThreshold: 0.85,
216
+ proposalThreshold: 0.5,
217
+ outputLanguage: 'en-US',
218
+ },
219
+ onReviewAssistanceProgress: (event) => console.log(event),
220
+
204
221
  // Chunked conversion for large PDFs
205
222
  chunkedConversion: true,
206
223
  chunkSize: 50,
@@ -273,6 +290,43 @@ const tokenUsageReport = await pdfParser.parse(
273
290
  );
274
291
  ```
275
292
 
293
+ ## Review Assistance
294
+
295
+ `reviewAssistance` enables an optional page-level VLM review after Docling
296
+ conversion. It inspects rendered page images, text, tables, captions, pictures,
297
+ reading order, roles, bounding boxes, and domain patterns, then writes an audit
298
+ report while applying only high-confidence fixes.
299
+
300
+ ```typescript
301
+ const tokenUsageReport = await pdfParser.parse(
302
+ 'file:///path/to/input.pdf',
303
+ 'report-001',
304
+ async (outputPath) => console.log(outputPath),
305
+ false,
306
+ {
307
+ strategySamplerModel: openai('gpt-5.1'),
308
+ vlmProcessorModel: openai('gpt-5.1'),
309
+ reviewAssistance: {
310
+ enabled: true,
311
+ autoApplyThreshold: 0.85,
312
+ proposalThreshold: 0.5,
313
+ maxRetries: 3,
314
+ temperature: 0,
315
+ outputLanguage: 'en-US',
316
+ },
317
+ onReviewAssistanceProgress: (event) => {
318
+ console.log(event.substage, event.status, event.pageNo);
319
+ },
320
+ },
321
+ );
322
+ ```
323
+
324
+ Review Assistance requires a local `file://` PDF and either
325
+ `vlmProcessorModel` or `strategySamplerModel`. It updates `result.json` with
326
+ auto-applied fixes, keeps snapshots in `result_review_origin.json` and
327
+ `result_ocr_origin.json`, and writes `review_assistance.json` containing
328
+ per-page decisions, issues, proposals, and summary counts.
329
+
276
330
  ## Document Type Validation
277
331
 
278
332
  Optional LLM-based validation that a PDF is an archaeological investigation report. When `documentValidationModel` is provided, the parser extracts text from the PDF and uses the LLM to verify the document type before processing. If validation fails, an `InvalidDocumentTypeError` is thrown.
@@ -404,7 +458,7 @@ Archaeological excavation report PDFs have the following characteristics:
404
458
  ### Key Advantages
405
459
 
406
460
  - **Cost**: 100x+ cheaper than cloud OCR (free)
407
- - **Performance**: Fast processing with GPU acceleration on Apple Silicon M1/M2/M3
461
+ - **Performance**: Fast processing with GPU acceleration on Apple Silicon M1/M2/M3/M4/M5
408
462
  - **Quality**: Accurate recognition even for complex documents
409
463
  - **Privacy**: Documents are not sent to external servers
410
464
 
@@ -525,6 +579,10 @@ type PDFConvertOptions = {
525
579
  document_timeout?: number; // Document processing timeout in seconds
526
580
  documentValidationModel?: LanguageModel; // LLM for document type validation
527
581
 
582
+ // Review Assistance
583
+ reviewAssistance?: boolean | ReviewAssistanceOptions; // Optional page-level review
584
+ onReviewAssistanceProgress?: (event: ReviewAssistanceProgressEvent) => void; // Progress callback
585
+
528
586
  // Chunked conversion (large PDFs)
529
587
  chunkedConversion?: boolean; // Enable chunked conversion
530
588
  chunkSize?: number; // Pages per chunk
@@ -537,6 +595,19 @@ type PDFConvertOptions = {
537
595
  };
538
596
  ```
539
597
 
598
+ ### ReviewAssistanceOptions
599
+
600
+ ```typescript
601
+ interface ReviewAssistanceOptions {
602
+ enabled?: boolean; // Enable page-level review assistance
603
+ autoApplyThreshold?: number; // Minimum confidence for direct mutation (default: 0.85)
604
+ proposalThreshold?: number; // Minimum confidence for sidecar proposal (default: 0.5)
605
+ maxRetries?: number; // Max retries per page-level VLM call (default: 3)
606
+ temperature?: number; // VLM generation temperature (default: 0)
607
+ outputLanguage?: string; // Human-readable review reason language (default: en-US)
608
+ }
609
+ ```
610
+
540
611
  ### ConvertWithStrategyResult
541
612
 
542
613
  ```typescript
@@ -665,6 +736,13 @@ If you have ideas for supporting Linux while maintaining both performance and co
665
736
  - [@heripo/document-processor](../document-processor) - Document structure analysis and LLM processing
666
737
  - [@heripo/model](../model) - Data models and type definitions
667
738
 
739
+ ## Sponsor
740
+
741
+ If you'd like to support heripo lab's open-source research, you can sponsor us through:
742
+
743
+ - [Open Collective](https://opencollective.com/heripo-project) for general project sponsorship.
744
+ - [fairy.hada.io/@heripo](https://fairy.hada.io/@heripo) for Korean individual supporters who prefer KRW payments.
745
+
668
746
  ## License
669
747
 
670
748
  This package is distributed under the [Apache License 2.0](../../LICENSE).
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@heripo/pdf-parser",
3
3
  "private": false,
4
4
  "type": "module",
5
- "version": "0.1.28",
5
+ "version": "0.1.29",
6
6
  "description": "PDF parsing library using Docling SDK with OCR support for macOS",
7
7
  "main": "dist/index.cjs",
8
8
  "module": "dist/index.js",
@@ -62,8 +62,8 @@
62
62
  "es-toolkit": "^1.46.1",
63
63
  "yauzl": "^3.3.0",
64
64
  "zod": "^4.4.3",
65
- "@heripo/logger": "0.1.28",
66
- "@heripo/model": "0.1.28"
65
+ "@heripo/logger": "0.1.29",
66
+ "@heripo/model": "0.1.29"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/yauzl": "^2.10.3",
@@ -72,9 +72,9 @@
72
72
  "tsup": "^8.5.1",
73
73
  "vitest": "^4.1.5",
74
74
  "@heripo/shared": "0.0.0",
75
+ "@heripo/tsconfig": "0.0.0",
75
76
  "@heripo/tsup-config": "0.0.0",
76
- "@heripo/vitest-config": "0.0.0",
77
- "@heripo/tsconfig": "0.0.0"
77
+ "@heripo/vitest-config": "0.0.0"
78
78
  },
79
79
  "scripts": {
80
80
  "clean": "rimraf dist",