knaif 1.0.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.
- knaif-1.0.0/LICENSE +201 -0
- knaif-1.0.0/NOTICE +62 -0
- knaif-1.0.0/PKG-INFO +315 -0
- knaif-1.0.0/README.md +267 -0
- knaif-1.0.0/knaif/__init__.py +165 -0
- knaif-1.0.0/knaif/_console.py +37 -0
- knaif-1.0.0/knaif/_gpu_check.py +23 -0
- knaif-1.0.0/knaif/agent.py +1409 -0
- knaif-1.0.0/knaif/app.py +631 -0
- knaif-1.0.0/knaif/cli/__init__.py +8 -0
- knaif-1.0.0/knaif/cli/build.py +140 -0
- knaif-1.0.0/knaif/cli/click_adapter.py +173 -0
- knaif-1.0.0/knaif/cli/decorators.py +53 -0
- knaif-1.0.0/knaif/cli/function_step.py +70 -0
- knaif-1.0.0/knaif/cli/inference.py +221 -0
- knaif-1.0.0/knaif/cli/runner.py +119 -0
- knaif-1.0.0/knaif/core_tools.py +84 -0
- knaif-1.0.0/knaif/core_tools.yaml +32 -0
- knaif-1.0.0/knaif/evalsuite/__init__.py +28 -0
- knaif-1.0.0/knaif/evalsuite/__main__.py +3 -0
- knaif-1.0.0/knaif/evalsuite/chain.py +77 -0
- knaif-1.0.0/knaif/evalsuite/cli.py +1523 -0
- knaif-1.0.0/knaif/evalsuite/corpus.py +156 -0
- knaif-1.0.0/knaif/evalsuite/descriptor_analysis.py +337 -0
- knaif-1.0.0/knaif/evalsuite/protocols.py +51 -0
- knaif-1.0.0/knaif/evalsuite/report.py +934 -0
- knaif-1.0.0/knaif/evalsuite/retrieval.py +130 -0
- knaif-1.0.0/knaif/evalsuite/review_log.py +58 -0
- knaif-1.0.0/knaif/evalsuite/runner.py +259 -0
- knaif-1.0.0/knaif/evalsuite/scoring.py +337 -0
- knaif-1.0.0/knaif/evalsuite/snapshot.py +84 -0
- knaif-1.0.0/knaif/evaluator.py +131 -0
- knaif-1.0.0/knaif/examples/__init__.py +0 -0
- knaif-1.0.0/knaif/examples/clock/__init__.py +0 -0
- knaif-1.0.0/knaif/examples/clock/__main__.py +24 -0
- knaif-1.0.0/knaif/examples/clock/app_click.py +86 -0
- knaif-1.0.0/knaif/examples/clock/app_decorator.py +92 -0
- knaif-1.0.0/knaif/examples/clock/store.py +164 -0
- knaif-1.0.0/knaif/executor.py +146 -0
- knaif-1.0.0/knaif/handler_api.py +39 -0
- knaif-1.0.0/knaif/injectors.py +66 -0
- knaif-1.0.0/knaif/input_refs.py +190 -0
- knaif-1.0.0/knaif/models.py +148 -0
- knaif-1.0.0/knaif/nl_clarify_gate.py +278 -0
- knaif-1.0.0/knaif/orchestrator.py +475 -0
- knaif-1.0.0/knaif/planner.py +632 -0
- knaif-1.0.0/knaif/prompt.py +250 -0
- knaif-1.0.0/knaif/registry.py +209 -0
- knaif-1.0.0/knaif/skill.py +420 -0
- knaif-1.0.0/knaif/skill_base.py +26 -0
- knaif-1.0.0/knaif/steps/__init__.py +7 -0
- knaif-1.0.0/knaif/steps/_resolve_inputs.py +73 -0
- knaif-1.0.0/knaif/tool.py +36 -0
- knaif-1.0.0/knaif.egg-info/PKG-INFO +315 -0
- knaif-1.0.0/knaif.egg-info/SOURCES.txt +129 -0
- knaif-1.0.0/knaif.egg-info/dependency_links.txt +1 -0
- knaif-1.0.0/knaif.egg-info/entry_points.txt +2 -0
- knaif-1.0.0/knaif.egg-info/requires.txt +27 -0
- knaif-1.0.0/knaif.egg-info/top_level.txt +1 -0
- knaif-1.0.0/pyproject.toml +112 -0
- knaif-1.0.0/setup.cfg +4 -0
- knaif-1.0.0/tests/test_agent.py +1425 -0
- knaif-1.0.0/tests/test_api.py +121 -0
- knaif-1.0.0/tests/test_app.py +101 -0
- knaif-1.0.0/tests/test_baseline_reviewer_chain.py +140 -0
- knaif-1.0.0/tests/test_chain_intermediate_linking.py +150 -0
- knaif-1.0.0/tests/test_cli_click_adapter.py +183 -0
- knaif-1.0.0/tests/test_cli_decorators.py +237 -0
- knaif-1.0.0/tests/test_cli_runner.py +140 -0
- knaif-1.0.0/tests/test_core_tools.py +125 -0
- knaif-1.0.0/tests/test_corpus_review_marker.py +82 -0
- knaif-1.0.0/tests/test_descriptor_analysis.py +251 -0
- knaif-1.0.0/tests/test_evalsuite_all_skills.py +318 -0
- knaif-1.0.0/tests/test_evalsuite_arm_loader.py +293 -0
- knaif-1.0.0/tests/test_evalsuite_corpus.py +378 -0
- knaif-1.0.0/tests/test_evalsuite_fixture_paths.py +16 -0
- knaif-1.0.0/tests/test_evalsuite_fixtures_regen.py +117 -0
- knaif-1.0.0/tests/test_evalsuite_report_cmd.py +312 -0
- knaif-1.0.0/tests/test_evalsuite_report_hardening.py +110 -0
- knaif-1.0.0/tests/test_evalsuite_report_html_multi_arm.py +215 -0
- knaif-1.0.0/tests/test_evalsuite_report_md_sections.py +184 -0
- knaif-1.0.0/tests/test_evalsuite_report_multi_arm.py +248 -0
- knaif-1.0.0/tests/test_evalsuite_retry.py +98 -0
- knaif-1.0.0/tests/test_evalsuite_review_log.py +150 -0
- knaif-1.0.0/tests/test_evalsuite_run_output_diff.py +179 -0
- knaif-1.0.0/tests/test_evalsuite_runner.py +339 -0
- knaif-1.0.0/tests/test_evalsuite_runner_execute.py +279 -0
- knaif-1.0.0/tests/test_evalsuite_score_external.py +493 -0
- knaif-1.0.0/tests/test_evalsuite_scoring.py +459 -0
- knaif-1.0.0/tests/test_evalsuite_seed_baselines.py +182 -0
- knaif-1.0.0/tests/test_evalsuite_stem_sandbox.py +102 -0
- knaif-1.0.0/tests/test_evaluator.py +255 -0
- knaif-1.0.0/tests/test_example_clock.py +248 -0
- knaif-1.0.0/tests/test_executor.py +218 -0
- knaif-1.0.0/tests/test_function_step.py +165 -0
- knaif-1.0.0/tests/test_golden_prompt.py +84 -0
- knaif-1.0.0/tests/test_injectors.py +142 -0
- knaif-1.0.0/tests/test_input_refs.py +185 -0
- knaif-1.0.0/tests/test_justfile.py +43 -0
- knaif-1.0.0/tests/test_license_files.py +56 -0
- knaif-1.0.0/tests/test_model_manifest_release_ready.py +67 -0
- knaif-1.0.0/tests/test_models.py +202 -0
- knaif-1.0.0/tests/test_nl_clarify_gate.py +343 -0
- knaif-1.0.0/tests/test_notebook_package.py +81 -0
- knaif-1.0.0/tests/test_notebook_runner.py +67 -0
- knaif-1.0.0/tests/test_oop_dispatch.py +195 -0
- knaif-1.0.0/tests/test_orchestrator.py +493 -0
- knaif-1.0.0/tests/test_path_arg_keys.py +58 -0
- knaif-1.0.0/tests/test_plan_headers.py +75 -0
- knaif-1.0.0/tests/test_planner.py +1182 -0
- knaif-1.0.0/tests/test_planner_parity.py +45 -0
- knaif-1.0.0/tests/test_prompt.py +260 -0
- knaif-1.0.0/tests/test_prompt_audit.py +210 -0
- knaif-1.0.0/tests/test_protocols.py +71 -0
- knaif-1.0.0/tests/test_registry.py +396 -0
- knaif-1.0.0/tests/test_resolve_inputs.py +151 -0
- knaif-1.0.0/tests/test_retrieval_harness.py +74 -0
- knaif-1.0.0/tests/test_runtime_data.py +50 -0
- knaif-1.0.0/tests/test_sdk_inference.py +150 -0
- knaif-1.0.0/tests/test_skill.py +70 -0
- knaif-1.0.0/tests/test_skill_base.py +73 -0
- knaif-1.0.0/tests/test_skill_loader_oop.py +322 -0
- knaif-1.0.0/tests/test_skill_metadata.py +55 -0
- knaif-1.0.0/tests/test_skill_overrides.py +89 -0
- knaif-1.0.0/tests/test_skill_package_loader.py +220 -0
- knaif-1.0.0/tests/test_steps_package.py +35 -0
- knaif-1.0.0/tests/test_tool.py +119 -0
- knaif-1.0.0/tests/test_train_data_integrity.py +114 -0
- knaif-1.0.0/tests/test_version_consistency.py +63 -0
- knaif-1.0.0/tests/test_wiring_equivalence.py +146 -0
- knaif-1.0.0/tests/test_workflow_expansion.py +171 -0
knaif-1.0.0/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 2026 knaif contributors
|
|
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.
|
knaif-1.0.0/NOTICE
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
knaif
|
|
2
|
+
Copyright 2026 Blackdeep Technologies
|
|
3
|
+
|
|
4
|
+
This product includes software developed by Blackdeep Technologies.
|
|
5
|
+
|
|
6
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
7
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
8
|
+
License in the accompanying LICENSE file or at:
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
================================================================================
|
|
13
|
+
MODELS
|
|
14
|
+
================================================================================
|
|
15
|
+
|
|
16
|
+
The fine-tuned models distributed alongside knaif are derivative works of the
|
|
17
|
+
Qwen3 model family by Alibaba Cloud, used under the Apache License 2.0:
|
|
18
|
+
|
|
19
|
+
knaif-qwen3-4b-v1 derived from Qwen/Qwen3-4B
|
|
20
|
+
knaif-qwen3-1.7b-v1 derived from Qwen/Qwen3-1.7B
|
|
21
|
+
|
|
22
|
+
Qwen3 — Copyright Alibaba Cloud, licensed under Apache-2.0
|
|
23
|
+
https://huggingface.co/Qwen
|
|
24
|
+
|
|
25
|
+
Models are NOT bundled in knaif artifacts; they are downloaded on first run from
|
|
26
|
+
the URLs recorded in contracts/models/model-manifest.yaml, which also records each
|
|
27
|
+
model's `base_model` and `base_model_license`.
|
|
28
|
+
|
|
29
|
+
================================================================================
|
|
30
|
+
BUNDLED THIRD-PARTY SOFTWARE
|
|
31
|
+
================================================================================
|
|
32
|
+
|
|
33
|
+
The native runtime links or bundles the following. Full license texts ship in
|
|
34
|
+
the installers/licenses/ directory of every artifact.
|
|
35
|
+
|
|
36
|
+
llama.cpp — Copyright (c) 2023-2024 The ggml authors, MIT License
|
|
37
|
+
installers/licenses/llama.cpp-LICENSE.txt
|
|
38
|
+
|
|
39
|
+
NVIDIA CUDA runtime (CUDA-enabled builds only) — NVIDIA Software License
|
|
40
|
+
Agreement. CUDA support is an opt-in build; base artifacts do not include it.
|
|
41
|
+
installers/licenses/NVIDIA-CUDA-EULA.txt
|
|
42
|
+
|
|
43
|
+
Rust crate dependencies — permissive licenses only (Apache-2.0, MIT, BSD-2/3,
|
|
44
|
+
ISC, Unicode-3.0, NCSA, CDLA-Permissive-2.0). Generated by `just licenses`.
|
|
45
|
+
installers/licenses/THIRD-PARTY-RUST.txt
|
|
46
|
+
|
|
47
|
+
Python runtime dependencies — permissive licenses only (Apache-2.0, MIT,
|
|
48
|
+
BSD, MPL-2.0). Generated by `just licenses-python`.
|
|
49
|
+
installers/licenses/THIRD-PARTY-PYTHON.txt
|
|
50
|
+
|
|
51
|
+
knaif does not bundle FFmpeg. Skills that shell out to FFmpeg or other external
|
|
52
|
+
binaries require the user to install them separately; those tools remain under
|
|
53
|
+
their own licenses. See skills/<name>/SPEC.md for per-skill requirements.
|
|
54
|
+
|
|
55
|
+
================================================================================
|
|
56
|
+
DATA
|
|
57
|
+
================================================================================
|
|
58
|
+
|
|
59
|
+
Evaluation, training, and safety corpora under skills/<name>/data/ were authored
|
|
60
|
+
for this project and are covered by the project license. They reference synthetic
|
|
61
|
+
filenames only and contain no third-party or personal content. See
|
|
62
|
+
docs/PROVENANCE.md for the full non-code provenance record.
|
knaif-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: knaif
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Local LLM command agent with deterministic execution layer
|
|
5
|
+
Author-email: Blackdeep Technologies <knaif@blackdeep.tech>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/blackdeep-tech/knaif
|
|
8
|
+
Project-URL: Repository, https://github.com/blackdeep-tech/knaif
|
|
9
|
+
Project-URL: Documentation, https://github.com/blackdeep-tech/knaif/blob/HEAD/docs/SDK.md
|
|
10
|
+
Project-URL: Changelog, https://github.com/blackdeep-tech/knaif/blob/HEAD/CHANGELOG.md
|
|
11
|
+
Project-URL: Issues, https://github.com/blackdeep-tech/knaif/issues
|
|
12
|
+
Keywords: llm,cli,natural-language,agent,local-llm,ffmpeg
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
20
|
+
Classifier: Topic :: Utilities
|
|
21
|
+
Requires-Python: <3.15,>=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
License-File: NOTICE
|
|
25
|
+
Requires-Dist: requests>=2.33.0
|
|
26
|
+
Requires-Dist: pyyaml>=6.0
|
|
27
|
+
Requires-Dist: click>=8.0
|
|
28
|
+
Provides-Extra: llama
|
|
29
|
+
Requires-Dist: llama-cpp-python>=0.2.0; extra == "llama"
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
33
|
+
Requires-Dist: black>=23.7.0; extra == "dev"
|
|
34
|
+
Requires-Dist: black[jupyter]>=26.5.1; extra == "dev"
|
|
35
|
+
Requires-Dist: ruff>=0.0.280; extra == "dev"
|
|
36
|
+
Requires-Dist: mypy>=1.5.0; extra == "dev"
|
|
37
|
+
Requires-Dist: types-requests>=2.31.0; extra == "dev"
|
|
38
|
+
Provides-Extra: notebook
|
|
39
|
+
Requires-Dist: jupyterlab>=4.0.0; extra == "notebook"
|
|
40
|
+
Requires-Dist: ipykernel>=6.25.0; extra == "notebook"
|
|
41
|
+
Requires-Dist: notebook>=7.0.0; extra == "notebook"
|
|
42
|
+
Requires-Dist: ipywidgets>=8.0.0; extra == "notebook"
|
|
43
|
+
Provides-Extra: evalsuite
|
|
44
|
+
Requires-Dist: rich>=13.0.0; extra == "evalsuite"
|
|
45
|
+
Provides-Extra: clock
|
|
46
|
+
Requires-Dist: tzdata>=2024.1; extra == "clock"
|
|
47
|
+
Dynamic: license-file
|
|
48
|
+
|
|
49
|
+
<p align="center">
|
|
50
|
+
<img src="https://raw.githubusercontent.com/blackdeep-tech/knaif/HEAD/media/knaif-logo-rect.svg" alt="knaif" width="260">
|
|
51
|
+
</p>
|
|
52
|
+
|
|
53
|
+
# knaif
|
|
54
|
+
|
|
55
|
+
**Turn natural language into validated, executable actions — without letting a language
|
|
56
|
+
model near your filesystem.**
|
|
57
|
+
|
|
58
|
+
knaif runs a **local** model. No API key, no token meter, nothing leaves the machine.
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
import knaif.cli as nk
|
|
62
|
+
|
|
63
|
+
@nk.command(help="Add a task", keywords=["add", "create"])
|
|
64
|
+
def add(title: nk.Arg(help="task title")):
|
|
65
|
+
...
|
|
66
|
+
|
|
67
|
+
nk.App([add]).run() # your CLI now accepts plain English
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Why knaif
|
|
71
|
+
|
|
72
|
+
Most ways of putting an LLM in front of a tool give the model the ability to *act* — it
|
|
73
|
+
emits a shell command, or calls tools in a loop, and you hope the guardrails hold.
|
|
74
|
+
|
|
75
|
+
knaif inverts that. The model is allowed to produce exactly one thing — a **plan**:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{ "plan": [ { "tool": "convert", "args": { "input": "clip.mp4", "format": "webm" } } ] }
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Everything that decides whether that plan runs is **ordinary deterministic code**: schema
|
|
82
|
+
validation, arguments checked against a tool registry, sandbox path checks, a safety
|
|
83
|
+
category per tool, and a confirmation gate. A hallucinated tool name is rejected before
|
|
84
|
+
execution. An argument your tool doesn't accept is rejected. A path outside the sandbox is
|
|
85
|
+
rejected — and re-checked after variable substitution, because substitution can introduce a
|
|
86
|
+
new path.
|
|
87
|
+
|
|
88
|
+
**What that buys you as a developer:**
|
|
89
|
+
|
|
90
|
+
- **Safety is a property of your registry, not the model's mood.** You classify a tool
|
|
91
|
+
`destructive` once; the gate is code. Swap the model and the guarantee holds.
|
|
92
|
+
- **One inference call, not an agent loop.** The model proposes the whole plan; everything
|
|
93
|
+
after is normal Python. No per-step round trip, no token meter, no nondeterminism in the
|
|
94
|
+
middle of a workflow.
|
|
95
|
+
- **It runs on your user's hardware.** A small local model plus deterministic code means the
|
|
96
|
+
marginal cost of the millionth run equals the first — electricity on a laptop.
|
|
97
|
+
- **A typed, testable surface.** Tools are declared in YAML and implemented as classes, so
|
|
98
|
+
the whole thing is unit-testable without calling a model at all — mock inference is built
|
|
99
|
+
in.
|
|
100
|
+
|
|
101
|
+
Scope is narrow on purpose: knaif is not a general problem solver. It targets tools that are
|
|
102
|
+
genuinely hard to drive by hand. **Free-form shell command generation is explicitly out of
|
|
103
|
+
scope** — knaif will not emit a command its own validator can't account for.
|
|
104
|
+
|
|
105
|
+
## Install
|
|
106
|
+
|
|
107
|
+
```console
|
|
108
|
+
pip install knaif
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
That's everything you need for mock inference and for Ollama. For in-process llama.cpp
|
|
112
|
+
there is an extra:
|
|
113
|
+
|
|
114
|
+
```console
|
|
115
|
+
pip install "knaif[llama]"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
> **Heads-up:** `llama-cpp-python` publishes only an sdist to PyPI, so this compiles from
|
|
119
|
+
> source and needs CMake and a C++ toolchain. If you'd rather not build it, use the
|
|
120
|
+
> project's [prebuilt wheels][llama-wheels] —
|
|
121
|
+
> `pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu`
|
|
122
|
+
> — or just use Ollama, which needs no build step at all.
|
|
123
|
+
|
|
124
|
+
## Try it without writing anything
|
|
125
|
+
|
|
126
|
+
A complete example CLI ships inside the package, so you can see the whole pipeline work
|
|
127
|
+
before writing a line:
|
|
128
|
+
|
|
129
|
+
```console
|
|
130
|
+
pip install "knaif[clock]"
|
|
131
|
+
python -m knaif.examples.clock "list timezones in europe"
|
|
132
|
+
python -m knaif.examples.clock "what time is it in Tokyo"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
With no model installed it uses mock inference and still runs end to end — parse, validate,
|
|
136
|
+
dispatch, result. Add Ollama or a GGUF (below) and the same command starts answering
|
|
137
|
+
free-form phrasing. The source is ~340 lines across three files
|
|
138
|
+
(`knaif/examples/clock/`): pure logic in `store.py`, then the same CLI built two ways —
|
|
139
|
+
`@nk.command` decorators and `from_click()`.
|
|
140
|
+
|
|
141
|
+
## Getting a model
|
|
142
|
+
|
|
143
|
+
**No model is bundled** — not in this wheel, not anywhere. knaif is the engine; you choose
|
|
144
|
+
what runs behind it. Three options, easiest first:
|
|
145
|
+
|
|
146
|
+
**1. Ollama** — it manages the download for you, and needs no build step:
|
|
147
|
+
|
|
148
|
+
```console
|
|
149
|
+
ollama pull qwen3:4b
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
import knaif.cli as nk
|
|
154
|
+
|
|
155
|
+
app = nk.App([convert], orchestrator=nk.local_ollama("qwen3:4b"))
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
`local_ollama()` returns `None` and warns if Ollama isn't reachable, so your app degrades to
|
|
159
|
+
mock inference instead of crashing. Its defaults are also tuned for reasoning models like
|
|
160
|
+
Qwen3 — use the helper rather than building an orchestrator by hand, or you'll hit a
|
|
161
|
+
JSON-constraint deadlock. Details: [Reasoning models on Ollama][ollama-thinking].
|
|
162
|
+
|
|
163
|
+
**2. A GGUF through llama.cpp** — one call, no llama.cpp knowledge required:
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
app = nk.App([convert], orchestrator=nk.local_llama_cpp("model.gguf"))
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
`local_llama_cpp()` picks working defaults (8k context, full GPU offload, JSON handling for
|
|
170
|
+
thinking-style models) so you don't have to learn llama.cpp's knobs. Override any of them —
|
|
171
|
+
`n_ctx`, `n_gpu_layers`, `n_threads` — only if you want to. Like `local_ollama()`, it warns
|
|
172
|
+
and returns `None` when the model or `llama-cpp-python` is missing, so your app falls back to
|
|
173
|
+
mock rather than crashing.
|
|
174
|
+
|
|
175
|
+
Any instruct-tuned GGUF that emits clean JSON works. Ready-made ones are at
|
|
176
|
+
**[huggingface.co/blackdeep/knaif][hf]** — `knaif-qwen3-4b-v1` (~2.5 GB) is the
|
|
177
|
+
general-purpose choice, `knaif-qwen3-1.7b-v1` is smaller and faster:
|
|
178
|
+
|
|
179
|
+
```console
|
|
180
|
+
curl -L -o model.gguf https://huggingface.co/blackdeep/knaif/resolve/main/knaif-qwen3-4b-v1-q4_k_m.gguf
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
A relative path resolves from your project root (the nearest directory containing `.git`,
|
|
184
|
+
else the current directory); an absolute path always works. The warning names the path it
|
|
185
|
+
actually tried, so a miss is easy to diagnose.
|
|
186
|
+
|
|
187
|
+
**3. Mock inference** — the default when no orchestrator is supplied. It plans from registry
|
|
188
|
+
keywords rather than a model, which makes the whole pipeline testable in CI with no model,
|
|
189
|
+
no GPU, and no network.
|
|
190
|
+
|
|
191
|
+
> The `knaif models pull` command and the `models.yaml` resolver belong to the **native CLI
|
|
192
|
+
> and repo checkout**, not this package. From a pip install you supply the model explicitly,
|
|
193
|
+
> as above.
|
|
194
|
+
|
|
195
|
+
## Two ways to use it
|
|
196
|
+
|
|
197
|
+
### 1. Add a natural-language front end to your own CLI
|
|
198
|
+
|
|
199
|
+
The **self-contained** case: everything you need is in this package.
|
|
200
|
+
|
|
201
|
+
```python
|
|
202
|
+
import knaif.cli as nk
|
|
203
|
+
|
|
204
|
+
@nk.command(help="Convert a file", keywords=["convert", "transcode"])
|
|
205
|
+
def convert(src: nk.Arg(help="input file"), fmt: nk.Arg(help="target format")):
|
|
206
|
+
...
|
|
207
|
+
|
|
208
|
+
app = nk.App([convert])
|
|
209
|
+
app.run() # sys.argv[1] as an utterance
|
|
210
|
+
app.invoke("turn report.docx into a pdf", dry_run=True)
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Already using `click`? Wrap the existing group without touching your commands:
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
from myapp.cli import cli
|
|
217
|
+
app = nk.from_click(cli)
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
You get typed validation, safety categories, dry-run, and variable binding for free — the
|
|
221
|
+
same pipeline the full engine uses.
|
|
222
|
+
|
|
223
|
+
### 2. Build a skill
|
|
224
|
+
|
|
225
|
+
When your domain outgrows a handful of commands, package it as a **skill** — a
|
|
226
|
+
self-contained bundle of a YAML tool registry plus Python handlers. Skills give you intent
|
|
227
|
+
expansion (one user request becoming a multi-step workflow), per-tool safety categories, and
|
|
228
|
+
a reusable unit you can ship or hand to someone else.
|
|
229
|
+
|
|
230
|
+
A minimal skill is a directory with `skill.yaml`, `tools.yaml`, and a handlers module:
|
|
231
|
+
|
|
232
|
+
```python
|
|
233
|
+
# my_skill/python/handlers.py
|
|
234
|
+
from knaif.handler_api import HandlerContext
|
|
235
|
+
from knaif.skill_base import Skill
|
|
236
|
+
from knaif.tool import Step
|
|
237
|
+
|
|
238
|
+
class GreetStep(Step):
|
|
239
|
+
name = "greet"
|
|
240
|
+
def handle(self, args: dict, ctx: HandlerContext) -> dict:
|
|
241
|
+
return {"message": f"hello {args['name']}"}
|
|
242
|
+
|
|
243
|
+
class MySkill(Skill):
|
|
244
|
+
tools = [GreetStep]
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Then load and run it:
|
|
248
|
+
|
|
249
|
+
```python
|
|
250
|
+
from knaif import CommandAgent
|
|
251
|
+
|
|
252
|
+
agent = CommandAgent.from_skill("my_skill", sandbox="./sandbox")
|
|
253
|
+
results = agent.execute_plan(
|
|
254
|
+
{"plan": [{"tool": "greet", "args": {"name": "world"}}]},
|
|
255
|
+
dry_run=True,
|
|
256
|
+
)
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Every tool is a `Step` (executes, returns a result) or an `Intent` (expands into a sub-plan
|
|
260
|
+
of Steps). `HandlerContext` carries the sandbox root, `dry_run`, `confirmed`, and a
|
|
261
|
+
confirmation callback. The full contract — registry schema, safety categories, intent
|
|
262
|
+
expansion, preflight, result formatting — is in [TOOL_SCHEMA.md][tool-schema].
|
|
263
|
+
|
|
264
|
+
Keeping several skills side by side? Point `create_agent()` at the directory holding them:
|
|
265
|
+
|
|
266
|
+
```python
|
|
267
|
+
from knaif import create_agent, list_skills
|
|
268
|
+
|
|
269
|
+
print(list_skills(skills_root="./skills"))
|
|
270
|
+
agent = create_agent("my_skill", sandbox="./sandbox", skills_root="./skills")
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
> **No skills ship in this wheel** — the published package is the engine plus the
|
|
274
|
+
> `knaif.cli` SDK, so nothing pulls in dependencies for domains you don't use. If you want
|
|
275
|
+
> worked examples rather than a blank page, the repository carries two production skills
|
|
276
|
+
> (media processing and document handling) you can read or copy from.
|
|
277
|
+
|
|
278
|
+
## Requirements
|
|
279
|
+
|
|
280
|
+
- Python 3.10–3.14
|
|
281
|
+
- A local model for real inference (llama.cpp via the `llama` extra, or Ollama). Mock
|
|
282
|
+
inference needs nothing.
|
|
283
|
+
- Skills that shell out to external tools need those tools installed — external binaries are
|
|
284
|
+
never bundled.
|
|
285
|
+
|
|
286
|
+
## Documentation
|
|
287
|
+
|
|
288
|
+
| | |
|
|
289
|
+
|---|---|
|
|
290
|
+
| [Skill authoring][tool-schema] | registry schema, `Step` / `Intent`, safety categories |
|
|
291
|
+
| [Developer SDK][sdk] | `@nk.command`, `nk.App`, `from_click` |
|
|
292
|
+
| [Architecture][architecture] | the plan pipeline end to end |
|
|
293
|
+
| [Inference backends][inference] | model resolution, llama.cpp and Ollama setup |
|
|
294
|
+
| [Released models][models] | which models, why those, how they were tuned |
|
|
295
|
+
| [Scope and safety][requirements] | what knaif deliberately will not do |
|
|
296
|
+
|
|
297
|
+
Source, issues, and releases: **[github.com/blackdeep-tech/knaif][repo]**
|
|
298
|
+
|
|
299
|
+
## License
|
|
300
|
+
|
|
301
|
+
Apache-2.0 — see [LICENSE][license] and [NOTICE][notice].
|
|
302
|
+
|
|
303
|
+
[repo]: https://github.com/blackdeep-tech/knaif
|
|
304
|
+
[tool-schema]: https://github.com/blackdeep-tech/knaif/blob/HEAD/docs/TOOL_SCHEMA.md
|
|
305
|
+
[sdk]: https://github.com/blackdeep-tech/knaif/blob/HEAD/docs/SDK.md
|
|
306
|
+
[architecture]: https://github.com/blackdeep-tech/knaif/blob/HEAD/docs/ARCHITECTURE.md
|
|
307
|
+
[inference]: https://github.com/blackdeep-tech/knaif/blob/HEAD/docs/INFERENCE.md
|
|
308
|
+
[requirements]: https://github.com/blackdeep-tech/knaif/blob/HEAD/docs/REQUIREMENTS.md
|
|
309
|
+
[license]: https://github.com/blackdeep-tech/knaif/blob/HEAD/LICENSE
|
|
310
|
+
[notice]: https://github.com/blackdeep-tech/knaif/blob/HEAD/NOTICE
|
|
311
|
+
[models]: https://github.com/blackdeep-tech/knaif/blob/HEAD/docs/MODELS.md
|
|
312
|
+
[hf]: https://huggingface.co/blackdeep/knaif
|
|
313
|
+
[ollama]: https://ollama.com
|
|
314
|
+
[ollama-thinking]: https://github.com/blackdeep-tech/knaif/blob/HEAD/docs/INFERENCE.md#reasoning-models-on-ollama--leave-thinking-on
|
|
315
|
+
[llama-wheels]: https://abetlen.github.io/llama-cpp-python/whl/cpu/
|