infernik 0.1.0a1__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.
- infernik-0.1.0a1/LICENSE +202 -0
- infernik-0.1.0a1/PKG-INFO +81 -0
- infernik-0.1.0a1/README.md +63 -0
- infernik-0.1.0a1/pyproject.toml +29 -0
- infernik-0.1.0a1/setup.cfg +4 -0
- infernik-0.1.0a1/src/infernik/__init__.py +1 -0
- infernik-0.1.0a1/src/infernik/cli.py +129 -0
- infernik-0.1.0a1/src/infernik/http.py +174 -0
- infernik-0.1.0a1/src/infernik/runtime.py +173 -0
- infernik-0.1.0a1/src/infernik/session.py +82 -0
- infernik-0.1.0a1/src/infernik/sources.py +92 -0
- infernik-0.1.0a1/src/infernik/store.py +188 -0
- infernik-0.1.0a1/src/infernik/telemetry.py +16 -0
- infernik-0.1.0a1/src/infernik/web/app.js +173 -0
- infernik-0.1.0a1/src/infernik/web/index.html +40 -0
- infernik-0.1.0a1/src/infernik/web/style.css +47 -0
- infernik-0.1.0a1/src/infernik.egg-info/PKG-INFO +81 -0
- infernik-0.1.0a1/src/infernik.egg-info/SOURCES.txt +24 -0
- infernik-0.1.0a1/src/infernik.egg-info/dependency_links.txt +1 -0
- infernik-0.1.0a1/src/infernik.egg-info/entry_points.txt +2 -0
- infernik-0.1.0a1/src/infernik.egg-info/requires.txt +9 -0
- infernik-0.1.0a1/src/infernik.egg-info/top_level.txt +1 -0
- infernik-0.1.0a1/tests/test_http.py +73 -0
- infernik-0.1.0a1/tests/test_package.py +8 -0
- infernik-0.1.0a1/tests/test_session.py +57 -0
- infernik-0.1.0a1/tests/test_store.py +55 -0
infernik-0.1.0a1/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 2026 Nikolaus Spence
|
|
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.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: infernik
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: A local and shared runner for Transformers checkpoints
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Repository, https://github.com/nikspence/infernik
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Provides-Extra: hub
|
|
11
|
+
Requires-Dist: huggingface-hub<1,>=0.30; extra == "hub"
|
|
12
|
+
Provides-Extra: runtime
|
|
13
|
+
Requires-Dist: transformers<5,>=4.57.6; extra == "runtime"
|
|
14
|
+
Requires-Dist: torch>=2.6; extra == "runtime"
|
|
15
|
+
Requires-Dist: pillow>=10; extra == "runtime"
|
|
16
|
+
Requires-Dist: psutil>=6; extra == "runtime"
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# Infernik
|
|
20
|
+
|
|
21
|
+
<picture>
|
|
22
|
+
<source media="(prefers-color-scheme: dark)" srcset="assets/infernik-dark.svg">
|
|
23
|
+
<source media="(prefers-color-scheme: light)" srcset="assets/infernik-light.svg">
|
|
24
|
+
<img alt="Infernik logo" src="assets/infernik-light.svg" width="460">
|
|
25
|
+
</picture>
|
|
26
|
+
|
|
27
|
+
Infernik is a planned Ollama-style runner for compatible Transformers checkpoints from Hugging Face, ModelScope, or a local directory. Save a known-good model configuration, run it offline once downloaded, and connect an existing app through an OpenAI-compatible API.
|
|
28
|
+
|
|
29
|
+
- **Infernik** is the single-user CLI and local API. It manages downloads, cached models, and running workers without an account system.
|
|
30
|
+
- **Infernik Server** uses the same model definitions and worker code behind a shared gateway with permissions, usage accounting, and administration.
|
|
31
|
+
|
|
32
|
+
## Model storage
|
|
33
|
+
|
|
34
|
+
After installing with `python -m pip install -e ".[hub]"`, use `infernik pull hf:OWNER/REPO --name example` or `infernik import DIRECTORY --name example` to install a compatible safetensors snapshot. Models default to `~/.infernik/models`. Use `INFERNIK_HOME` to relocate the registry and its default model root, or `infernik storage DIRECTORY` to change only the default model root. Use `--storage DIRECTORY` during installation for a per-model override, and `infernik move example DIRECTORY` to relocate an installed model. Use `infernik storage DIRECTORY --preview` before migrating default-managed models with `--move-existing`. Server storage administration is planned.
|
|
35
|
+
|
|
36
|
+
## Status
|
|
37
|
+
|
|
38
|
+
Infernik targets Windows 11, Linux, and macOS. The first alpha has real CPU inference and browser image-chat smoke coverage on Windows 11 x64. Hosted Windows, Linux, and macOS checks validate the package and offline test suite, not accelerator or full deployment support.
|
|
39
|
+
|
|
40
|
+
The first alpha is the single-user CLI and browser interface. Multi-user Infernik Server is not implemented yet.
|
|
41
|
+
|
|
42
|
+
## Local chat
|
|
43
|
+
|
|
44
|
+
Install the alpha on a Python version supported by PyTorch. Python 3.11 was used for the first inference smoke tests.
|
|
45
|
+
|
|
46
|
+
```shell
|
|
47
|
+
python -m pip install "infernik[hub,runtime]==0.1.0a1"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
If your system drive is low on space, put the virtual environment, pip cache and temporary directory, `INFERNIK_HOME`, and `HF_HOME` on a larger drive before installing and downloading models. A hub pull needs temporary room for the download and the managed copy.
|
|
51
|
+
|
|
52
|
+
```shell
|
|
53
|
+
infernik pull hf:HuggingFaceTB/SmolVLM-256M-Instruct --name vision --task vision
|
|
54
|
+
infernik serve vision --device cpu --open
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Open `http://127.0.0.1:8080/` if your browser doesn't open automatically. Send a message or attach PNG, JPEG, or WebP images. The model is loaded from its local snapshot, so chat does not need Internet access after installation. This test build serves one model per process and keeps browser history only until you reload or start a new chat. Press Ctrl+C in the terminal to stop the runner. For a one-shot text prompt, use `infernik run vision "Say hello"`.
|
|
58
|
+
|
|
59
|
+
OpenAI-compatible clients can point to `http://127.0.0.1:8080/v1` and use the model's local alias. Model listing and streaming or non-streaming chat completions are implemented. Use a loopback client only. Tools, embeddings, and the rest of the OpenAI API are outside this test build.
|
|
60
|
+
|
|
61
|
+
For a text-only smoke test with ModelScope:
|
|
62
|
+
|
|
63
|
+
```shell
|
|
64
|
+
infernik pull modelscope:Qwen/Qwen2.5-0.5B-Instruct --name qwen
|
|
65
|
+
infernik run qwen "What is two plus two?" --device cpu
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Performance logs
|
|
69
|
+
|
|
70
|
+
`infernik logs` prints the path to the versioned JSON Lines file. It records model load time, time to first generated token, request duration, prompt and completion tokens, estimated decode rate, and process RAM/CPU samples. Available device metrics include PyTorch CUDA allocation and MPS allocation. Records carry session, request, and model identifiers, but no prompts, images, or generated text. The file remains local and is not rotated automatically in this build.
|
|
71
|
+
|
|
72
|
+
## Development
|
|
73
|
+
|
|
74
|
+
With Python 3.11 or newer, install the scaffold in editable mode and run its tests:
|
|
75
|
+
|
|
76
|
+
```shell
|
|
77
|
+
python -m pip install -e .
|
|
78
|
+
python -m unittest discover -s tests -v
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
See [PLAN.md](PLAN.md) for the shared architecture, parallel milestones, and release gates. See [AGENTS.md](AGENTS.md) for contributor guidance.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Infernik
|
|
2
|
+
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="assets/infernik-dark.svg">
|
|
5
|
+
<source media="(prefers-color-scheme: light)" srcset="assets/infernik-light.svg">
|
|
6
|
+
<img alt="Infernik logo" src="assets/infernik-light.svg" width="460">
|
|
7
|
+
</picture>
|
|
8
|
+
|
|
9
|
+
Infernik is a planned Ollama-style runner for compatible Transformers checkpoints from Hugging Face, ModelScope, or a local directory. Save a known-good model configuration, run it offline once downloaded, and connect an existing app through an OpenAI-compatible API.
|
|
10
|
+
|
|
11
|
+
- **Infernik** is the single-user CLI and local API. It manages downloads, cached models, and running workers without an account system.
|
|
12
|
+
- **Infernik Server** uses the same model definitions and worker code behind a shared gateway with permissions, usage accounting, and administration.
|
|
13
|
+
|
|
14
|
+
## Model storage
|
|
15
|
+
|
|
16
|
+
After installing with `python -m pip install -e ".[hub]"`, use `infernik pull hf:OWNER/REPO --name example` or `infernik import DIRECTORY --name example` to install a compatible safetensors snapshot. Models default to `~/.infernik/models`. Use `INFERNIK_HOME` to relocate the registry and its default model root, or `infernik storage DIRECTORY` to change only the default model root. Use `--storage DIRECTORY` during installation for a per-model override, and `infernik move example DIRECTORY` to relocate an installed model. Use `infernik storage DIRECTORY --preview` before migrating default-managed models with `--move-existing`. Server storage administration is planned.
|
|
17
|
+
|
|
18
|
+
## Status
|
|
19
|
+
|
|
20
|
+
Infernik targets Windows 11, Linux, and macOS. The first alpha has real CPU inference and browser image-chat smoke coverage on Windows 11 x64. Hosted Windows, Linux, and macOS checks validate the package and offline test suite, not accelerator or full deployment support.
|
|
21
|
+
|
|
22
|
+
The first alpha is the single-user CLI and browser interface. Multi-user Infernik Server is not implemented yet.
|
|
23
|
+
|
|
24
|
+
## Local chat
|
|
25
|
+
|
|
26
|
+
Install the alpha on a Python version supported by PyTorch. Python 3.11 was used for the first inference smoke tests.
|
|
27
|
+
|
|
28
|
+
```shell
|
|
29
|
+
python -m pip install "infernik[hub,runtime]==0.1.0a1"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
If your system drive is low on space, put the virtual environment, pip cache and temporary directory, `INFERNIK_HOME`, and `HF_HOME` on a larger drive before installing and downloading models. A hub pull needs temporary room for the download and the managed copy.
|
|
33
|
+
|
|
34
|
+
```shell
|
|
35
|
+
infernik pull hf:HuggingFaceTB/SmolVLM-256M-Instruct --name vision --task vision
|
|
36
|
+
infernik serve vision --device cpu --open
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Open `http://127.0.0.1:8080/` if your browser doesn't open automatically. Send a message or attach PNG, JPEG, or WebP images. The model is loaded from its local snapshot, so chat does not need Internet access after installation. This test build serves one model per process and keeps browser history only until you reload or start a new chat. Press Ctrl+C in the terminal to stop the runner. For a one-shot text prompt, use `infernik run vision "Say hello"`.
|
|
40
|
+
|
|
41
|
+
OpenAI-compatible clients can point to `http://127.0.0.1:8080/v1` and use the model's local alias. Model listing and streaming or non-streaming chat completions are implemented. Use a loopback client only. Tools, embeddings, and the rest of the OpenAI API are outside this test build.
|
|
42
|
+
|
|
43
|
+
For a text-only smoke test with ModelScope:
|
|
44
|
+
|
|
45
|
+
```shell
|
|
46
|
+
infernik pull modelscope:Qwen/Qwen2.5-0.5B-Instruct --name qwen
|
|
47
|
+
infernik run qwen "What is two plus two?" --device cpu
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Performance logs
|
|
51
|
+
|
|
52
|
+
`infernik logs` prints the path to the versioned JSON Lines file. It records model load time, time to first generated token, request duration, prompt and completion tokens, estimated decode rate, and process RAM/CPU samples. Available device metrics include PyTorch CUDA allocation and MPS allocation. Records carry session, request, and model identifiers, but no prompts, images, or generated text. The file remains local and is not rotated automatically in this build.
|
|
53
|
+
|
|
54
|
+
## Development
|
|
55
|
+
|
|
56
|
+
With Python 3.11 or newer, install the scaffold in editable mode and run its tests:
|
|
57
|
+
|
|
58
|
+
```shell
|
|
59
|
+
python -m pip install -e .
|
|
60
|
+
python -m unittest discover -s tests -v
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
See [PLAN.md](PLAN.md) for the shared architecture, parallel milestones, and release gates. See [AGENTS.md](AGENTS.md) for contributor guidance.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "infernik"
|
|
7
|
+
version = "0.1.0a1"
|
|
8
|
+
description = "A local and shared runner for Transformers checkpoints"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
dependencies = []
|
|
14
|
+
|
|
15
|
+
[project.optional-dependencies]
|
|
16
|
+
hub = ["huggingface-hub>=0.30,<1"]
|
|
17
|
+
runtime = ["transformers>=4.57.6,<5", "torch>=2.6", "pillow>=10", "psutil>=6"]
|
|
18
|
+
|
|
19
|
+
[project.scripts]
|
|
20
|
+
infernik = "infernik.cli:main"
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
Repository = "https://github.com/nikspence/infernik"
|
|
24
|
+
|
|
25
|
+
[tool.setuptools.packages.find]
|
|
26
|
+
where = ["src"]
|
|
27
|
+
|
|
28
|
+
[tool.setuptools.package-data]
|
|
29
|
+
infernik = ["web/*.html", "web/*.css", "web/*.js"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Infernik package."""
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""Infernik's lightweight command-line entry point."""
|
|
2
|
+
import argparse
|
|
3
|
+
from dataclasses import asdict
|
|
4
|
+
import json
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
import sqlite3
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
from .store import ModelSpec, Store, StoreError
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def parser():
|
|
13
|
+
cli = argparse.ArgumentParser(prog="infernik", description="Run local Transformers checkpoints.")
|
|
14
|
+
cli.add_argument("--home", help="Set the Infernik registry and logs directory for this invocation.")
|
|
15
|
+
commands = cli.add_subparsers(dest="command", required=True)
|
|
16
|
+
commands.add_parser("list", help="List installed models.").add_argument("--json", action="store_true")
|
|
17
|
+
fetch = commands.add_parser("pull", help="Download and install a pinned hub snapshot.")
|
|
18
|
+
fetch.add_argument("reference", help="hf:owner/repo or modelscope:owner/repo")
|
|
19
|
+
fetch.add_argument("--revision", help="Hub branch, tag or commit")
|
|
20
|
+
local = commands.add_parser("import", help="Install a managed copy of a local checkpoint.")
|
|
21
|
+
local.add_argument("directory", type=Path)
|
|
22
|
+
for command in (fetch, local):
|
|
23
|
+
command.add_argument("--name", required=True, help="Local model alias")
|
|
24
|
+
command.add_argument("--task", choices=("text", "vision"), default="text")
|
|
25
|
+
command.add_argument("--storage", type=Path, help="Override storage root for this model")
|
|
26
|
+
move = commands.add_parser("move", help="Verify and relocate an installed model.")
|
|
27
|
+
move.add_argument("name")
|
|
28
|
+
move.add_argument("directory", type=Path)
|
|
29
|
+
storage = commands.add_parser("storage", help="Show or change the default install directory.")
|
|
30
|
+
storage.add_argument("directory", type=Path, nargs="?")
|
|
31
|
+
migration = storage.add_mutually_exclusive_group()
|
|
32
|
+
migration.add_argument("--move-existing", action="store_true", help="Also relocate existing default-managed models")
|
|
33
|
+
migration.add_argument("--preview", action="store_true", help="Show the moves without changing settings")
|
|
34
|
+
prompt = commands.add_parser("run", help="Run a local model against a prompt.")
|
|
35
|
+
prompt.add_argument("name")
|
|
36
|
+
prompt.add_argument("prompt")
|
|
37
|
+
prompt.add_argument("--device", choices=("auto", "cpu", "cuda", "mps"), default="auto")
|
|
38
|
+
prompt.add_argument("--max-tokens", type=int, default=128)
|
|
39
|
+
serve = commands.add_parser("serve", help="Serve browser chat and a local OpenAI-compatible API.")
|
|
40
|
+
serve.add_argument("name")
|
|
41
|
+
serve.add_argument("--device", choices=("auto", "cpu", "cuda", "mps"), default="auto")
|
|
42
|
+
serve.add_argument("--port", type=int, default=8080)
|
|
43
|
+
serve.add_argument("--open", action="store_true", help="Open browser chat after loading the model.")
|
|
44
|
+
commands.add_parser("logs", help="Print the path to the JSONL inference log.")
|
|
45
|
+
return cli
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def print_move(store, name, directory, *, placement="override"):
|
|
49
|
+
model, leftover = store.move(name, directory, placement=placement)
|
|
50
|
+
print(f"{name}\t{model.path}")
|
|
51
|
+
if leftover is not None:
|
|
52
|
+
print(f"Previous copy needs manual cleanup: {leftover}", file=sys.stderr)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def run(args):
|
|
56
|
+
store = Store(args.home)
|
|
57
|
+
if args.command == "list":
|
|
58
|
+
items = store.list()
|
|
59
|
+
if args.json:
|
|
60
|
+
print(json.dumps([dict(asdict(item.spec), path=str(item.path)) for item in items], indent=2))
|
|
61
|
+
else:
|
|
62
|
+
for item in items:
|
|
63
|
+
print(f"{item.spec.alias}\t{item.spec.task}\t{item.spec.source}\t{item.path}")
|
|
64
|
+
elif args.command == "import":
|
|
65
|
+
directory = args.directory.resolve()
|
|
66
|
+
spec = ModelSpec(args.name, "local", str(directory), "local", args.task)
|
|
67
|
+
print(store.install(spec, directory, args.storage).path)
|
|
68
|
+
elif args.command == "pull":
|
|
69
|
+
from .sources import pull
|
|
70
|
+
print(pull(store, args.name, args.reference, args.task, args.revision, args.storage).path)
|
|
71
|
+
elif args.command == "move":
|
|
72
|
+
print_move(store, args.name, args.directory)
|
|
73
|
+
elif args.command == "run":
|
|
74
|
+
from contextlib import closing
|
|
75
|
+
from .session import open_session
|
|
76
|
+
with open_session(store, args.name, args.device) as session:
|
|
77
|
+
print(f"Loaded {args.name} on {session.worker.device}", file=sys.stderr)
|
|
78
|
+
messages = [{"role": "user", "content": args.prompt}]
|
|
79
|
+
with closing(session.stream(messages, args.max_tokens)) as events:
|
|
80
|
+
for event in events:
|
|
81
|
+
if isinstance(event, str):
|
|
82
|
+
print(event, end="", flush=True)
|
|
83
|
+
print()
|
|
84
|
+
elif args.command == "logs":
|
|
85
|
+
print(store.home / "logs" / "inference.jsonl")
|
|
86
|
+
elif args.command == "serve":
|
|
87
|
+
import webbrowser
|
|
88
|
+
from .http import LocalServer
|
|
89
|
+
from .session import open_session
|
|
90
|
+
with open_session(store, args.name, args.device) as session, LocalServer(args.port, session) as server:
|
|
91
|
+
url = f"http://127.0.0.1:{server.server_port}/"
|
|
92
|
+
print(f"Infernik · {args.name} on {session.worker.device} · {url}", flush=True)
|
|
93
|
+
if args.open:
|
|
94
|
+
webbrowser.open(url)
|
|
95
|
+
server.serve_forever()
|
|
96
|
+
elif args.command == "storage":
|
|
97
|
+
destination = args.directory.expanduser().resolve() if args.directory else store.default_root()
|
|
98
|
+
pending = [item for item in store.list() if item.placement == "default" and item.path.parent != destination]
|
|
99
|
+
if args.preview:
|
|
100
|
+
print(f"Default target: {destination}")
|
|
101
|
+
for item in pending:
|
|
102
|
+
print(f"{item.spec.alias}\t{item.path}\t-> {destination}")
|
|
103
|
+
else:
|
|
104
|
+
print(store.set_default(destination) if args.directory else destination)
|
|
105
|
+
errors = 0
|
|
106
|
+
if args.move_existing:
|
|
107
|
+
for item in pending:
|
|
108
|
+
try:
|
|
109
|
+
print_move(store, item.spec.alias, destination, placement="default")
|
|
110
|
+
except (StoreError, OSError) as exc:
|
|
111
|
+
print(f"{item.spec.alias}: {exc}", file=sys.stderr)
|
|
112
|
+
errors += 1
|
|
113
|
+
return int(bool(errors))
|
|
114
|
+
return 0
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def main(argv=None):
|
|
118
|
+
args = parser().parse_args(argv)
|
|
119
|
+
try:
|
|
120
|
+
return run(args)
|
|
121
|
+
except (RuntimeError, OSError, sqlite3.Error, ValueError) as exc:
|
|
122
|
+
print(f"infernik: {exc}", file=sys.stderr)
|
|
123
|
+
return 1
|
|
124
|
+
except KeyboardInterrupt:
|
|
125
|
+
return 130
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
if __name__ == "__main__":
|
|
129
|
+
sys.exit(main())
|