inklight 0.1.0__tar.gz
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.
- inklight-0.1.0/.gitignore +18 -0
- inklight-0.1.0/CHANGELOG.md +52 -0
- inklight-0.1.0/LICENSE +202 -0
- inklight-0.1.0/NOTICE +15 -0
- inklight-0.1.0/PKG-INFO +202 -0
- inklight-0.1.0/README.md +153 -0
- inklight-0.1.0/THIRD_PARTY_LICENSES.md +70 -0
- inklight-0.1.0/docs/API.md +67 -0
- inklight-0.1.0/docs/ARCHITECTURE.md +71 -0
- inklight-0.1.0/docs/BENCHMARKS.md +112 -0
- inklight-0.1.0/docs/PUBLISHING.md +97 -0
- inklight-0.1.0/docs/assets/logo.svg +16 -0
- inklight-0.1.0/docs/assets/workspace.jpg +0 -0
- inklight-0.1.0/docs/extraction.md +57 -0
- inklight-0.1.0/docs/site/landing.html +323 -0
- inklight-0.1.0/pyproject.toml +91 -0
- inklight-0.1.0/src/inklight/__init__.py +36 -0
- inklight-0.1.0/src/inklight/__main__.py +4 -0
- inklight-0.1.0/src/inklight/_brand.py +16 -0
- inklight-0.1.0/src/inklight/agent/__init__.py +178 -0
- inklight-0.1.0/src/inklight/agent/analysis.py +469 -0
- inklight-0.1.0/src/inklight/agent/answer.py +544 -0
- inklight-0.1.0/src/inklight/agent/compose.py +150 -0
- inklight-0.1.0/src/inklight/agent/conditions.py +363 -0
- inklight-0.1.0/src/inklight/agent/context.py +86 -0
- inklight-0.1.0/src/inklight/agent/plan.py +98 -0
- inklight-0.1.0/src/inklight/agent/planner.py +339 -0
- inklight-0.1.0/src/inklight/agent/runner.py +206 -0
- inklight-0.1.0/src/inklight/agent/tools.py +178 -0
- inklight-0.1.0/src/inklight/brains/__init__.py +112 -0
- inklight-0.1.0/src/inklight/brains/hub.py +68 -0
- inklight-0.1.0/src/inklight/brains/onnx_models.py +248 -0
- inklight-0.1.0/src/inklight/brains/remote.py +49 -0
- inklight-0.1.0/src/inklight/chunking.py +61 -0
- inklight-0.1.0/src/inklight/cli.py +505 -0
- inklight-0.1.0/src/inklight/cli_render.py +142 -0
- inklight-0.1.0/src/inklight/config.py +173 -0
- inklight-0.1.0/src/inklight/errors.py +47 -0
- inklight-0.1.0/src/inklight/extract/__init__.py +21 -0
- inklight-0.1.0/src/inklight/extract/classify.py +91 -0
- inklight-0.1.0/src/inklight/extract/fields.py +525 -0
- inklight-0.1.0/src/inklight/extract/values.py +127 -0
- inklight-0.1.0/src/inklight/library.py +219 -0
- inklight-0.1.0/src/inklight/ocr/__init__.py +29 -0
- inklight-0.1.0/src/inklight/ocr/base.py +23 -0
- inklight-0.1.0/src/inklight/ocr/indra.py +194 -0
- inklight-0.1.0/src/inklight/ocr/plaintext.py +43 -0
- inklight-0.1.0/src/inklight/py.typed +0 -0
- inklight-0.1.0/src/inklight/retrieval.py +69 -0
- inklight-0.1.0/src/inklight/safety.py +178 -0
- inklight-0.1.0/src/inklight/schemas.py +205 -0
- inklight-0.1.0/src/inklight/server/__init__.py +5 -0
- inklight-0.1.0/src/inklight/server/app.py +286 -0
- inklight-0.1.0/src/inklight/server/render.py +57 -0
- inklight-0.1.0/src/inklight/server/static/app.css +147 -0
- inklight-0.1.0/src/inklight/server/static/app.js +332 -0
- inklight-0.1.0/src/inklight/server/static/index.html +127 -0
- inklight-0.1.0/src/inklight/server/static/logo.svg +16 -0
- inklight-0.1.0/src/inklight/store.py +402 -0
- inklight-0.1.0/src/inklight/watch.py +103 -0
- inklight-0.1.0/tests/__init__.py +0 -0
- inklight-0.1.0/tests/conftest.py +102 -0
- inklight-0.1.0/tests/factory.py +217 -0
- inklight-0.1.0/tests/test_agent_e2e.py +154 -0
- inklight-0.1.0/tests/test_models_remote_watch.py +138 -0
- inklight-0.1.0/tests/test_planner.py +104 -0
- inklight-0.1.0/tests/test_request_fidelity.py +166 -0
- inklight-0.1.0/tests/test_runner_library.py +203 -0
- inklight-0.1.0/tests/test_safety_config_store.py +130 -0
- inklight-0.1.0/tests/test_server_cli.py +133 -0
- inklight-0.1.0/tests/test_values_fields.py +190 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow [SemVer](https://semver.org/).
|
|
5
|
+
|
|
6
|
+
## [0.1.0] — 2026-10-23
|
|
7
|
+
|
|
8
|
+
First public release candidate.
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Document library: incremental ingest (unchanged files skipped, identical content reuses OCR), SQLite +
|
|
12
|
+
FTS5 index, layout-aware chunks, classification, prompt-injection scan, re-index and delete.
|
|
13
|
+
- Indra OCR backend (PDF text layer first, OCR where needed; PNG/JPEG/TIFF/BMP/WebP), plain-text and
|
|
14
|
+
Markdown reader, pluggable engine registry.
|
|
15
|
+
- Typed field extraction with page/box provenance, confidence, warnings and `subtotal + tax = total`
|
|
16
|
+
checks; schema files in three formats.
|
|
17
|
+
- Bounded agent: rule planner, 11 allow-listed tools, step limits, time budgets, cancellation, retries, trace.
|
|
18
|
+
- Small local models on ONNX Runtime: 66M extractive reader, 33M embedder (hybrid search), optional
|
|
19
|
+
135M writer with grounding checks. Optional OpenAI-compatible remote model with quote verification.
|
|
20
|
+
- CLI (`process, ask, extract, search, docs, show, remove, reindex, history, watch, serve, tools, doctor, models`).
|
|
21
|
+
- Local web workspace: upload, library, page preview with evidence highlighting, agent, extraction, search, history, settings.
|
|
22
|
+
- Folder watcher automation.
|
|
23
|
+
- Benchmarks (`bench/`), 128 tests, CI and release workflows, Dockerfile.
|
|
24
|
+
|
|
25
|
+
### Fixed before release (external review of 478fc3d)
|
|
26
|
+
- Vendor and customer constraints ("invoices from Acme above $5,000") were silently dropped. They are now
|
|
27
|
+
conditions (`vendor contains "Acme"`), including negation ("not from", "except").
|
|
28
|
+
- `or` between conditions was applied as AND. It now means any. A mix of `and`/`or` is reported instead of guessed.
|
|
29
|
+
- Added `between X and Y` and year conditions ("in 2026").
|
|
30
|
+
- Amounts in different currencies were summed into one number. Money values now carry a `unit`, sums are
|
|
31
|
+
reported per currency, and filters never compare € amounts with a $ threshold.
|
|
32
|
+
- Requests with words no tool can apply ("paid late", "last month", "top 3", a stray amount) used to return
|
|
33
|
+
`succeeded`. They now return `partial` and list the words under **Not applied**.
|
|
34
|
+
- Counting with conditions ("how many invoices above $8,000") ignored the conditions.
|
|
35
|
+
- Ambiguous numeric dates (`03/04/2026`) were read silently. They are now flagged, and `[extraction] day_first`
|
|
36
|
+
sets the order.
|
|
37
|
+
- The currency is read from a label ("TOTAL DUE (USD)") when the amount has no symbol. Added EGP / E£.
|
|
38
|
+
- `grounded()` accepted "Acme owes Bob" against "Bob owes Acme". It now also requires the evidence's order of
|
|
39
|
+
names and numbers, and is documented as a necessary check, not proof of correctness.
|
|
40
|
+
- Reader answers whose surroundings share no word with the question are penalised.
|
|
41
|
+
|
|
42
|
+
### Changed
|
|
43
|
+
- Results report confidence twice: `interpretation_confidence` (was the request understood) and
|
|
44
|
+
`evidence_confidence` (do the documents support it). `confidence` is the lower of the two. Results also
|
|
45
|
+
carry `interpretation` and `not_understood`, shown in the CLI and the web workspace.
|
|
46
|
+
- Docs: "verified" now explicitly means provenance (the text exists where cited), not semantic correctness.
|
|
47
|
+
- Benchmarks: three invoice layouts instead of one, plus a request-handling score.
|
|
48
|
+
|
|
49
|
+
### Configuration
|
|
50
|
+
- Config schema version `1`. Configs declaring a newer version are rejected with a clear message.
|
|
51
|
+
Future migrations will run oldest-first in `config._migrate`.
|
|
52
|
+
- Library database schema version `1` (`meta.schema_version`).
|
inklight-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
inklight-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Inklight
|
|
2
|
+
Copyright 2026 Mahmoud AboEl-Wfa
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
|
|
6
|
+
Inklight uses, but does not include, the following third-party software and models,
|
|
7
|
+
which are installed or downloaded separately under their own licenses:
|
|
8
|
+
|
|
9
|
+
- Indra OCR (https://github.com/datalab-to/indra), code under Apache-2.0,
|
|
10
|
+
Copyright Datalab. Its model weights (https://huggingface.co/datalab-to/indra-ocr)
|
|
11
|
+
are licensed under a modified OpenRAIL-M license with commercial-use restrictions.
|
|
12
|
+
- DistilBERT SQuAD (Apache-2.0), BGE-small-en-v1.5 (MIT) and SmolLM2-135M-Instruct
|
|
13
|
+
(Apache-2.0), downloaded on request by `inklight models pull`.
|
|
14
|
+
|
|
15
|
+
See THIRD_PARTY_LICENSES.md for the full audit.
|
inklight-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: inklight
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Inklight — a local-first, OCR-powered document agent. See documents. Understand meaning. Take action.
|
|
5
|
+
Project-URL: Homepage, https://github.com/MahmoudYahiaAhmed/inklight
|
|
6
|
+
Project-URL: Documentation, https://github.com/MahmoudYahiaAhmed/inklight/tree/main/docs
|
|
7
|
+
Project-URL: Issues, https://github.com/MahmoudYahiaAhmed/inklight/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/MahmoudYahiaAhmed/inklight/blob/main/CHANGELOG.md
|
|
9
|
+
Project-URL: Source, https://github.com/MahmoudYahiaAhmed/inklight
|
|
10
|
+
Author: Mahmoud AboEl-Wfa
|
|
11
|
+
Maintainer: Mahmoud AboEl-Wfa
|
|
12
|
+
License-Expression: Apache-2.0
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
License-File: NOTICE
|
|
15
|
+
License-File: THIRD_PARTY_LICENSES.md
|
|
16
|
+
Keywords: agent,document-ai,extraction,invoice,local-first,ocr,pdf,rag
|
|
17
|
+
Classifier: Development Status :: 4 - Beta
|
|
18
|
+
Classifier: Environment :: Console
|
|
19
|
+
Classifier: Environment :: Web Environment
|
|
20
|
+
Classifier: Intended Audience :: Developers
|
|
21
|
+
Classifier: Operating System :: OS Independent
|
|
22
|
+
Classifier: Programming Language :: Python :: 3
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
26
|
+
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
|
27
|
+
Classifier: Topic :: Text Processing :: General
|
|
28
|
+
Classifier: Typing :: Typed
|
|
29
|
+
Requires-Python: >=3.11
|
|
30
|
+
Requires-Dist: fastapi>=0.110
|
|
31
|
+
Requires-Dist: indra-ocr>=1.1
|
|
32
|
+
Requires-Dist: numpy>=1.24
|
|
33
|
+
Requires-Dist: pydantic>=2.6
|
|
34
|
+
Requires-Dist: python-multipart>=0.0.9
|
|
35
|
+
Requires-Dist: rich>=13
|
|
36
|
+
Requires-Dist: tokenizers>=0.19
|
|
37
|
+
Requires-Dist: typer>=0.12
|
|
38
|
+
Requires-Dist: uvicorn>=0.29
|
|
39
|
+
Provides-Extra: dev
|
|
40
|
+
Requires-Dist: httpx>=0.27; extra == 'dev'
|
|
41
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
42
|
+
Requires-Dist: pymupdf>=1.24; extra == 'dev'
|
|
43
|
+
Requires-Dist: pytest-cov>=5; extra == 'dev'
|
|
44
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
45
|
+
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
46
|
+
Provides-Extra: remote
|
|
47
|
+
Requires-Dist: httpx>=0.27; extra == 'remote'
|
|
48
|
+
Description-Content-Type: text/markdown
|
|
49
|
+
|
|
50
|
+
<p align="center">
|
|
51
|
+
<img src="https://raw.githubusercontent.com/MahmoudYahiaAhmed/inklight/main/docs/assets/logo.svg" width="84" alt="Inklight logo">
|
|
52
|
+
</p>
|
|
53
|
+
|
|
54
|
+
<h1 align="center">inklight</h1>
|
|
55
|
+
|
|
56
|
+
<p align="center"><b>See documents. Understand meaning. Take action.</b><br>
|
|
57
|
+
A local-first, OCR-powered document agent for Python — fast on a laptop CPU, and it shows its evidence.</p>
|
|
58
|
+
|
|
59
|
+
<p align="center">
|
|
60
|
+
<a href="https://github.com/MahmoudYahiaAhmed/inklight/actions/workflows/ci.yml"><img alt="ci" src="https://github.com/MahmoudYahiaAhmed/inklight/actions/workflows/ci.yml/badge.svg"></a>
|
|
61
|
+
<a href="https://pypi.org/project/inklight/"><img alt="pypi" src="https://img.shields.io/pypi/v/inklight?style=flat-square&labelColor=0B0F14&color=22D3EE"></a>
|
|
62
|
+
<img alt="python" src="https://img.shields.io/badge/python-3.11%2B-22D3EE?style=flat-square&labelColor=0B0F14">
|
|
63
|
+
<img alt="license" src="https://img.shields.io/badge/code-Apache--2.0-F5B544?style=flat-square&labelColor=0B0F14">
|
|
64
|
+
<img alt="ocr" src="https://img.shields.io/badge/OCR-Indra-22D3EE?style=flat-square&labelColor=0B0F14">
|
|
65
|
+
<img alt="local" src="https://img.shields.io/badge/runs-offline-F5B544?style=flat-square&labelColor=0B0F14">
|
|
66
|
+
</p>
|
|
67
|
+
|
|
68
|
+
<p align="center"><img src="https://raw.githubusercontent.com/MahmoudYahiaAhmed/inklight/main/docs/assets/workspace.jpg" width="860" alt="The Inklight workspace: an evidence-backed answer with the source line highlighted on the page"></p>
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
Point Inklight at a folder of PDFs, scans or photos and ask for what you need, in plain language:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
inklight ask ./invoices "Read all these invoices and create a CSV of vendor, date, tax, and total" --out ./out
|
|
76
|
+
inklight ask ./contracts "Find every contract that expires within 90 days"
|
|
77
|
+
inklight ask ./reports "Compare these reports and explain the differences"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
You get an answer **plus the page, line and bounding box it came from**, a confidence score, warnings when
|
|
81
|
+
something looks off, and a trace of every step the agent took.
|
|
82
|
+
|
|
83
|
+
## Why Inklight
|
|
84
|
+
|
|
85
|
+
- **Real OCR, on CPU.** Built on [Indra OCR](https://github.com/datalab-to/indra): 43 ms per digital PDF page,
|
|
86
|
+
98 ms per scanned page on a laptop ([benchmarks](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/docs/BENCHMARKS.md)). Digital PDFs use their text layer
|
|
87
|
+
first, and OCR runs only where needed.
|
|
88
|
+
- **An agent, not a chatbot wrapper.** It works out the intent, then runs a minimal plan of typed tools
|
|
89
|
+
(search, extract, filter, calculate, compare, find inconsistencies, summarise, write). Every run has
|
|
90
|
+
step limits, time budgets, retries and cancellation.
|
|
91
|
+
- **Shows its work, and its limits.** Every result says *how your request was understood* ("vendor contains
|
|
92
|
+
Acme; total > 5,000 USD") and lists anything it could **not** apply, instead of quietly answering a broader
|
|
93
|
+
question. Values come from labelled fields, extractive spans or quoted sentences with page and position.
|
|
94
|
+
A citation proves where a value came from, not that it answers your question, so confidence is reported
|
|
95
|
+
twice: *understood* (did it read your request right) and *evidence* (OCR, labels, `subtotal + tax = total`).
|
|
96
|
+
Amounts in different currencies are never added or compared to each other.
|
|
97
|
+
- **Small-model intelligence, measured.** Optional models are each under 200M parameters: a 66M reader that
|
|
98
|
+
can only point at text in your document, a 33M embedder for search, and an optional 135M writer whose output
|
|
99
|
+
must be grounded. Calculations and filters are exact Python, not model guesses.
|
|
100
|
+
- **Local and private by default.** No API key needed. Nothing leaves your machine unless you configure a remote model.
|
|
101
|
+
- **Safe with untrusted documents.** "Ignore previous instructions" inside a PDF is treated as data and flagged.
|
|
102
|
+
The agent has no shell, no code execution, and writes files only where you allow. See [SECURITY.md](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/SECURITY.md).
|
|
103
|
+
|
|
104
|
+
## Install
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
pip install inklight # Python 3.11+, Windows / Linux / macOS, CPU only
|
|
108
|
+
inklight models pull # optional: 66M reader + 33M embedder (~100 MB, once)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Indra's OCR models (~76 MB) download automatically on the first OCR run. After that, everything works offline.
|
|
112
|
+
|
|
113
|
+
## 60-second tour
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
inklight process ./documents/ # OCR, classify and index (incremental)
|
|
117
|
+
inklight ask ./documents/ "Find all invoices above $5,000"
|
|
118
|
+
inklight extract invoice.pdf --schema invoice.json --format csv
|
|
119
|
+
inklight serve # web workspace on http://127.0.0.1:8765
|
|
120
|
+
inklight watch ./inbox -r "extract vendor and total as csv" -o ./out # automation
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
from inklight import DocumentAgent
|
|
125
|
+
|
|
126
|
+
agent = DocumentAgent()
|
|
127
|
+
result = agent.ask("Extract the invoice number, date, and total", files=["invoice.pdf"])
|
|
128
|
+
|
|
129
|
+
print(result.answer) # human-readable answer
|
|
130
|
+
print(result.table()) # [{'document': 'invoice.pdf', 'invoice_number': 'INV-2041', 'date': '2026-10-03', 'total': 5616.0}]
|
|
131
|
+
print(result.sources[0]) # name='invoice.pdf' page=1 bbox=(200.4, 325.0, 667.6, 359.5) excerpt='INVOICE #INV-2041' ocr_conf=1.0
|
|
132
|
+
print(result.warnings, result.confidence, result.trace)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
More: typed extraction without natural language (`agent.extract(files, fields=[...])` or `schema=`), `ask_async`,
|
|
136
|
+
library management (`agent.library.search/remove/reindex`), and the HTTP API at `/api/docs` when serving.
|
|
137
|
+
See [docs/API.md](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/docs/API.md).
|
|
138
|
+
|
|
139
|
+
## What it can do
|
|
140
|
+
|
|
141
|
+
| You say | Inklight does | Tools |
|
|
142
|
+
|---|---|---|
|
|
143
|
+
| "create a CSV of vendor, date, tax and total" | Typed extraction with provenance, then writes the CSV (with permission) | `extract_fields → write_output` |
|
|
144
|
+
| "contracts that expire within 90 days" | Extracts expiry dates, filters by date window | `extract_fields → filter_records` |
|
|
145
|
+
| "invoices above $5,000" | Exact numeric filter | `extract_fields → filter_records` |
|
|
146
|
+
| "sum of all invoice totals" | Decimal arithmetic, reports missing values | `extract_fields → calculate` |
|
|
147
|
+
| "compare these reports" | Field and line diffs, changed figures (`6% → 17%`) | `compare_documents` |
|
|
148
|
+
| "flag inconsistent customer names" | Fuzzy grouping of variants, arithmetic and date checks | `extract_fields → find_inconsistencies` |
|
|
149
|
+
| "find the paragraph about termination" | Retrieval, then the exact block with its box on the page | `search → cite` |
|
|
150
|
+
| "what was revenue growth in Q2?" | Field shortcut, extractive reader, or best sentence, with citation | `search → answer` |
|
|
151
|
+
| "summarize the reports" | Extractive summaries with page citations | `summarize` |
|
|
152
|
+
|
|
153
|
+
## How it works
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
request ─► planner (typed plan, from your words only) ─► bounded runner ─► tools ─► cited answer + what it understood
|
|
157
|
+
│
|
|
158
|
+
library: SQLite + FTS5 (+ vectors) ◄── ingest ◄── Indra OCR (text layer first, OCR where needed)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Details in [docs/ARCHITECTURE.md](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/docs/ARCHITECTURE.md). The short version of the "200M-parameter" story:
|
|
162
|
+
we measured a 135M model as a planner and it was right 27.5% of the time, so the small models do what small
|
|
163
|
+
models are good at (pointing at evidence, ranking passages) and deterministic code does the rest.
|
|
164
|
+
|
|
165
|
+
## Configuration
|
|
166
|
+
|
|
167
|
+
`~/.inklight/config.toml` (see [config.example.toml](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/config.example.toml)) or environment variables such as
|
|
168
|
+
`INKLIGHT_LIMITS__MAX_PAGES=50`. Brain modes:
|
|
169
|
+
- `rules`: no models.
|
|
170
|
+
- `auto` (default): use the small models if they are installed.
|
|
171
|
+
- `local`: require the small models.
|
|
172
|
+
- `models.remote_*`: optional stronger model behind an OpenAI-compatible API, for low-confidence questions.
|
|
173
|
+
|
|
174
|
+
## Limits, honestly
|
|
175
|
+
|
|
176
|
+
- OCR quality is Indra's. It is weaker on handwriting, degraded scans, complex tables and some scripts
|
|
177
|
+
([Indra's notes](https://github.com/datalab-to/indra)). Low OCR confidence is surfaced on every value.
|
|
178
|
+
- Field labels are English. Ambiguous dates like `03/04/2026` are read month-first.
|
|
179
|
+
- The rule planner covers common document tasks. Unusual phrasing falls back to question answering,
|
|
180
|
+
or to a remote model if you configured one.
|
|
181
|
+
- Semantic search scans vectors in memory, which suits libraries up to tens of thousands of chunks.
|
|
182
|
+
|
|
183
|
+
## ⚠ License notice — read before commercial use
|
|
184
|
+
|
|
185
|
+
Inklight's code is **Apache-2.0**. The **Indra OCR model weights** (downloaded by `indra-ocr`, not
|
|
186
|
+
bundled) use a **modified OpenRAIL-M license**. It is free for research, personal use, and organisations
|
|
187
|
+
under $20M revenue and under $20M funding. It restricts commercial use that **competes with Datalab**.
|
|
188
|
+
A commercial document-AI product built on Inklight + Indra needs a license from
|
|
189
|
+
[Datalab](https://www.datalab.to/pricing), or a different OCR engine (the OCR layer is pluggable).
|
|
190
|
+
Full audit: [THIRD_PARTY_LICENSES.md](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/THIRD_PARTY_LICENSES.md).
|
|
191
|
+
|
|
192
|
+
## Development
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
pip install -e ".[dev]"
|
|
196
|
+
pytest # 128 tests, about 1 minute on CPU (downloads Indra models on first run)
|
|
197
|
+
ruff check src tests && mypy src
|
|
198
|
+
python bench/run.py # reproduces docs/BENCHMARKS.md
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
See [CONTRIBUTING.md](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/CONTRIBUTING.md), [CHANGELOG.md](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/CHANGELOG.md), [CODE_OF_CONDUCT.md](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/CODE_OF_CONDUCT.md)
|
|
202
|
+
and, for maintainers, [docs/PUBLISHING.md](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/docs/PUBLISHING.md).
|
inklight-0.1.0/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/MahmoudYahiaAhmed/inklight/main/docs/assets/logo.svg" width="84" alt="Inklight logo">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">inklight</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center"><b>See documents. Understand meaning. Take action.</b><br>
|
|
8
|
+
A local-first, OCR-powered document agent for Python — fast on a laptop CPU, and it shows its evidence.</p>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="https://github.com/MahmoudYahiaAhmed/inklight/actions/workflows/ci.yml"><img alt="ci" src="https://github.com/MahmoudYahiaAhmed/inklight/actions/workflows/ci.yml/badge.svg"></a>
|
|
12
|
+
<a href="https://pypi.org/project/inklight/"><img alt="pypi" src="https://img.shields.io/pypi/v/inklight?style=flat-square&labelColor=0B0F14&color=22D3EE"></a>
|
|
13
|
+
<img alt="python" src="https://img.shields.io/badge/python-3.11%2B-22D3EE?style=flat-square&labelColor=0B0F14">
|
|
14
|
+
<img alt="license" src="https://img.shields.io/badge/code-Apache--2.0-F5B544?style=flat-square&labelColor=0B0F14">
|
|
15
|
+
<img alt="ocr" src="https://img.shields.io/badge/OCR-Indra-22D3EE?style=flat-square&labelColor=0B0F14">
|
|
16
|
+
<img alt="local" src="https://img.shields.io/badge/runs-offline-F5B544?style=flat-square&labelColor=0B0F14">
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center"><img src="https://raw.githubusercontent.com/MahmoudYahiaAhmed/inklight/main/docs/assets/workspace.jpg" width="860" alt="The Inklight workspace: an evidence-backed answer with the source line highlighted on the page"></p>
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
Point Inklight at a folder of PDFs, scans or photos and ask for what you need, in plain language:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
inklight ask ./invoices "Read all these invoices and create a CSV of vendor, date, tax, and total" --out ./out
|
|
27
|
+
inklight ask ./contracts "Find every contract that expires within 90 days"
|
|
28
|
+
inklight ask ./reports "Compare these reports and explain the differences"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
You get an answer **plus the page, line and bounding box it came from**, a confidence score, warnings when
|
|
32
|
+
something looks off, and a trace of every step the agent took.
|
|
33
|
+
|
|
34
|
+
## Why Inklight
|
|
35
|
+
|
|
36
|
+
- **Real OCR, on CPU.** Built on [Indra OCR](https://github.com/datalab-to/indra): 43 ms per digital PDF page,
|
|
37
|
+
98 ms per scanned page on a laptop ([benchmarks](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/docs/BENCHMARKS.md)). Digital PDFs use their text layer
|
|
38
|
+
first, and OCR runs only where needed.
|
|
39
|
+
- **An agent, not a chatbot wrapper.** It works out the intent, then runs a minimal plan of typed tools
|
|
40
|
+
(search, extract, filter, calculate, compare, find inconsistencies, summarise, write). Every run has
|
|
41
|
+
step limits, time budgets, retries and cancellation.
|
|
42
|
+
- **Shows its work, and its limits.** Every result says *how your request was understood* ("vendor contains
|
|
43
|
+
Acme; total > 5,000 USD") and lists anything it could **not** apply, instead of quietly answering a broader
|
|
44
|
+
question. Values come from labelled fields, extractive spans or quoted sentences with page and position.
|
|
45
|
+
A citation proves where a value came from, not that it answers your question, so confidence is reported
|
|
46
|
+
twice: *understood* (did it read your request right) and *evidence* (OCR, labels, `subtotal + tax = total`).
|
|
47
|
+
Amounts in different currencies are never added or compared to each other.
|
|
48
|
+
- **Small-model intelligence, measured.** Optional models are each under 200M parameters: a 66M reader that
|
|
49
|
+
can only point at text in your document, a 33M embedder for search, and an optional 135M writer whose output
|
|
50
|
+
must be grounded. Calculations and filters are exact Python, not model guesses.
|
|
51
|
+
- **Local and private by default.** No API key needed. Nothing leaves your machine unless you configure a remote model.
|
|
52
|
+
- **Safe with untrusted documents.** "Ignore previous instructions" inside a PDF is treated as data and flagged.
|
|
53
|
+
The agent has no shell, no code execution, and writes files only where you allow. See [SECURITY.md](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/SECURITY.md).
|
|
54
|
+
|
|
55
|
+
## Install
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install inklight # Python 3.11+, Windows / Linux / macOS, CPU only
|
|
59
|
+
inklight models pull # optional: 66M reader + 33M embedder (~100 MB, once)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Indra's OCR models (~76 MB) download automatically on the first OCR run. After that, everything works offline.
|
|
63
|
+
|
|
64
|
+
## 60-second tour
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
inklight process ./documents/ # OCR, classify and index (incremental)
|
|
68
|
+
inklight ask ./documents/ "Find all invoices above $5,000"
|
|
69
|
+
inklight extract invoice.pdf --schema invoice.json --format csv
|
|
70
|
+
inklight serve # web workspace on http://127.0.0.1:8765
|
|
71
|
+
inklight watch ./inbox -r "extract vendor and total as csv" -o ./out # automation
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from inklight import DocumentAgent
|
|
76
|
+
|
|
77
|
+
agent = DocumentAgent()
|
|
78
|
+
result = agent.ask("Extract the invoice number, date, and total", files=["invoice.pdf"])
|
|
79
|
+
|
|
80
|
+
print(result.answer) # human-readable answer
|
|
81
|
+
print(result.table()) # [{'document': 'invoice.pdf', 'invoice_number': 'INV-2041', 'date': '2026-10-03', 'total': 5616.0}]
|
|
82
|
+
print(result.sources[0]) # name='invoice.pdf' page=1 bbox=(200.4, 325.0, 667.6, 359.5) excerpt='INVOICE #INV-2041' ocr_conf=1.0
|
|
83
|
+
print(result.warnings, result.confidence, result.trace)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
More: typed extraction without natural language (`agent.extract(files, fields=[...])` or `schema=`), `ask_async`,
|
|
87
|
+
library management (`agent.library.search/remove/reindex`), and the HTTP API at `/api/docs` when serving.
|
|
88
|
+
See [docs/API.md](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/docs/API.md).
|
|
89
|
+
|
|
90
|
+
## What it can do
|
|
91
|
+
|
|
92
|
+
| You say | Inklight does | Tools |
|
|
93
|
+
|---|---|---|
|
|
94
|
+
| "create a CSV of vendor, date, tax and total" | Typed extraction with provenance, then writes the CSV (with permission) | `extract_fields → write_output` |
|
|
95
|
+
| "contracts that expire within 90 days" | Extracts expiry dates, filters by date window | `extract_fields → filter_records` |
|
|
96
|
+
| "invoices above $5,000" | Exact numeric filter | `extract_fields → filter_records` |
|
|
97
|
+
| "sum of all invoice totals" | Decimal arithmetic, reports missing values | `extract_fields → calculate` |
|
|
98
|
+
| "compare these reports" | Field and line diffs, changed figures (`6% → 17%`) | `compare_documents` |
|
|
99
|
+
| "flag inconsistent customer names" | Fuzzy grouping of variants, arithmetic and date checks | `extract_fields → find_inconsistencies` |
|
|
100
|
+
| "find the paragraph about termination" | Retrieval, then the exact block with its box on the page | `search → cite` |
|
|
101
|
+
| "what was revenue growth in Q2?" | Field shortcut, extractive reader, or best sentence, with citation | `search → answer` |
|
|
102
|
+
| "summarize the reports" | Extractive summaries with page citations | `summarize` |
|
|
103
|
+
|
|
104
|
+
## How it works
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
request ─► planner (typed plan, from your words only) ─► bounded runner ─► tools ─► cited answer + what it understood
|
|
108
|
+
│
|
|
109
|
+
library: SQLite + FTS5 (+ vectors) ◄── ingest ◄── Indra OCR (text layer first, OCR where needed)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Details in [docs/ARCHITECTURE.md](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/docs/ARCHITECTURE.md). The short version of the "200M-parameter" story:
|
|
113
|
+
we measured a 135M model as a planner and it was right 27.5% of the time, so the small models do what small
|
|
114
|
+
models are good at (pointing at evidence, ranking passages) and deterministic code does the rest.
|
|
115
|
+
|
|
116
|
+
## Configuration
|
|
117
|
+
|
|
118
|
+
`~/.inklight/config.toml` (see [config.example.toml](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/config.example.toml)) or environment variables such as
|
|
119
|
+
`INKLIGHT_LIMITS__MAX_PAGES=50`. Brain modes:
|
|
120
|
+
- `rules`: no models.
|
|
121
|
+
- `auto` (default): use the small models if they are installed.
|
|
122
|
+
- `local`: require the small models.
|
|
123
|
+
- `models.remote_*`: optional stronger model behind an OpenAI-compatible API, for low-confidence questions.
|
|
124
|
+
|
|
125
|
+
## Limits, honestly
|
|
126
|
+
|
|
127
|
+
- OCR quality is Indra's. It is weaker on handwriting, degraded scans, complex tables and some scripts
|
|
128
|
+
([Indra's notes](https://github.com/datalab-to/indra)). Low OCR confidence is surfaced on every value.
|
|
129
|
+
- Field labels are English. Ambiguous dates like `03/04/2026` are read month-first.
|
|
130
|
+
- The rule planner covers common document tasks. Unusual phrasing falls back to question answering,
|
|
131
|
+
or to a remote model if you configured one.
|
|
132
|
+
- Semantic search scans vectors in memory, which suits libraries up to tens of thousands of chunks.
|
|
133
|
+
|
|
134
|
+
## ⚠ License notice — read before commercial use
|
|
135
|
+
|
|
136
|
+
Inklight's code is **Apache-2.0**. The **Indra OCR model weights** (downloaded by `indra-ocr`, not
|
|
137
|
+
bundled) use a **modified OpenRAIL-M license**. It is free for research, personal use, and organisations
|
|
138
|
+
under $20M revenue and under $20M funding. It restricts commercial use that **competes with Datalab**.
|
|
139
|
+
A commercial document-AI product built on Inklight + Indra needs a license from
|
|
140
|
+
[Datalab](https://www.datalab.to/pricing), or a different OCR engine (the OCR layer is pluggable).
|
|
141
|
+
Full audit: [THIRD_PARTY_LICENSES.md](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/THIRD_PARTY_LICENSES.md).
|
|
142
|
+
|
|
143
|
+
## Development
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
pip install -e ".[dev]"
|
|
147
|
+
pytest # 128 tests, about 1 minute on CPU (downloads Indra models on first run)
|
|
148
|
+
ruff check src tests && mypy src
|
|
149
|
+
python bench/run.py # reproduces docs/BENCHMARKS.md
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
See [CONTRIBUTING.md](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/CONTRIBUTING.md), [CHANGELOG.md](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/CHANGELOG.md), [CODE_OF_CONDUCT.md](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/CODE_OF_CONDUCT.md)
|
|
153
|
+
and, for maintainers, [docs/PUBLISHING.md](https://github.com/MahmoudYahiaAhmed/inklight/blob/main/docs/PUBLISHING.md).
|