operonx-kb 0.2.1__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.
- operonx_kb-0.2.1/.gitignore +10 -0
- operonx_kb-0.2.1/LICENSE +201 -0
- operonx_kb-0.2.1/PKG-INFO +130 -0
- operonx_kb-0.2.1/README.md +84 -0
- operonx_kb-0.2.1/operonx_kb/__init__.py +71 -0
- operonx_kb-0.2.1/operonx_kb/admin/__init__.py +24 -0
- operonx_kb-0.2.1/operonx_kb/admin/asgi.py +194 -0
- operonx_kb-0.2.1/operonx_kb/admin/pages.py +99 -0
- operonx_kb-0.2.1/operonx_kb/admin/views.py +556 -0
- operonx_kb-0.2.1/operonx_kb/chunking/__init__.py +26 -0
- operonx_kb-0.2.1/operonx_kb/chunking/base.py +202 -0
- operonx_kb-0.2.1/operonx_kb/chunking/recursive.py +72 -0
- operonx_kb-0.2.1/operonx_kb/chunking/structural.py +267 -0
- operonx_kb-0.2.1/operonx_kb/cli.py +337 -0
- operonx_kb-0.2.1/operonx_kb/enrich/__init__.py +15 -0
- operonx_kb-0.2.1/operonx_kb/enrich/base.py +60 -0
- operonx_kb-0.2.1/operonx_kb/enrich/concepts.py +100 -0
- operonx_kb-0.2.1/operonx_kb/enrich/contextual.py +106 -0
- operonx_kb-0.2.1/operonx_kb/enrich/tree.py +346 -0
- operonx_kb-0.2.1/operonx_kb/errors.py +106 -0
- operonx_kb-0.2.1/operonx_kb/eval/__init__.py +43 -0
- operonx_kb-0.2.1/operonx_kb/eval/cases.py +69 -0
- operonx_kb-0.2.1/operonx_kb/eval/evaluators.py +189 -0
- operonx_kb-0.2.1/operonx_kb/eval/labels.py +91 -0
- operonx_kb-0.2.1/operonx_kb/eval/metrics.py +131 -0
- operonx_kb-0.2.1/operonx_kb/eval/run.py +92 -0
- operonx_kb-0.2.1/operonx_kb/graphs/__init__.py +31 -0
- operonx_kb-0.2.1/operonx_kb/graphs/answer.py +62 -0
- operonx_kb-0.2.1/operonx_kb/graphs/enrich.py +117 -0
- operonx_kb-0.2.1/operonx_kb/graphs/ingest.py +144 -0
- operonx_kb-0.2.1/operonx_kb/graphs/maintenance.py +161 -0
- operonx_kb-0.2.1/operonx_kb/graphs/retrieve.py +260 -0
- operonx_kb-0.2.1/operonx_kb/kb.py +417 -0
- operonx_kb-0.2.1/operonx_kb/maintenance.py +150 -0
- operonx_kb-0.2.1/operonx_kb/model/__init__.py +49 -0
- operonx_kb-0.2.1/operonx_kb/model/collection.py +326 -0
- operonx_kb-0.2.1/operonx_kb/model/document.py +229 -0
- operonx_kb-0.2.1/operonx_kb/model/filter.py +274 -0
- operonx_kb-0.2.1/operonx_kb/model/ids.py +147 -0
- operonx_kb-0.2.1/operonx_kb/model/tree.py +51 -0
- operonx_kb-0.2.1/operonx_kb/ops/__init__.py +30 -0
- operonx_kb-0.2.1/operonx_kb/ops/_resources.py +86 -0
- operonx_kb-0.2.1/operonx_kb/ops/answer.py +105 -0
- operonx_kb-0.2.1/operonx_kb/ops/embed.py +82 -0
- operonx_kb-0.2.1/operonx_kb/ops/enrich.py +350 -0
- operonx_kb-0.2.1/operonx_kb/ops/graph.py +87 -0
- operonx_kb-0.2.1/operonx_kb/ops/ingest.py +460 -0
- operonx_kb-0.2.1/operonx_kb/ops/lexical.py +133 -0
- operonx_kb-0.2.1/operonx_kb/ops/maintenance.py +196 -0
- operonx_kb-0.2.1/operonx_kb/ops/retrieve.py +279 -0
- operonx_kb-0.2.1/operonx_kb/ops/serve.py +39 -0
- operonx_kb-0.2.1/operonx_kb/ops/settings.py +137 -0
- operonx_kb-0.2.1/operonx_kb/ops/tree.py +142 -0
- operonx_kb-0.2.1/operonx_kb/parsing/__init__.py +0 -0
- operonx_kb-0.2.1/operonx_kb/parsing/_ooxml.py +137 -0
- operonx_kb-0.2.1/operonx_kb/parsing/_text.py +47 -0
- operonx_kb-0.2.1/operonx_kb/parsing/base.py +132 -0
- operonx_kb-0.2.1/operonx_kb/parsing/docx.py +383 -0
- operonx_kb-0.2.1/operonx_kb/parsing/html.py +420 -0
- operonx_kb-0.2.1/operonx_kb/parsing/markdown.py +282 -0
- operonx_kb-0.2.1/operonx_kb/parsing/plain.py +37 -0
- operonx_kb-0.2.1/operonx_kb/parsing/pptx.py +356 -0
- operonx_kb-0.2.1/operonx_kb/parsing/router.py +103 -0
- operonx_kb-0.2.1/operonx_kb/parsing/xlsx.py +190 -0
- operonx_kb-0.2.1/operonx_kb/pdf/__init__.py +0 -0
- operonx_kb-0.2.1/operonx_kb/pdf/assemble.py +136 -0
- operonx_kb-0.2.1/operonx_kb/pdf/backend.py +295 -0
- operonx_kb-0.2.1/operonx_kb/pdf/layout.py +1248 -0
- operonx_kb-0.2.1/operonx_kb/pdf/models.py +536 -0
- operonx_kb-0.2.1/operonx_kb/pdf/parser.py +100 -0
- operonx_kb-0.2.1/operonx_kb/pdf/reading_order.py +239 -0
- operonx_kb-0.2.1/operonx_kb/pipeline.py +76 -0
- operonx_kb-0.2.1/operonx_kb/registry.py +171 -0
- operonx_kb-0.2.1/operonx_kb/retrieval/__init__.py +6 -0
- operonx_kb-0.2.1/operonx_kb/retrieval/citations.py +257 -0
- operonx_kb-0.2.1/operonx_kb/retrieval/context.py +174 -0
- operonx_kb-0.2.1/operonx_kb/retrieval/filters.py +306 -0
- operonx_kb-0.2.1/operonx_kb/retrieval/fusion.py +50 -0
- operonx_kb-0.2.1/operonx_kb/retrieval/graph.py +161 -0
- operonx_kb-0.2.1/operonx_kb/stores/__init__.py +0 -0
- operonx_kb-0.2.1/operonx_kb/stores/catalog/__init__.py +7 -0
- operonx_kb-0.2.1/operonx_kb/stores/catalog/base.py +279 -0
- operonx_kb-0.2.1/operonx_kb/stores/catalog/migrations/__init__.py +0 -0
- operonx_kb-0.2.1/operonx_kb/stores/catalog/migrations/postgres/001_init.sql +117 -0
- operonx_kb-0.2.1/operonx_kb/stores/catalog/migrations/postgres/002_index_entries.sql +18 -0
- operonx_kb-0.2.1/operonx_kb/stores/catalog/migrations/postgres/003_document_acl.sql +5 -0
- operonx_kb-0.2.1/operonx_kb/stores/catalog/migrations/postgres/004_enrichment.sql +38 -0
- operonx_kb-0.2.1/operonx_kb/stores/catalog/migrations/postgres/005_graph.sql +13 -0
- operonx_kb-0.2.1/operonx_kb/stores/catalog/migrations/postgres/__init__.py +0 -0
- operonx_kb-0.2.1/operonx_kb/stores/catalog/migrations/sqlite/001_init.sql +116 -0
- operonx_kb-0.2.1/operonx_kb/stores/catalog/migrations/sqlite/002_index_entries.sql +18 -0
- operonx_kb-0.2.1/operonx_kb/stores/catalog/migrations/sqlite/003_document_acl.sql +5 -0
- operonx_kb-0.2.1/operonx_kb/stores/catalog/migrations/sqlite/004_enrichment.sql +38 -0
- operonx_kb-0.2.1/operonx_kb/stores/catalog/migrations/sqlite/005_graph.sql +13 -0
- operonx_kb-0.2.1/operonx_kb/stores/catalog/migrations/sqlite/__init__.py +0 -0
- operonx_kb-0.2.1/operonx_kb/stores/catalog/postgres.py +103 -0
- operonx_kb-0.2.1/operonx_kb/stores/catalog/sql.py +803 -0
- operonx_kb-0.2.1/operonx_kb/stores/catalog/sqlite.py +65 -0
- operonx_kb-0.2.1/operonx_kb/stores/lexical/__init__.py +6 -0
- operonx_kb-0.2.1/operonx_kb/stores/lexical/base.py +106 -0
- operonx_kb-0.2.1/operonx_kb/stores/lexical/postgres.py +193 -0
- operonx_kb-0.2.1/operonx_kb/stores/lexical/sqlite.py +159 -0
- operonx_kb-0.2.1/operonx_kb/structure/__init__.py +0 -0
- operonx_kb-0.2.1/operonx_kb/structure/build.py +406 -0
- operonx_kb-0.2.1/operonx_kb/testing/__init__.py +22 -0
- operonx_kb-0.2.1/operonx_kb/testing/fakes.py +219 -0
- operonx_kb-0.2.1/operonx_kb/testing/golden.py +92 -0
- operonx_kb-0.2.1/operonx_kb/testing/layout_crops.py +72 -0
- operonx_kb-0.2.1/operonx_kb/testing/layout_eval.py +294 -0
- operonx_kb-0.2.1/operonx_kb/testing/trace.py +34 -0
- operonx_kb-0.2.1/operonx_kb/text/__init__.py +0 -0
- operonx_kb-0.2.1/operonx_kb/text/analyze.py +80 -0
- operonx_kb-0.2.1/operonx_kb/text/normalize.py +70 -0
- operonx_kb-0.2.1/operonx_kb/text/sentences.py +61 -0
- operonx_kb-0.2.1/operonx_kb/text/spans.py +220 -0
- operonx_kb-0.2.1/operonx_kb/text/tokenize.py +51 -0
- operonx_kb-0.2.1/operonx_kb/tools.py +132 -0
- operonx_kb-0.2.1/pyproject.toml +105 -0
operonx_kb-0.2.1/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
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.
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: operonx-kb
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: Knowledge base and document intelligence on OperonX: versioned documents with span-level provenance
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Requires-Dist: defusedxml>=0.7.1
|
|
9
|
+
Requires-Dist: httpx>=0.24
|
|
10
|
+
Requires-Dist: numpy>=1.24
|
|
11
|
+
Requires-Dist: operonx>=1.16
|
|
12
|
+
Requires-Dist: pydantic>=2.0
|
|
13
|
+
Provides-Extra: admin
|
|
14
|
+
Requires-Dist: operonx[serve]; extra == 'admin'
|
|
15
|
+
Requires-Dist: pillow>=10; extra == 'admin'
|
|
16
|
+
Requires-Dist: pypdfium2>=4.30; extra == 'admin'
|
|
17
|
+
Provides-Extra: all
|
|
18
|
+
Requires-Dist: docling-parse>=7.22; extra == 'all'
|
|
19
|
+
Requires-Dist: operonx[faiss]; extra == 'all'
|
|
20
|
+
Requires-Dist: operonx[openai]; extra == 'all'
|
|
21
|
+
Requires-Dist: operonx[serve]; extra == 'all'
|
|
22
|
+
Requires-Dist: pillow>=10; extra == 'all'
|
|
23
|
+
Requires-Dist: psycopg-pool>=3.2; extra == 'all'
|
|
24
|
+
Requires-Dist: psycopg[binary]>=3.1; extra == 'all'
|
|
25
|
+
Requires-Dist: pypdfium2>=4.30; extra == 'all'
|
|
26
|
+
Provides-Extra: answer
|
|
27
|
+
Requires-Dist: operonx[openai]; extra == 'answer'
|
|
28
|
+
Provides-Extra: faiss
|
|
29
|
+
Requires-Dist: operonx[faiss]; extra == 'faiss'
|
|
30
|
+
Provides-Extra: layout
|
|
31
|
+
Requires-Dist: docling-ibm-models[opencv-python-headless]>=4.0; extra == 'layout'
|
|
32
|
+
Requires-Dist: docling-parse>=7.22; extra == 'layout'
|
|
33
|
+
Requires-Dist: pypdfium2>=4.30; extra == 'layout'
|
|
34
|
+
Requires-Dist: torch>=2.2.2; extra == 'layout'
|
|
35
|
+
Requires-Dist: torchvision; extra == 'layout'
|
|
36
|
+
Provides-Extra: pdf
|
|
37
|
+
Requires-Dist: docling-parse>=7.22; extra == 'pdf'
|
|
38
|
+
Provides-Extra: pgvector
|
|
39
|
+
Requires-Dist: operonx[pgvector]; extra == 'pgvector'
|
|
40
|
+
Provides-Extra: postgres
|
|
41
|
+
Requires-Dist: psycopg-pool>=3.2; extra == 'postgres'
|
|
42
|
+
Requires-Dist: psycopg[binary]>=3.1; extra == 'postgres'
|
|
43
|
+
Provides-Extra: qdrant
|
|
44
|
+
Requires-Dist: operonx[qdrant]; extra == 'qdrant'
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
|
|
47
|
+
# operonx-kb
|
|
48
|
+
|
|
49
|
+
Knowledge base and document intelligence on [operonx](https://github.com/batman1m2001-cyber/Operonx): files become versioned documents
|
|
50
|
+
whose every character has an address (version, span → page, bbox), indexed for retrieval, and
|
|
51
|
+
answers cite spans that were checked against the text they quote.
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
uv sync --extra pdf --extra faiss # core + PDF text layer + FAISS index
|
|
55
|
+
PYTHONPATH=../operonx-wt/feat-kb-upstream uv run pytest -q # until operonx PR #74 merges
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
import operonx
|
|
60
|
+
from operonx_kb import CollectionSpec, DenseIndexSpec, KnowledgeBase
|
|
61
|
+
from operonx_kb.model.collection import LexicalIndexSpec
|
|
62
|
+
|
|
63
|
+
operonx.bootstrap(resources="resources.yaml") # kb_catalog:, kb_blob:, kb_lexical:, embedding:, vector_store:, llm:
|
|
64
|
+
kb = KnowledgeBase()
|
|
65
|
+
kb.create_collection("handbook", CollectionSpec(
|
|
66
|
+
dense=DenseIndexSpec(embedder="e5", store="vector_store:kb",
|
|
67
|
+
passage_template="passage: {text}", query_template="query: {text}"),
|
|
68
|
+
lexical=LexicalIndexSpec(), # SQLite FTS5 or Postgres FTS
|
|
69
|
+
filterable={"dept": "keyword"},
|
|
70
|
+
))
|
|
71
|
+
await kb.add("handbook", "policy.pdf", key="policy.pdf", tags=["hr"], acl=["team:hr"],
|
|
72
|
+
metadata={"dept": "hr"})
|
|
73
|
+
found = await kb.search("handbook", "how many days of leave", mode="hybrid",
|
|
74
|
+
filter={"acl_any": ["team:hr"]}, reranker="ce")
|
|
75
|
+
answer = await kb.ask("handbook", "how many days of leave", "assistant")
|
|
76
|
+
answer["citations"] # each: quote, canonical span, pages, bboxes; unverified ones are in answer["dropped"]
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
operonx-kb query handbook "how many days of leave" --mode hybrid --tag hr
|
|
81
|
+
operonx-kb query wiki "who directed the film that won in 1999" --mode graph # created with --graph
|
|
82
|
+
operonx-kb query handbook "how many days of leave" --answer assistant
|
|
83
|
+
operonx-kb eval handbook datasets/handbook.jsonl --mode hybrid
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Use it inside your flows
|
|
87
|
+
|
|
88
|
+
A search is an operonx graph, so it is one step of your own flow — traced with it, no service in
|
|
89
|
+
between (`tests/graphs/test_in_a_flow.py`):
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from operonx.kb.graphs import search # module level: the collection's settings are read per run
|
|
93
|
+
|
|
94
|
+
@graph
|
|
95
|
+
def answer_flow(question, catalog):
|
|
96
|
+
found = search(query=question, collection="handbook", filter=None, k=5, mode="hybrid",
|
|
97
|
+
catalog=catalog)
|
|
98
|
+
reply = cite(hits=found["hits"]) # your own op
|
|
99
|
+
START >> found >> reply >> END
|
|
100
|
+
|
|
101
|
+
engine = Operon(answer_flow, params={"question": None, "catalog": None})
|
|
102
|
+
out = await engine.run(inputs={"question": "...", "catalog": "kb_catalog:main"})
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
For an agent (operonx-agents installed beside it), `kb_tools` gives a read-only `kb_search` /
|
|
106
|
+
`kb_read` toolset. The scope comes from your code or the run's context — the model only sends a
|
|
107
|
+
query — and `kb_read` checks it again (`tests/graphs/test_agent_tools.py`):
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from operonx.kb.tools import kb_tools
|
|
111
|
+
|
|
112
|
+
tools = kb_tools(kb, "handbook", scope=lambda ctx: {"acl_any": ctx.deps.principals})
|
|
113
|
+
agent = Agent(name="hr", model=Model("assistant"), tools=[tools])
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Studio's Knowledge tab reads a knowledge base through its admin API (extra `admin`), served as
|
|
117
|
+
one of the project's services:
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
import operonx
|
|
121
|
+
from operonx.app import Service, asgi
|
|
122
|
+
from operonx_kb.admin import kb_admin_app
|
|
123
|
+
|
|
124
|
+
operonx.bootstrap() # operonx serve loads no resources for an asgi service
|
|
125
|
+
Service("kb_admin", asgi("/kb", port=8021), app=kb_admin_app(llm="assistant"))
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Outstanding work (K5 visual retrieval needs a GPU): [BACKLOG.md](BACKLOG.md).
|
|
129
|
+
Design and phase gates: [PLAN.md](PLAN.md); measured gates: [docs/bench](docs/bench).
|
|
130
|
+
Contributor and agent rules: [AGENTS.md](AGENTS.md).
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# operonx-kb
|
|
2
|
+
|
|
3
|
+
Knowledge base and document intelligence on [operonx](https://github.com/batman1m2001-cyber/Operonx): files become versioned documents
|
|
4
|
+
whose every character has an address (version, span → page, bbox), indexed for retrieval, and
|
|
5
|
+
answers cite spans that were checked against the text they quote.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
uv sync --extra pdf --extra faiss # core + PDF text layer + FAISS index
|
|
9
|
+
PYTHONPATH=../operonx-wt/feat-kb-upstream uv run pytest -q # until operonx PR #74 merges
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
import operonx
|
|
14
|
+
from operonx_kb import CollectionSpec, DenseIndexSpec, KnowledgeBase
|
|
15
|
+
from operonx_kb.model.collection import LexicalIndexSpec
|
|
16
|
+
|
|
17
|
+
operonx.bootstrap(resources="resources.yaml") # kb_catalog:, kb_blob:, kb_lexical:, embedding:, vector_store:, llm:
|
|
18
|
+
kb = KnowledgeBase()
|
|
19
|
+
kb.create_collection("handbook", CollectionSpec(
|
|
20
|
+
dense=DenseIndexSpec(embedder="e5", store="vector_store:kb",
|
|
21
|
+
passage_template="passage: {text}", query_template="query: {text}"),
|
|
22
|
+
lexical=LexicalIndexSpec(), # SQLite FTS5 or Postgres FTS
|
|
23
|
+
filterable={"dept": "keyword"},
|
|
24
|
+
))
|
|
25
|
+
await kb.add("handbook", "policy.pdf", key="policy.pdf", tags=["hr"], acl=["team:hr"],
|
|
26
|
+
metadata={"dept": "hr"})
|
|
27
|
+
found = await kb.search("handbook", "how many days of leave", mode="hybrid",
|
|
28
|
+
filter={"acl_any": ["team:hr"]}, reranker="ce")
|
|
29
|
+
answer = await kb.ask("handbook", "how many days of leave", "assistant")
|
|
30
|
+
answer["citations"] # each: quote, canonical span, pages, bboxes; unverified ones are in answer["dropped"]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
operonx-kb query handbook "how many days of leave" --mode hybrid --tag hr
|
|
35
|
+
operonx-kb query wiki "who directed the film that won in 1999" --mode graph # created with --graph
|
|
36
|
+
operonx-kb query handbook "how many days of leave" --answer assistant
|
|
37
|
+
operonx-kb eval handbook datasets/handbook.jsonl --mode hybrid
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Use it inside your flows
|
|
41
|
+
|
|
42
|
+
A search is an operonx graph, so it is one step of your own flow — traced with it, no service in
|
|
43
|
+
between (`tests/graphs/test_in_a_flow.py`):
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from operonx.kb.graphs import search # module level: the collection's settings are read per run
|
|
47
|
+
|
|
48
|
+
@graph
|
|
49
|
+
def answer_flow(question, catalog):
|
|
50
|
+
found = search(query=question, collection="handbook", filter=None, k=5, mode="hybrid",
|
|
51
|
+
catalog=catalog)
|
|
52
|
+
reply = cite(hits=found["hits"]) # your own op
|
|
53
|
+
START >> found >> reply >> END
|
|
54
|
+
|
|
55
|
+
engine = Operon(answer_flow, params={"question": None, "catalog": None})
|
|
56
|
+
out = await engine.run(inputs={"question": "...", "catalog": "kb_catalog:main"})
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
For an agent (operonx-agents installed beside it), `kb_tools` gives a read-only `kb_search` /
|
|
60
|
+
`kb_read` toolset. The scope comes from your code or the run's context — the model only sends a
|
|
61
|
+
query — and `kb_read` checks it again (`tests/graphs/test_agent_tools.py`):
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from operonx.kb.tools import kb_tools
|
|
65
|
+
|
|
66
|
+
tools = kb_tools(kb, "handbook", scope=lambda ctx: {"acl_any": ctx.deps.principals})
|
|
67
|
+
agent = Agent(name="hr", model=Model("assistant"), tools=[tools])
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Studio's Knowledge tab reads a knowledge base through its admin API (extra `admin`), served as
|
|
71
|
+
one of the project's services:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
import operonx
|
|
75
|
+
from operonx.app import Service, asgi
|
|
76
|
+
from operonx_kb.admin import kb_admin_app
|
|
77
|
+
|
|
78
|
+
operonx.bootstrap() # operonx serve loads no resources for an asgi service
|
|
79
|
+
Service("kb_admin", asgi("/kb", port=8021), app=kb_admin_app(llm="assistant"))
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Outstanding work (K5 visual retrieval needs a GPU): [BACKLOG.md](BACKLOG.md).
|
|
83
|
+
Design and phase gates: [PLAN.md](PLAN.md); measured gates: [docs/bench](docs/bench).
|
|
84
|
+
Contributor and agent rules: [AGENTS.md](AGENTS.md).
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""operonx-kb: versioned documents with span-level provenance, on OperonX.
|
|
2
|
+
|
|
3
|
+
Read ``PLAN.md`` first. The model lives in :mod:`operonx_kb.model`, the pure
|
|
4
|
+
text and span functions in :mod:`operonx_kb.text`, the structurer in
|
|
5
|
+
:mod:`operonx_kb.structure`, parsers in :mod:`operonx_kb.parsing` and
|
|
6
|
+
:mod:`operonx_kb.pdf`, the ops and graphs in :mod:`operonx_kb.ops` and
|
|
7
|
+
:mod:`operonx_kb.graphs`, and the library API in :class:`KnowledgeBase`.
|
|
8
|
+
|
|
9
|
+
Its resource categories (``kb_catalog``, ``kb_blob``) reach operonx through
|
|
10
|
+
``operonx.resources`` entry points, and importing the package registers them too.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from operonx_kb import registry as _registry # noqa: F401 — registers kb_* categories
|
|
14
|
+
from operonx_kb.errors import (
|
|
15
|
+
CatalogError,
|
|
16
|
+
DocumentParseError,
|
|
17
|
+
KBError,
|
|
18
|
+
MissingExtraError,
|
|
19
|
+
SpanInvariantError,
|
|
20
|
+
UnsupportedFormatError,
|
|
21
|
+
)
|
|
22
|
+
from operonx_kb.kb import DEFAULT_MODE, IngestError, KnowledgeBase, QueryError
|
|
23
|
+
from operonx_kb.model.collection import (
|
|
24
|
+
ChunkerSpec,
|
|
25
|
+
Collection,
|
|
26
|
+
CollectionSpec,
|
|
27
|
+
ContextualSpec,
|
|
28
|
+
DenseIndexSpec,
|
|
29
|
+
GraphSpec,
|
|
30
|
+
LayoutSpec,
|
|
31
|
+
TreeSpec,
|
|
32
|
+
)
|
|
33
|
+
from operonx_kb.model.document import (
|
|
34
|
+
Chunk,
|
|
35
|
+
Document,
|
|
36
|
+
DocumentVersion,
|
|
37
|
+
Element,
|
|
38
|
+
Page,
|
|
39
|
+
Region,
|
|
40
|
+
VersionChunk,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
__version__ = "0.2.1"
|
|
44
|
+
|
|
45
|
+
__all__ = [
|
|
46
|
+
"Chunk",
|
|
47
|
+
"ChunkerSpec",
|
|
48
|
+
"Collection",
|
|
49
|
+
"CollectionSpec",
|
|
50
|
+
"ContextualSpec",
|
|
51
|
+
"DenseIndexSpec",
|
|
52
|
+
"Document",
|
|
53
|
+
"DocumentVersion",
|
|
54
|
+
"Element",
|
|
55
|
+
"LayoutSpec",
|
|
56
|
+
"Page",
|
|
57
|
+
"Region",
|
|
58
|
+
"TreeSpec",
|
|
59
|
+
"GraphSpec",
|
|
60
|
+
"VersionChunk",
|
|
61
|
+
"DEFAULT_MODE",
|
|
62
|
+
"IngestError",
|
|
63
|
+
"QueryError",
|
|
64
|
+
"KnowledgeBase",
|
|
65
|
+
"KBError",
|
|
66
|
+
"SpanInvariantError",
|
|
67
|
+
"UnsupportedFormatError",
|
|
68
|
+
"DocumentParseError",
|
|
69
|
+
"CatalogError",
|
|
70
|
+
"MissingExtraError",
|
|
71
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""The admin API Studio's Knowledge tab talks to (track5 §16.2): ``operonx-kb/1``.
|
|
2
|
+
|
|
3
|
+
Studio never imports this package; it finds a KB by asking a served ``asgi``
|
|
4
|
+
service for ``GET <path>/.well-known/operonx-kb`` and speaks the HTTP contract
|
|
5
|
+
below. The contract is versioned (:data:`API`) so the two repos release
|
|
6
|
+
independently.
|
|
7
|
+
|
|
8
|
+
import operonx
|
|
9
|
+
from operonx.app import Service, asgi
|
|
10
|
+
from operonx_kb.admin import kb_admin_app
|
|
11
|
+
|
|
12
|
+
operonx.bootstrap() # the project's resources.yaml: operonx serve loads none for an asgi service
|
|
13
|
+
Service("kb_admin", asgi("/kb", port=8021), app=kb_admin_app(llm="gpt-4o-mini"))
|
|
14
|
+
|
|
15
|
+
:mod:`operonx_kb.admin.views` holds what each route answers (pure reads of the
|
|
16
|
+
catalog and blob store, and the query runs); :mod:`operonx_kb.admin.asgi` only
|
|
17
|
+
routes. The ASGI app needs the ``admin`` extra (Starlette, and pypdfium2 for
|
|
18
|
+
page images).
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from operonx_kb.admin.asgi import kb_admin_app
|
|
22
|
+
from operonx_kb.admin.views import API
|
|
23
|
+
|
|
24
|
+
__all__ = ["API", "kb_admin_app"]
|