qaechi-parser 2.0.0__py3-none-any.whl
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.
- qaechi/parser/__init__.py +23 -0
- qaechi/parser/__main__.py +5 -0
- qaechi/parser/api.py +119 -0
- qaechi/parser/cli.py +87 -0
- qaechi/parser/config.py +150 -0
- qaechi/parser/llm.py +53 -0
- qaechi/parser/parsers/__init__.py +3 -0
- qaechi/parser/parsers/ledger.py +115 -0
- qaechi/parser/pipeline/__init__.py +65 -0
- qaechi/parser/pipeline/chunk.py +110 -0
- qaechi/parser/pipeline/extract.py +116 -0
- qaechi/parser/pipeline/grade.py +55 -0
- qaechi/parser/pipeline/graph.py +128 -0
- qaechi/parser/pipeline/index.py +64 -0
- qaechi/parser/pipeline/load.py +267 -0
- qaechi/parser/pipeline/nodes.py +185 -0
- qaechi/parser/pipeline/prompts.py +37 -0
- qaechi/parser/pipeline/retrieve.py +53 -0
- qaechi/parser/pipeline/state.py +35 -0
- qaechi/parser/pipeline/verbatim.py +67 -0
- qaechi/parser/registry.py +131 -0
- qaechi/parser/schemas.py +132 -0
- qaechi/parser/sources.py +103 -0
- qaechi/parser/store.py +103 -0
- qaechi_parser-2.0.0.dist-info/METADATA +381 -0
- qaechi_parser-2.0.0.dist-info/RECORD +31 -0
- qaechi_parser-2.0.0.dist-info/WHEEL +5 -0
- qaechi_parser-2.0.0.dist-info/entry_points.txt +2 -0
- qaechi_parser-2.0.0.dist-info/licenses/LICENSE +202 -0
- qaechi_parser-2.0.0.dist-info/licenses/NOTICE +5 -0
- qaechi_parser-2.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: qaechi-parser
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Evidence-first document extraction engine: every value comes with its quote and page.
|
|
5
|
+
Author: Taeyong Kang
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/qaechi/qaechi-parser
|
|
8
|
+
Project-URL: Documentation, https://qaechi.github.io/qaechi-parser/
|
|
9
|
+
Project-URL: Issues, https://github.com/qaechi/qaechi-parser/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/qaechi/qaechi-parser/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: rag,document-parsing,extraction,llm,provenance,fastapi,langgraph
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Framework :: FastAPI
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Text Processing
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
License-File: NOTICE
|
|
25
|
+
Requires-Dist: pydantic<3,>=2.6
|
|
26
|
+
Provides-Extra: server
|
|
27
|
+
Requires-Dist: fastapi<1,>=0.110; extra == "server"
|
|
28
|
+
Requires-Dist: uvicorn[standard]<1,>=0.29; extra == "server"
|
|
29
|
+
Provides-Extra: parse
|
|
30
|
+
Requires-Dist: httpx<1,>=0.27; extra == "parse"
|
|
31
|
+
Requires-Dist: openpyxl<4,>=3.1; extra == "parse"
|
|
32
|
+
Requires-Dist: pymupdf<3,>=1.24; extra == "parse"
|
|
33
|
+
Requires-Dist: pymupdf4llm>=0.0.17; extra == "parse"
|
|
34
|
+
Requires-Dist: python-pptx<2,>=1.0; extra == "parse"
|
|
35
|
+
Provides-Extra: llm
|
|
36
|
+
Requires-Dist: langchain-openai<2,>=1.0; extra == "llm"
|
|
37
|
+
Requires-Dist: langchain-text-splitters<2,>=1.0; extra == "llm"
|
|
38
|
+
Requires-Dist: langgraph<2,>=1.0; extra == "llm"
|
|
39
|
+
Provides-Extra: all
|
|
40
|
+
Requires-Dist: qaechi-parser[llm,parse,server]; extra == "all"
|
|
41
|
+
Provides-Extra: dev
|
|
42
|
+
Requires-Dist: qaechi-parser[server]; extra == "dev"
|
|
43
|
+
Requires-Dist: pytest<10,>=8; extra == "dev"
|
|
44
|
+
Requires-Dist: httpx<1,>=0.27; extra == "dev"
|
|
45
|
+
Requires-Dist: openpyxl<4,>=3.1; extra == "dev"
|
|
46
|
+
Requires-Dist: python-dotenv<2,>=1; extra == "dev"
|
|
47
|
+
Requires-Dist: ruff==0.16.*; extra == "dev"
|
|
48
|
+
Dynamic: license-file
|
|
49
|
+
|
|
50
|
+
<div align="center">
|
|
51
|
+
|
|
52
|
+
<img src="https://raw.githubusercontent.com/qaechi/qaechi-parser/main/docs/assets/brand/qaechi-social-preview-2560x1280.png" alt="qaechi: evidence-first document extraction. Each value comes back with its quote and page." width="100%">
|
|
53
|
+
|
|
54
|
+
# qaechi-parser
|
|
55
|
+
|
|
56
|
+
**Evidence-first document extraction for RAG and business systems.**<br>
|
|
57
|
+
Every value comes back with the exact quote and page it was read from.
|
|
58
|
+
|
|
59
|
+
[](https://github.com/qaechi/qaechi-parser/actions/workflows/ci.yml)
|
|
60
|
+
[](https://github.com/qaechi/qaechi-parser/releases)
|
|
61
|
+
[](https://github.com/qaechi/qaechi-parser/blob/main/pyproject.toml)
|
|
62
|
+
[](https://github.com/qaechi/qaechi-parser/blob/main/LICENSE)
|
|
63
|
+
[](https://qaechi.github.io/qaechi-parser/)
|
|
64
|
+
|
|
65
|
+
[Quickstart](#quickstart) | [How it works](#how-it-works) | [Parsing rules](#parsing-rules) | [Benchmarks](#benchmarks) | [Plugins](#write-a-parser-plugin) | [API](#http-api) | [Config](#configuration) | [Contact](#contact) | [Maintainer](#maintainer) | [한국어](https://github.com/qaechi/qaechi-parser/blob/main/README.ko.md)
|
|
66
|
+
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Why qaechi-parser
|
|
72
|
+
|
|
73
|
+
LLM extraction is easy to demo and hard to trust. When a number is wrong, you need to
|
|
74
|
+
know **where it came from**. When the model is unsure, you want `null`, not a guess.
|
|
75
|
+
|
|
76
|
+
qaechi-parser is the extraction layer of the **Qaechi** framework. It reads a document and
|
|
77
|
+
**proposes** values with evidence. Your system (an ERP, a review queue, an agent)
|
|
78
|
+
decides what to accept.
|
|
79
|
+
|
|
80
|
+
| qaechi-parser does | qaechi-parser does not |
|
|
81
|
+
|---|---|
|
|
82
|
+
| Load, chunk, index, extract, grade | Authenticate or authorize users |
|
|
83
|
+
| Return each value with `quote` and `page` | Approve, confirm or post anything |
|
|
84
|
+
| Report quotes it could not find in the source | Fix values so totals add up |
|
|
85
|
+
| Count what it skipped or truncated | Drop rows or sheets silently |
|
|
86
|
+
|
|
87
|
+
## Features
|
|
88
|
+
|
|
89
|
+
- **Provenance on every value.** `quote`, `page` and `chunkId` for each field and line item.
|
|
90
|
+
- **Verbatim check.** Each LLM quote is matched against the source text; misses are listed in `quoteCheck.notInSource`.
|
|
91
|
+
- **Deterministic parsers first.** Fixed layouts go to plugins that read the file directly: zero tokens, confidence 1.0.
|
|
92
|
+
- **LLM route for the rest.** You describe the fields you want; qaechi-parser builds the structured-output schema.
|
|
93
|
+
- **Groundedness grade.** A second pass labels results `yes` / `no` / `unknown`. No key means `unknown`, never an optimistic `yes`.
|
|
94
|
+
- **Runs without anything.** With no keys and no storage it starts in stub mode and returns `null`s, so you can wire your UI first.
|
|
95
|
+
- **LangGraph optional.** Same nodes and edges run on LangGraph or on a built-in sequential runner.
|
|
96
|
+
- **Safe defaults.** Loopback bind, constant-time token check, API docs off, path traversal blocked, input size limits.
|
|
97
|
+
|
|
98
|
+
## Quickstart
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
pip install "qaechi-parser[parse] @ git+https://github.com/qaechi/qaechi-parser@qaechi-parser-v1.2.7"
|
|
102
|
+
|
|
103
|
+
# Parse a local file (built-in ledger parser)
|
|
104
|
+
qaechi-parser parse examples/ledger.csv --doc-type ledger
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
```jsonc
|
|
108
|
+
{
|
|
109
|
+
"route": "parser",
|
|
110
|
+
"parser": "ledger",
|
|
111
|
+
"lines": [
|
|
112
|
+
{ "label": "Design work",
|
|
113
|
+
"amount": { "value": 1200000, "confidence": 1.0,
|
|
114
|
+
"provenance": { "page": 1, "quote": "Design work | 1 | 1,200,000" } } }
|
|
115
|
+
// ...
|
|
116
|
+
],
|
|
117
|
+
"total": { "value": 1225000, ... },
|
|
118
|
+
"groundedness": "yes"
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Ask an LLM for free-form fields (needs `pip install "qaechi-parser[all]"` and `OPENAI_API_KEY`):
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
qaechi-parser parse contract.pdf --doc-type contract \
|
|
126
|
+
--field "party:text:the counterparty name" \
|
|
127
|
+
--field "fee:integer:monthly fee" \
|
|
128
|
+
--field "start:date:contract start date"
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Or from Python:
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
import qaechi.parser as qp
|
|
135
|
+
|
|
136
|
+
result = qp.parse("contract.pdf", "contract",
|
|
137
|
+
fields=[{"name": "fee", "kind": "integer"}])
|
|
138
|
+
print(result.fields["fee"].value, result.fields["fee"].provenance.quote)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## How it works
|
|
142
|
+
|
|
143
|
+
```mermaid
|
|
144
|
+
flowchart LR
|
|
145
|
+
F[fetch] -->|parser matches| P[parse]
|
|
146
|
+
F -->|no source / no LLM| S[stub]
|
|
147
|
+
F -->|LLM route| L[load] --> C[chunk] --> I[index] --> R[retrieve] --> E[extract] --> G[grade]
|
|
148
|
+
G -->|"no (once)"| W[rewrite] --> E
|
|
149
|
+
G --> V[save]
|
|
150
|
+
P --> V
|
|
151
|
+
S --> V
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
1. **fetch**: get the file from a local directory or an HTTP object store.
|
|
155
|
+
2. **route**: a registered parser that matches `docType` + extension (+ `sourceKind`) wins. Otherwise LLM, or stub.
|
|
156
|
+
3. **load / chunk**: PDF, PPTX, XLSX (every sheet), CSV, TXT, MD. Tables are never split.
|
|
157
|
+
4. **retrieve** *(opt-in)*: long documents are narrowed to the chunks that hold evidence.
|
|
158
|
+
5. **extract**: structured output with a quote per value.
|
|
159
|
+
6. **grade**: groundedness as a secondary signal; one widened retry on a clear `no` *(opt-in)*.
|
|
160
|
+
7. **save**: the result is stored as a proposal with its quote check.
|
|
161
|
+
|
|
162
|
+
## Parsing rules
|
|
163
|
+
|
|
164
|
+
<!-- --8<-- [start:parsing-rules] -->
|
|
165
|
+
|
|
166
|
+
qaechi-parser decides what to read, how to cut it and what counts as evidence by fixed
|
|
167
|
+
rules, not by model judgment. Same file in, same pages and chunks out.
|
|
168
|
+
|
|
169
|
+
### 1. Route: who reads the document
|
|
170
|
+
|
|
171
|
+
| Order | Condition | Route | Tokens | Confidence |
|
|
172
|
+
|---|---|---|---|---|
|
|
173
|
+
| 1 | A registered parser matches `docType` **and** extension (**and** `sourceKind`, if the parser declares any). The most recently registered match wins, so a plugin overrides a built-in. | `parser` | 0 | 1.0 |
|
|
174
|
+
| 2 | No parser, a source file exists and an LLM key is set | `llm` | yes | model's |
|
|
175
|
+
| 3 | Anything else | `stub` (all `null`, with the reason in `notes`) | 0 | 0 |
|
|
176
|
+
|
|
177
|
+
A parser that does not recognise the layout raises `LayoutError` rather than guessing.
|
|
178
|
+
|
|
179
|
+
### 2. Load: what each format turns into
|
|
180
|
+
|
|
181
|
+
Every loader returns **pages**, and the page number travels to `provenance.page`.
|
|
182
|
+
|
|
183
|
+
| Format | Page = | Rules |
|
|
184
|
+
|---|---|---|
|
|
185
|
+
| **PDF** | PDF page | Text layer via pymupdf4llm, tables kept as markdown. A page with no text is kept empty and reported in `notes` as `no text on N page(s)` (likely scanned; put OCR in front). Encrypted files fail unless `QAECHI_PDF_PASSWORD` opens them. |
|
|
186
|
+
| **PPTX** | slide | Title first as `# title`. Shapes in **reading order** (top-to-bottom, then left-to-right), **including shapes inside groups**. Tables become `\| a \| b \|` rows. **Charts** become a `series \| category...` table with their values. Speaker notes follow a `[notes]` marker. |
|
|
187
|
+
| **XLSX / XLSM** | sheet | **Every sheet**, hidden sheets too (marked `(hidden)`). Cached values, not formulas. Blank rows dropped and trailing empty cells trimmed; empty cells in the middle stay so columns line up. `1200000.0` prints as `1200000`, a midnight datetime as `2026-01-31`; nothing is rounded. Up to 20,000 rows are read per sheet for parsers; the first 300 non-blank rows go to the LLM, and the sheet header says so. |
|
|
188
|
+
| **CSV** | whole file | Delimiter sniffed (`, ; tab \|`), UTF-8 with or without BOM. Same row rules as XLSX. |
|
|
189
|
+
| **TXT / MD** | whole file | As is. |
|
|
190
|
+
|
|
191
|
+
### 3. Chunk: how pages are cut
|
|
192
|
+
|
|
193
|
+
| Rule | Why |
|
|
194
|
+
|---|---|
|
|
195
|
+
| A sheet page is one chunk, however long. | A table split from its header loses meaning. |
|
|
196
|
+
| Other pages are cut into **table blocks** (lines with 2+ `\|`) and **prose blocks**. | A PDF page often holds both. |
|
|
197
|
+
| Table blocks are never split. Prose blocks over 1,000 chars are split (100-char overlap). | Retrieval gets small prose chunks without breaking tables. |
|
|
198
|
+
| Small neighbouring blocks are packed together up to 1,000 chars. | A table keeps the sentence that introduces it. |
|
|
199
|
+
| Each chunk starts with `[doc: <type> \| period: <p> \| p.<n>]`. | The model can cite the page. |
|
|
200
|
+
| Chunk text is verbatim. | Quotes are checked against it. |
|
|
201
|
+
|
|
202
|
+
### 4. Evidence: when a quote counts
|
|
203
|
+
|
|
204
|
+
Each LLM quote is searched for in the chunk text. Before matching, both sides are normalized
|
|
205
|
+
**only** for: Unicode compatibility forms (full-width `1,000`, NBSP), typographic quotes and
|
|
206
|
+
dashes (`“ ”` `–` `−`), markdown the loader added (`|`, `**`, `__`, `<br>`), and runs of
|
|
207
|
+
whitespace. Letters, digits and their order must match exactly, so a changed digit, a moved
|
|
208
|
+
decimal point or a dropped minus sign is reported in `quoteCheck.notInSource`.
|
|
209
|
+
|
|
210
|
+
### 5. Grade and save
|
|
211
|
+
|
|
212
|
+
- Groundedness is `yes` / `no` / `unknown`; without an LLM key it is `unknown`, never `yes`.
|
|
213
|
+
Parser results are `yes` because their values are read, not generated.
|
|
214
|
+
- A clear `no` retries once with the full context, and only if `QAECHI_REWRITE` is on.
|
|
215
|
+
- Nothing is dropped silently: skipped rows, skipped sheets, truncated sheets, empty pages and
|
|
216
|
+
quotes not found in the source are all counted in the result.
|
|
217
|
+
|
|
218
|
+
<!-- --8<-- [end:parsing-rules] -->
|
|
219
|
+
|
|
220
|
+
## Benchmarks
|
|
221
|
+
|
|
222
|
+
What these rules buy you, measured on a seeded synthetic corpus (20 decks, 20 workbooks,
|
|
223
|
+
60 PDF-style pages, 380 quote trials). Each pipeline reads the same files:
|
|
224
|
+
|
|
225
|
+
- **Naive baseline**: what a quick RAG prototype does (text frames only, active sheet only,
|
|
226
|
+
a fixed 1,000-char window, "is the number in the quote" check).
|
|
227
|
+
- **qaechi-parser 1.1**: the previous release's rules.
|
|
228
|
+
- **qaechi-parser 1.2**: the rules described above.
|
|
229
|
+
|
|
230
|
+
<picture>
|
|
231
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/qaechi/qaechi-parser/main/docs/assets/benchmark-dark.png">
|
|
232
|
+
<img alt="Benchmark chart: qaechi-parser 1.2 recovers 100% of PPTX text (naive 11%, 1.1 70%), reaches 100% of XLSX values (naive 34%), keeps 100% of tables whole (naive 22%), keeps 100% of chunks within budget (1.1 0%), matches 100% of genuine quotes (1.1 75%) and flags 100% of invented quotes (naive 0%), while sending 78% less XLSX text than 1.1." src="https://raw.githubusercontent.com/qaechi/qaechi-parser/main/docs/assets/benchmark.png">
|
|
233
|
+
</picture>
|
|
234
|
+
|
|
235
|
+
| Metric | Naive | v1.1 | **v1.2** |
|
|
236
|
+
|---|---:|---:|---:|
|
|
237
|
+
| PPTX text recovered (groups, tables, charts, notes) | 11% | 70% | **100%** |
|
|
238
|
+
| XLSX values reachable (all sheets, incl. hidden) | 34% | 100% | **100%** |
|
|
239
|
+
| XLSX text sent to the LLM (relative to 1.1) | 34%¹ | 100% | **22%** |
|
|
240
|
+
| Tables kept whole with their header | 22% | 100% | **100%** |
|
|
241
|
+
| Chunks within the 1,000-char budget | 100% | 0%² | **100%** |
|
|
242
|
+
| Genuine quotes matched despite formatting | 100% | 75% | **100%** |
|
|
243
|
+
| Invented quotes flagged (one digit changed) | 0% | 100% | **100%** |
|
|
244
|
+
| Tokens spent on a `ledger` file (parser route) | n/a | 0 | **0** |
|
|
245
|
+
|
|
246
|
+
¹ Smaller only because it reads one sheet of three. ² 1.1 kept any page with a table as one
|
|
247
|
+
chunk, prose included.
|
|
248
|
+
|
|
249
|
+
The corpus isolates one rule per metric; it is not a claim about any specific real-world
|
|
250
|
+
document set. Reproduce or extend it with:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
pip install -e ".[parse,dev]" langchain-text-splitters matplotlib
|
|
254
|
+
python benchmarks/run.py # writes benchmarks/results.json and docs/assets/benchmark*.png
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Write a parser plugin
|
|
258
|
+
|
|
259
|
+
A plugin reads one fixed layout and never calls an LLM.
|
|
260
|
+
|
|
261
|
+
```python
|
|
262
|
+
from qaechi.parser.registry import LayoutError, ParseInput, ParseOutput, register
|
|
263
|
+
from qaechi.parser.schemas import FieldValue, Provenance
|
|
264
|
+
|
|
265
|
+
@register("acme_invoice", doc_types={"invoice"}, extensions=(".xlsx",),
|
|
266
|
+
source_kinds={"acme"}, version="1")
|
|
267
|
+
def parse(doc: ParseInput) -> ParseOutput:
|
|
268
|
+
...
|
|
269
|
+
if header_not_found:
|
|
270
|
+
raise LayoutError("not an ACME invoice") # stop rather than misread
|
|
271
|
+
return ParseOutput(fields={"invoice_no": FieldValue(
|
|
272
|
+
value="A-001", confidence=1.0,
|
|
273
|
+
provenance=Provenance(document_id=doc.document_id, page=1, quote="Invoice No. A-001"))})
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Load it with `QAECHI_PLUGINS=my_package.acme`, or ship it as a package with an entry point:
|
|
277
|
+
|
|
278
|
+
```toml
|
|
279
|
+
[project.entry-points."qaechi.parsers"]
|
|
280
|
+
acme = "my_package.acme"
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
See [`examples/key_value_parser.py`](https://github.com/qaechi/qaechi-parser/blob/main/examples/key_value_parser.py) for a runnable one.
|
|
284
|
+
|
|
285
|
+
## HTTP API
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
pip install "qaechi-parser[parse,server] @ git+https://github.com/qaechi/qaechi-parser@qaechi-parser-v1.2.7"
|
|
289
|
+
cp .env.example .env # sets QAECHI_INTERNAL_TOKEN and QAECHI_SOURCE_DIR
|
|
290
|
+
qaechi-parser serve # 127.0.0.1:3100
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
| Method | Path | |
|
|
294
|
+
|---|---|---|
|
|
295
|
+
| `GET` | `/health` | status, engine, optional modules (no token) |
|
|
296
|
+
| `POST` | `/jobs` | queue a job, returns `202` right away |
|
|
297
|
+
| `GET` | `/jobs/{jobId}` | `queued` / `running` / `succeeded` / `failed` |
|
|
298
|
+
| `GET` | `/results?documentId=&limit=&offset=` | list results (`limit` 1 to 200) |
|
|
299
|
+
| `GET` | `/results/{id}` | full result with provenance |
|
|
300
|
+
| `GET` | `/parsers` | registered parsers |
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
curl -X POST http://127.0.0.1:3100/jobs \
|
|
304
|
+
-H "X-Internal-Token: $QAECHI_INTERNAL_TOKEN" -H "Content-Type: application/json" \
|
|
305
|
+
-d '{"documentId":"doc-1","source":"ledger.csv","docType":"ledger"}'
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
JSON is camelCase. Full contract: [`docs/api.md`](https://github.com/qaechi/qaechi-parser/blob/main/docs/api.md).
|
|
309
|
+
|
|
310
|
+
## Configuration
|
|
311
|
+
|
|
312
|
+
| Variable | Default | |
|
|
313
|
+
|---|---|---|
|
|
314
|
+
| `QAECHI_INTERNAL_TOKEN` | *(required for API)* | shared token for `X-Internal-Token` |
|
|
315
|
+
| `QAECHI_SOURCE_DIR` | | read sources from this directory |
|
|
316
|
+
| `QAECHI_SOURCE_URL` / `QAECHI_SOURCE_TOKEN` | | read sources from `{url}/{source}` with a bearer token |
|
|
317
|
+
| `OPENAI_API_KEY` | | enables the LLM route and grading |
|
|
318
|
+
| `QAECHI_LLM_MODEL` | `gpt-4o-mini` | |
|
|
319
|
+
| `QAECHI_RETRIEVE` / `QAECHI_REWRITE` | off | narrowing and one retry (they change results) |
|
|
320
|
+
| `QAECHI_PLUGINS` | | comma-separated modules to import |
|
|
321
|
+
| `QAECHI_PDF_PASSWORD` | | for encrypted PDFs |
|
|
322
|
+
|
|
323
|
+
All variables: [`.env.example`](https://github.com/qaechi/qaechi-parser/blob/main/.env.example).
|
|
324
|
+
|
|
325
|
+
## Install options
|
|
326
|
+
|
|
327
|
+
| Extra | Adds |
|
|
328
|
+
|---|---|
|
|
329
|
+
| *(none)* | the library: CSV/TXT, parser plugins, stub mode |
|
|
330
|
+
| `server` | the HTTP service (`qaechi-parser serve`): FastAPI, Uvicorn |
|
|
331
|
+
| `parse` | PDF, PPTX, XLSX, HTTP sources |
|
|
332
|
+
| `llm` | LLM extraction, grading, LangGraph |
|
|
333
|
+
| `all` | `parse`, `llm` and `server` |
|
|
334
|
+
|
|
335
|
+
Docker: `docker build -t qaechi-parser . && docker run -p 127.0.0.1:3100:3100 --env-file .env qaechi-parser`
|
|
336
|
+
|
|
337
|
+
## Roadmap
|
|
338
|
+
|
|
339
|
+
- [ ] Postgres / pgvector store
|
|
340
|
+
- [ ] More model providers
|
|
341
|
+
- [ ] OCR front end for scanned PDFs
|
|
342
|
+
- [ ] Evaluation harness with golden sets
|
|
343
|
+
|
|
344
|
+
Ideas and votes are welcome in [Discussions](https://github.com/qaechi/qaechi-parser/discussions).
|
|
345
|
+
|
|
346
|
+
## Contributing
|
|
347
|
+
|
|
348
|
+
Issues and PRs are welcome. Read [CONTRIBUTING.md](https://github.com/qaechi/qaechi-parser/blob/main/CONTRIBUTING.md) first; commits follow
|
|
349
|
+
[Conventional Commits](https://www.conventionalcommits.org/) so releases are automatic.
|
|
350
|
+
Security reports go through [SECURITY.md](https://github.com/qaechi/qaechi-parser/blob/main/SECURITY.md), not public issues.
|
|
351
|
+
|
|
352
|
+
## Contact
|
|
353
|
+
|
|
354
|
+
Questions, ideas and use-case reports: [GitHub Discussions](https://github.com/qaechi/qaechi-parser/discussions)
|
|
355
|
+
or email [ddaeyongee@gmail.com](mailto:ddaeyongee@gmail.com).
|
|
356
|
+
Bugs go to [Issues](https://github.com/qaechi/qaechi-parser/issues); security reports follow [SECURITY.md](https://github.com/qaechi/qaechi-parser/blob/main/SECURITY.md).
|
|
357
|
+
|
|
358
|
+
## Maintainer
|
|
359
|
+
|
|
360
|
+
**Taeyong Kang** ([@ddaeyongee](https://github.com/ddaeyongee)), Seoul, South Korea
|
|
361
|
+
|
|
362
|
+
Application Architect at **LG CNS** (2021 to present) and Founder of **CNTSOFT** (2026 to present),
|
|
363
|
+
previously at **POSCO DX**. 11+ years designing enterprise applications, focused on microservice
|
|
364
|
+
architecture and real-time, high-volume event streaming.
|
|
365
|
+
|
|
366
|
+
- **Microservice architecture:** application architect for a platform of about 200 microservices on
|
|
367
|
+
Amazon EKS serving about 50,000 concurrent users; reusable MSA application standards adopted
|
|
368
|
+
across banking, insurance and public-sector programs.
|
|
369
|
+
- **Event streaming:** Apache Kafka and Amazon MSK with the transactional outbox pattern and change
|
|
370
|
+
data capture, with no message loss or duplication. Designed and built parallel processing
|
|
371
|
+
(a swimlane dispatcher) in the open-source Eventuate CDC framework together with its original
|
|
372
|
+
author, to meet production TPS targets.
|
|
373
|
+
- **Telemetry and observability:** Kafka-based log pipelines (Amazon MSK + ELK), CloudWatch,
|
|
374
|
+
Prometheus and Grafana, VictoriaMetrics and Grafana Alloy.
|
|
375
|
+
- **AI document pipelines:** RAG and LLM structured output with LangGraph, the groundwork for this project.
|
|
376
|
+
|
|
377
|
+
This background shapes Qaechi's next modules: batch processing and event streaming for documents at scale.
|
|
378
|
+
|
|
379
|
+
## License
|
|
380
|
+
|
|
381
|
+
[Apache-2.0](https://github.com/qaechi/qaechi-parser/blob/main/LICENSE) © 2026 Taeyong Kang
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
qaechi/parser/__init__.py,sha256=MJ4cSKspFdS-1Lm4K2BlELBf9DyM8JI0Lyvc2WGfBmU,624
|
|
2
|
+
qaechi/parser/__main__.py,sha256=E6Gls0DNz8GQK2K-kOUIx8cYhgANW_CH54VKrfCfs14,52
|
|
3
|
+
qaechi/parser/api.py,sha256=W0LsPVzmg7xKtKnIEHz3QtrNXq43V3VZ0SznymUqO5A,4288
|
|
4
|
+
qaechi/parser/cli.py,sha256=pKrG9rB54do7oBCvxMdZwGCZbpAV1nkDoOYMh4REO6U,3126
|
|
5
|
+
qaechi/parser/config.py,sha256=c4htc80YpPV_M5Ur-rw0JDxLaNYV2-JJsUqB2F0l0kk,3480
|
|
6
|
+
qaechi/parser/llm.py,sha256=1GMt2sEQKeQgUdnsj2F3ufGxDrdQDw32zgBMMD-xXnc,1494
|
|
7
|
+
qaechi/parser/registry.py,sha256=_lmSQ13AFQ89NU1VlB9x5folDvIPCw5AbVEFe2nAhQg,4024
|
|
8
|
+
qaechi/parser/schemas.py,sha256=mxPDQby40UReNn_uk3yKPgnrzOw1V_EVerAsoB15k6c,3654
|
|
9
|
+
qaechi/parser/sources.py,sha256=tiikFQG7GiQJ6Ium74OFAR5xgKk7vjBtiFubXnoKpUU,3149
|
|
10
|
+
qaechi/parser/store.py,sha256=_NzTqssVP_j1bkw6lB54B7CqqBLzj-aDYrcW4vz2Ptw,3402
|
|
11
|
+
qaechi/parser/parsers/__init__.py,sha256=wr6ql-4LfxiSXMkwuE4CVNXtt0qtxdMWKHa80puUasc,99
|
|
12
|
+
qaechi/parser/parsers/ledger.py,sha256=v6MXhPIRHlRgV7NiBPT45m26pGc7L3kpJTh6TeCzaaY,4650
|
|
13
|
+
qaechi/parser/pipeline/__init__.py,sha256=KXh97YKAPioyrDNeFSpaTpCNCErUxI9BpPCA_ypsNPs,2555
|
|
14
|
+
qaechi/parser/pipeline/chunk.py,sha256=1IZX3fga90oeL2RK1w3mufLG8trVlOZ4SkN2oJdjCEI,3632
|
|
15
|
+
qaechi/parser/pipeline/extract.py,sha256=VZWooCS8qC9niIRc7wJEB3EmuUrJut4v1rzJuFG0vEQ,4471
|
|
16
|
+
qaechi/parser/pipeline/grade.py,sha256=f8cDXy_9rErHWtuF6bPTGvTpagDh4SmIKhvkNXYzloY,2011
|
|
17
|
+
qaechi/parser/pipeline/graph.py,sha256=uzEcu5EGQcFsGtgvjwHxni0NnDI2EhrBxPGIo-a98oI,4235
|
|
18
|
+
qaechi/parser/pipeline/index.py,sha256=IvQgGCyY1KtAY00XGm6H9k3KqtghanNcAxoG6fUB69Q,1913
|
|
19
|
+
qaechi/parser/pipeline/load.py,sha256=on-iTlKzg_fL-pKZb36gOmfhXI45Vupr2WNZhv3XyxE,10151
|
|
20
|
+
qaechi/parser/pipeline/nodes.py,sha256=7MYuI4yooX0BfYDANhIdTRwO5i-L8CH_C9H10oqIuQA,6802
|
|
21
|
+
qaechi/parser/pipeline/prompts.py,sha256=W34lHBtbqONguvuOP8KXFgoMkh6MgAXJBLRuDZeqiuA,1517
|
|
22
|
+
qaechi/parser/pipeline/retrieve.py,sha256=LV3XXn7Ai8pmCUn7p8MNVH82MLbuITrs3lQillwVS28,2082
|
|
23
|
+
qaechi/parser/pipeline/state.py,sha256=2CfG6ThfEYCRbHB7WTqRrDcIdh-v1cw06VrdHcjD7yQ,974
|
|
24
|
+
qaechi/parser/pipeline/verbatim.py,sha256=07yXf3ZowthvNuqYYgcXwq7YomvepSNsuKk5QIQdgl8,2481
|
|
25
|
+
qaechi_parser-2.0.0.dist-info/licenses/LICENSE,sha256=yVuuHRzgI17MzTVgt3LsHvuX80innw--CmNPDCzO_iw,11358
|
|
26
|
+
qaechi_parser-2.0.0.dist-info/licenses/NOTICE,sha256=8f6NC_5W4GGzO0gxBCkBAduPW1-yIXSeAkTbtD993kc,165
|
|
27
|
+
qaechi_parser-2.0.0.dist-info/METADATA,sha256=94FnR0usrt7qjSr5Dz6_jwaZPbiW-QtdX2IoGbvUiIY,18766
|
|
28
|
+
qaechi_parser-2.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
29
|
+
qaechi_parser-2.0.0.dist-info/entry_points.txt,sha256=aEGffe0YfhvIDZcEHiKwbb1E_yINlctBp_Opq4xazwg,57
|
|
30
|
+
qaechi_parser-2.0.0.dist-info/top_level.txt,sha256=uD_gOde0YCWlGMtrDzR5FuXld9uzJkwJnJtoXcvNScM,7
|
|
31
|
+
qaechi_parser-2.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
qaechi
|