llmsetup 0.1.0__tar.gz → 0.4.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.
- {llmsetup-0.1.0/src/llmsetup.egg-info → llmsetup-0.4.0}/PKG-INFO +36 -7
- {llmsetup-0.1.0 → llmsetup-0.4.0}/README.md +33 -5
- {llmsetup-0.1.0 → llmsetup-0.4.0}/pyproject.toml +3 -2
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/catalog/autoupdate.py +2 -1
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/catalog/catalog.py +31 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/catalog/discover.py +2 -2
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/cli.py +133 -5
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/download.py +20 -12
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/interop/ollama.py +3 -2
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/interop/openai_clients.py +21 -10
- llmsetup-0.4.0/src/llmsetup/launch.py +137 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/runtimes/install.py +2 -1
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/runtimes/ollama.py +4 -3
- llmsetup-0.4.0/src/llmsetup/server.py +363 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/ui/server.py +37 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/util/http.py +47 -0
- llmsetup-0.4.0/src/llmsetup/util/modelfile.py +42 -0
- llmsetup-0.4.0/src/llmsetup/version.py +3 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0/src/llmsetup.egg-info}/PKG-INFO +36 -7
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup.egg-info/SOURCES.txt +8 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup.egg-info/requires.txt +1 -1
- llmsetup-0.4.0/tests/test_background_server.py +146 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_catalog_validation.py +15 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_interop.py +22 -0
- llmsetup-0.4.0/tests/test_module_entrypoint.py +35 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_ollama.py +19 -0
- llmsetup-0.4.0/tests/test_release_script.py +141 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_security.py +94 -0
- llmsetup-0.4.0/tests/test_server_logs.py +120 -0
- llmsetup-0.4.0/tests/test_start.py +108 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_ui.py +42 -0
- llmsetup-0.1.0/tests/test_module_entrypoint.py +0 -18
- {llmsetup-0.1.0 → llmsetup-0.4.0}/LICENSE +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/NOTICE +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/setup.cfg +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/__main__.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/bench/__init__.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/bench/sweep.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/catalog/__init__.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/catalog/data/models.yaml +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/catalog/refresh.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/gguf.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/hardware/__init__.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/hardware/bandwidth.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/hardware/cpu.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/hardware/detect.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/hardware/gpu.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/interop/__init__.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/interop/export.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/interop/jan.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/interop/llama_swap.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/interop/lmstudio.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/interview/__init__.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/interview/questions.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/interview/wizard.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/pipeline.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/planner/__init__.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/planner/memory.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/planner/model_fit.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/planner/moe.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/planner/plan.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/planner/requested.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/planner/score.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/repair/__init__.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/repair/loop.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/repair/strategies.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/report/__init__.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/report/render.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/runtimes/__init__.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/runtimes/base.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/runtimes/capabilities.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/runtimes/data/llamacpp_flags.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/runtimes/dependencies.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/runtimes/gguf_store.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/runtimes/llamacpp.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/runtimes/lmstudio.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/runtimes/mlx.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/runtimes/registry.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/runtimes/tabby.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/runtimes/vllm.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/tuning/__init__.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/tuning/advanced.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/tuning/platform_tuning.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/tuning/profiles.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/tuning/publisher.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/tuning/sampling.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/tuning/tuner.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/types.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/ui/__init__.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/ui/static/index.html +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/util/__init__.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/util/errors.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/util/fs.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/util/log.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/util/proc.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/util/units.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/verify/__init__.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/verify/checks.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/verify/client.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/verify/harness.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup/verify/signatures.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup.egg-info/dependency_links.txt +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup.egg-info/entry_points.txt +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/src/llmsetup.egg-info/top_level.txt +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_advanced_tuning.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_attention_and_drafting.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_auto_detection.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_auto_recovery.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_autoupdate.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_capabilities.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_catalog.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_catalog_boundaries.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_catalog_refresh.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_cli.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_cli_inputs.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_context_profile.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_dense_offload.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_dependency_compatibility.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_download_integrity.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_embedding_setup.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_flag_coverage.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_forum_practice.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_gguf.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_gpu_detection.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_hybrid_attention.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_interview.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_kv_quality.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_launch_failures.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_launch_matrix.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_memory.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_model_revisions.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_multigpu_and_apple.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_offline_integration.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_ollama_live.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_plan_reporting.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_planner.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_prefill.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_repair.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_repair_provisioning.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_reproducibility.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_requested_model_planner.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_research_config.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_runtime_dependencies.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_runtime_install.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_setups.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_specific_model_interview.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_specific_model_recovery.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_specific_model_tuning.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_startup_recovery.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_sweep.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_tool_parsers.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_tuner.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_verification_integrity.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_verify.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_vision.py +0 -0
- {llmsetup-0.1.0 → llmsetup-0.4.0}/tests/test_vllm_kv.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: llmsetup
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Interview-driven setup assistant for local open-weight LLMs: picks the model, tunes the runtime, proves it works, and registers it with every local LLM app you use.
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Project-URL: Homepage, https://github.com/catfish-1234/llmsetup
|
|
@@ -18,6 +18,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.13
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
21
22
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
22
23
|
Requires-Python: >=3.9
|
|
23
24
|
Description-Content-Type: text/markdown
|
|
@@ -27,7 +28,7 @@ Requires-Dist: PyYAML>=6.0
|
|
|
27
28
|
Provides-Extra: dev
|
|
28
29
|
Requires-Dist: pytest>=7; extra == "dev"
|
|
29
30
|
Requires-Dist: pytest-cov>=4; extra == "dev"
|
|
30
|
-
Requires-Dist: ruff==0.17.
|
|
31
|
+
Requires-Dist: ruff==0.17.5; extra == "dev"
|
|
31
32
|
Dynamic: license-file
|
|
32
33
|
|
|
33
34
|
# llmsetup
|
|
@@ -50,9 +51,14 @@ See [the name change and migration notes](docs/POSITIONING.md).
|
|
|
50
51
|
## Install
|
|
51
52
|
|
|
52
53
|
Use Python 3.9 or newer, preferably a version that still receives security
|
|
53
|
-
updates. PyYAML is the only runtime Python dependency.
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
updates. PyYAML is the only runtime Python dependency.
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
python -m pip install llmsetup
|
|
58
|
+
llmsetup --version
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
To install from source instead:
|
|
56
62
|
|
|
57
63
|
```bash
|
|
58
64
|
git clone https://github.com/catfish-1234/llmsetup.git
|
|
@@ -95,6 +101,16 @@ llmsetup setup --task coding --context 8192 --yes
|
|
|
95
101
|
|
|
96
102
|
# Read the saved settings, checks, repair history, and launch command.
|
|
97
103
|
llmsetup report
|
|
104
|
+
|
|
105
|
+
# Start the last verified setup again, exactly as it was tested.
|
|
106
|
+
llmsetup start
|
|
107
|
+
|
|
108
|
+
# Or keep it running in the background, then check on it, read its log, and stop it.
|
|
109
|
+
llmsetup start --detach
|
|
110
|
+
llmsetup status
|
|
111
|
+
llmsetup logs --follow
|
|
112
|
+
llmsetup restart
|
|
113
|
+
llmsetup stop
|
|
98
114
|
```
|
|
99
115
|
|
|
100
116
|
`--task` is repeatable, for example `--task coding --task agent`. `--context`
|
|
@@ -140,8 +156,21 @@ provisioning attempts, installation, and runtime fallback. Download transport
|
|
|
140
156
|
retries still apply. A preferred `--runtime` may change during recovery.
|
|
141
157
|
|
|
142
158
|
After verification, llmsetup stops servers it started. Shared Ollama and
|
|
143
|
-
LM Studio daemons keep running.
|
|
144
|
-
|
|
159
|
+
LM Studio daemons keep running. `llmsetup start` runs the verified model again
|
|
160
|
+
in the foreground with the exact command setup tested, nothing re-planned;
|
|
161
|
+
`llmsetup start --print` prints that command instead. `llmsetup start --detach`
|
|
162
|
+
runs it in the background with output in `server.log` under the data directory,
|
|
163
|
+
waits until the endpoint answers, and records the process so `llmsetup status`
|
|
164
|
+
can report whether it is alive and answering and `llmsetup stop` can end it.
|
|
165
|
+
`llmsetup logs` prints the end of that log (`-n` lines, default 50), and
|
|
166
|
+
`--follow` keeps printing until the server stops; escape sequences in the log
|
|
167
|
+
are shown inert. `llmsetup restart` stops the background server and starts the
|
|
168
|
+
verified setup again, detached; `status` shows how long it has been up.
|
|
169
|
+
`stop` only signals a process that is still the recorded server, so a reused
|
|
170
|
+
process ID is never touched. For Ollama and LM Studio
|
|
171
|
+
it shows the endpoint, since their daemons serve the model on demand. Only a
|
|
172
|
+
setup whose checks passed can be started this way; after changing anything,
|
|
173
|
+
run `llmsetup doctor`. Generated client snippets need a running endpoint.
|
|
145
174
|
|
|
146
175
|
## Other commands
|
|
147
176
|
|
|
@@ -18,9 +18,14 @@ See [the name change and migration notes](docs/POSITIONING.md).
|
|
|
18
18
|
## Install
|
|
19
19
|
|
|
20
20
|
Use Python 3.9 or newer, preferably a version that still receives security
|
|
21
|
-
updates. PyYAML is the only runtime Python dependency.
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
updates. PyYAML is the only runtime Python dependency.
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
python -m pip install llmsetup
|
|
25
|
+
llmsetup --version
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
To install from source instead:
|
|
24
29
|
|
|
25
30
|
```bash
|
|
26
31
|
git clone https://github.com/catfish-1234/llmsetup.git
|
|
@@ -63,6 +68,16 @@ llmsetup setup --task coding --context 8192 --yes
|
|
|
63
68
|
|
|
64
69
|
# Read the saved settings, checks, repair history, and launch command.
|
|
65
70
|
llmsetup report
|
|
71
|
+
|
|
72
|
+
# Start the last verified setup again, exactly as it was tested.
|
|
73
|
+
llmsetup start
|
|
74
|
+
|
|
75
|
+
# Or keep it running in the background, then check on it, read its log, and stop it.
|
|
76
|
+
llmsetup start --detach
|
|
77
|
+
llmsetup status
|
|
78
|
+
llmsetup logs --follow
|
|
79
|
+
llmsetup restart
|
|
80
|
+
llmsetup stop
|
|
66
81
|
```
|
|
67
82
|
|
|
68
83
|
`--task` is repeatable, for example `--task coding --task agent`. `--context`
|
|
@@ -108,8 +123,21 @@ provisioning attempts, installation, and runtime fallback. Download transport
|
|
|
108
123
|
retries still apply. A preferred `--runtime` may change during recovery.
|
|
109
124
|
|
|
110
125
|
After verification, llmsetup stops servers it started. Shared Ollama and
|
|
111
|
-
LM Studio daemons keep running.
|
|
112
|
-
|
|
126
|
+
LM Studio daemons keep running. `llmsetup start` runs the verified model again
|
|
127
|
+
in the foreground with the exact command setup tested, nothing re-planned;
|
|
128
|
+
`llmsetup start --print` prints that command instead. `llmsetup start --detach`
|
|
129
|
+
runs it in the background with output in `server.log` under the data directory,
|
|
130
|
+
waits until the endpoint answers, and records the process so `llmsetup status`
|
|
131
|
+
can report whether it is alive and answering and `llmsetup stop` can end it.
|
|
132
|
+
`llmsetup logs` prints the end of that log (`-n` lines, default 50), and
|
|
133
|
+
`--follow` keeps printing until the server stops; escape sequences in the log
|
|
134
|
+
are shown inert. `llmsetup restart` stops the background server and starts the
|
|
135
|
+
verified setup again, detached; `status` shows how long it has been up.
|
|
136
|
+
`stop` only signals a process that is still the recorded server, so a reused
|
|
137
|
+
process ID is never touched. For Ollama and LM Studio
|
|
138
|
+
it shows the endpoint, since their daemons serve the model on demand. Only a
|
|
139
|
+
setup whose checks passed can be started this way; after changing anything,
|
|
140
|
+
run `llmsetup doctor`. Generated client snippets need a running endpoint.
|
|
113
141
|
|
|
114
142
|
## Other commands
|
|
115
143
|
|
|
@@ -11,7 +11,7 @@ build-backend = "setuptools.build_meta"
|
|
|
11
11
|
|
|
12
12
|
[project]
|
|
13
13
|
name = "llmsetup"
|
|
14
|
-
version = "0.
|
|
14
|
+
version = "0.4.0"
|
|
15
15
|
description = "Interview-driven setup assistant for local open-weight LLMs: picks the model, tunes the runtime, proves it works, and registers it with every local LLM app you use."
|
|
16
16
|
readme = "README.md"
|
|
17
17
|
requires-python = ">=3.9"
|
|
@@ -29,6 +29,7 @@ classifiers = [
|
|
|
29
29
|
"Programming Language :: Python :: 3.12",
|
|
30
30
|
"Programming Language :: Python :: 3.13",
|
|
31
31
|
"Programming Language :: Python :: 3.14",
|
|
32
|
+
"Programming Language :: Python :: 3.15",
|
|
32
33
|
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
33
34
|
]
|
|
34
35
|
# Deliberately near-zero dependency: this tool runs on whatever machine the user
|
|
@@ -36,7 +37,7 @@ classifiers = [
|
|
|
36
37
|
dependencies = ["PyYAML>=6.0"]
|
|
37
38
|
|
|
38
39
|
[project.optional-dependencies]
|
|
39
|
-
dev = ["pytest>=7", "pytest-cov>=4", "ruff==0.17.
|
|
40
|
+
dev = ["pytest>=7", "pytest-cov>=4", "ruff==0.17.5"]
|
|
40
41
|
|
|
41
42
|
[project.scripts]
|
|
42
43
|
llmsetup = "llmsetup.cli:main"
|
|
@@ -33,6 +33,7 @@ import yaml
|
|
|
33
33
|
|
|
34
34
|
from llmsetup.util.fs import app_dir, ensure_dir, write_text
|
|
35
35
|
from llmsetup.util.log import Console
|
|
36
|
+
from llmsetup.version import __version__
|
|
36
37
|
|
|
37
38
|
#: Where updated catalogs come from. Points at this project's own catalog on
|
|
38
39
|
#: main, which a scheduled workflow keeps current, so the repo is the
|
|
@@ -154,7 +155,7 @@ def fetch_catalog(url: str, timeout: float = TIMEOUT_SECONDS) -> Optional[str]:
|
|
|
154
155
|
"""Download a catalog document. None on any failure."""
|
|
155
156
|
try:
|
|
156
157
|
request = urllib.request.Request(
|
|
157
|
-
url, headers={"User-Agent": "llmsetup/
|
|
158
|
+
url, headers={"User-Agent": f"llmsetup/{__version__} auto-update"}
|
|
158
159
|
)
|
|
159
160
|
with urllib.request.urlopen(request, timeout=timeout) as response:
|
|
160
161
|
# Only HTTP responses carry a status; a file:// or other local
|
|
@@ -10,6 +10,7 @@ from __future__ import annotations
|
|
|
10
10
|
|
|
11
11
|
import math
|
|
12
12
|
import os
|
|
13
|
+
import re
|
|
13
14
|
from dataclasses import replace
|
|
14
15
|
from pathlib import Path
|
|
15
16
|
from typing import Any, Dict, Iterable, List, Optional
|
|
@@ -358,9 +359,39 @@ def _coerce_types(fields: Dict[str, Any], model_id: str, path: Path) -> Dict[str
|
|
|
358
359
|
(name != "notes" and not out[name].strip())):
|
|
359
360
|
raise CatalogError(f"{model_id}.{name} must be a string in {path}")
|
|
360
361
|
|
|
362
|
+
# These values end up inside generated files (an Ollama Modelfile, client
|
|
363
|
+
# YAML, llama-swap commands). A line break in one would let an entry add
|
|
364
|
+
# its own directives there, such as a SYSTEM prompt or an ADAPTER.
|
|
365
|
+
for name in ("id", "name", "publisher", "license", "ollama_name", "chat_template",
|
|
366
|
+
"tokenizer_family"):
|
|
367
|
+
value = out.get(name)
|
|
368
|
+
if isinstance(value, str) and _CONTROL.search(value):
|
|
369
|
+
raise CatalogError(f"{model_id}.{name} must be a single line in {path}")
|
|
370
|
+
|
|
371
|
+
if out.get("ollama_name") is not None:
|
|
372
|
+
value = out["ollama_name"]
|
|
373
|
+
if not isinstance(value, str) or not _OLLAMA_NAME.fullmatch(value):
|
|
374
|
+
raise CatalogError(
|
|
375
|
+
f"{model_id}.ollama_name must be an Ollama model name such as "
|
|
376
|
+
f"`qwen3:8b`, got {value!r} in {path}")
|
|
377
|
+
|
|
378
|
+
for quant in out.get("recommended_quants", ()):
|
|
379
|
+
if not _QUANT_NAME.fullmatch(quant):
|
|
380
|
+
raise CatalogError(
|
|
381
|
+
f"{model_id}.recommended_quants has an invalid quantization {quant!r} in {path}")
|
|
382
|
+
|
|
361
383
|
return out
|
|
362
384
|
|
|
363
385
|
|
|
386
|
+
#: C0/C1 control characters, line and paragraph separators.
|
|
387
|
+
_CONTROL = re.compile(r"[\x00-\x1f\x7f-\x9f\u2028\u2029]")
|
|
388
|
+
#: An Ollama model reference: optional registry host and namespace, a name, an
|
|
389
|
+
#: optional tag. ``hf.co/owner/repo:Q4_K_M`` and ``qwen3:8b`` both qualify.
|
|
390
|
+
_OLLAMA_NAME = re.compile(r"[A-Za-z0-9][A-Za-z0-9._-]*(?:/[A-Za-z0-9][A-Za-z0-9._-]*){0,3}"
|
|
391
|
+
r"(?::[A-Za-z0-9][A-Za-z0-9._-]{0,127})?")
|
|
392
|
+
_QUANT_NAME = re.compile(r"[A-Za-z0-9][A-Za-z0-9_.-]{0,63}")
|
|
393
|
+
|
|
394
|
+
|
|
364
395
|
def _validate_spec(spec: ModelSpec, path: Path) -> None:
|
|
365
396
|
from llmsetup.download import validate_repo, validate_revision
|
|
366
397
|
from llmsetup.util.errors import ProvisionError
|
|
@@ -28,7 +28,7 @@ from typing import Any, Dict, List, Optional, Sequence
|
|
|
28
28
|
|
|
29
29
|
from llmsetup.download import (
|
|
30
30
|
HF_ENDPOINT,
|
|
31
|
-
|
|
31
|
+
hub_request,
|
|
32
32
|
pin_revision,
|
|
33
33
|
saved_revision,
|
|
34
34
|
validate_repo,
|
|
@@ -139,7 +139,7 @@ class Candidate:
|
|
|
139
139
|
def _get_json(url: str, timeout: float = 20.0) -> Optional[Any]:
|
|
140
140
|
"""GET and parse JSON. Returns None on any failure, because discovery is best-effort."""
|
|
141
141
|
try:
|
|
142
|
-
request =
|
|
142
|
+
request = hub_request(url)
|
|
143
143
|
with urllib.request.urlopen(request, timeout=timeout) as response:
|
|
144
144
|
return json.loads(response.read().decode("utf-8"))
|
|
145
145
|
except (urllib.error.URLError, urllib.error.HTTPError, OSError, ValueError):
|
|
@@ -8,6 +8,11 @@ inspected on its own:
|
|
|
8
8
|
llmsetup plan what would you pick, and why?
|
|
9
9
|
llmsetup verify does my current endpoint actually work?
|
|
10
10
|
llmsetup doctor re-test and repair an existing setup
|
|
11
|
+
llmsetup start start the last verified setup again (--detach for background)
|
|
12
|
+
llmsetup status is the background server running?
|
|
13
|
+
llmsetup stop stop the background server
|
|
14
|
+
llmsetup restart stop it and start the verified setup again
|
|
15
|
+
llmsetup logs show the background server's log (-f to follow)
|
|
11
16
|
llmsetup export register an existing model with my other apps
|
|
12
17
|
llmsetup catalog inspect or extend the model list
|
|
13
18
|
"""
|
|
@@ -42,8 +47,7 @@ from llmsetup.util.fs import app_dir, ensure_dir, write_text
|
|
|
42
47
|
from llmsetup.util.log import Console, write_console
|
|
43
48
|
from llmsetup.util.proc import format_command
|
|
44
49
|
from llmsetup.util.units import gb
|
|
45
|
-
|
|
46
|
-
VERSION = "0.1.0"
|
|
50
|
+
from llmsetup.version import __version__ as VERSION
|
|
47
51
|
|
|
48
52
|
|
|
49
53
|
def _positive_int(value: str) -> int:
|
|
@@ -56,6 +60,9 @@ def _positive_int(value: str) -> int:
|
|
|
56
60
|
def main(argv: Optional[List[str]] = None) -> int:
|
|
57
61
|
parser = build_parser()
|
|
58
62
|
args = parser.parse_args(argv)
|
|
63
|
+
from llmsetup.util.http import install_credential_safe_redirects
|
|
64
|
+
|
|
65
|
+
install_credential_safe_redirects()
|
|
59
66
|
console = Console(quiet=getattr(args, "quiet", False),
|
|
60
67
|
verbose=getattr(args, "verbose", False))
|
|
61
68
|
|
|
@@ -63,7 +70,9 @@ def main(argv: Optional[List[str]] = None) -> int:
|
|
|
63
70
|
"setup": cmd_setup, "detect": cmd_detect, "plan": cmd_plan,
|
|
64
71
|
"verify": cmd_verify, "doctor": cmd_doctor, "export": cmd_export,
|
|
65
72
|
"catalog": cmd_catalog, "runtimes": cmd_runtimes, "ui": cmd_ui,
|
|
66
|
-
"report": cmd_report,
|
|
73
|
+
"report": cmd_report, "start": cmd_start, "status": cmd_status, "stop": cmd_stop,
|
|
74
|
+
"restart": cmd_restart,
|
|
75
|
+
"logs": cmd_logs,
|
|
67
76
|
}.get(args.command)
|
|
68
77
|
|
|
69
78
|
if handler is None:
|
|
@@ -73,7 +82,9 @@ def main(argv: Optional[List[str]] = None) -> int:
|
|
|
73
82
|
rerun = "Rerun: " + format_command(["llmsetup", *(argv if argv is not None else sys.argv[1:])])
|
|
74
83
|
try:
|
|
75
84
|
code = handler(args, console)
|
|
76
|
-
|
|
85
|
+
# `status` reports state through its exit code (3: not running), like
|
|
86
|
+
# `systemctl status`; that is an answer, not a failure to rerun.
|
|
87
|
+
if code and args.command != "status":
|
|
77
88
|
console.error(rerun)
|
|
78
89
|
return code
|
|
79
90
|
except LlmsetupError as exc:
|
|
@@ -202,6 +213,37 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
202
213
|
p_doctor.add_argument("--cached-only", action="store_true",
|
|
203
214
|
help="require retained model weights, including every repair fallback")
|
|
204
215
|
|
|
216
|
+
p_start = sub.add_parser(
|
|
217
|
+
"start", help="start the last verified setup again, exactly as it was tested")
|
|
218
|
+
common(p_start)
|
|
219
|
+
p_start.add_argument("--setup", type=Path, help="saved setup JSON to start")
|
|
220
|
+
p_start.add_argument("--print", dest="print_only", action="store_true",
|
|
221
|
+
help="print the launch command instead of running it")
|
|
222
|
+
p_start.add_argument("--detach", action="store_true",
|
|
223
|
+
help="run in the background with output in a log file; stop it with `llmsetup stop`")
|
|
224
|
+
p_start.add_argument("--wait", type=float, default=180.0, metavar="SECONDS",
|
|
225
|
+
help="with --detach, how long to wait for the endpoint to answer (default 180)")
|
|
226
|
+
|
|
227
|
+
p_status = sub.add_parser("status", help="is the background server running and answering?")
|
|
228
|
+
common(p_status)
|
|
229
|
+
|
|
230
|
+
p_stop = sub.add_parser("stop", help="stop the server started by `llmsetup start --detach`")
|
|
231
|
+
common(p_stop)
|
|
232
|
+
|
|
233
|
+
p_restart = sub.add_parser(
|
|
234
|
+
"restart", help="stop the background server and start the verified setup again in the background")
|
|
235
|
+
common(p_restart)
|
|
236
|
+
p_restart.add_argument("--setup", type=Path, help="saved setup JSON to start")
|
|
237
|
+
p_restart.add_argument("--wait", type=float, default=180.0, metavar="SECONDS",
|
|
238
|
+
help="how long to wait for the endpoint to answer (default 180)")
|
|
239
|
+
|
|
240
|
+
p_logs = sub.add_parser("logs", help="show the log of the server started by `llmsetup start --detach`")
|
|
241
|
+
common(p_logs)
|
|
242
|
+
p_logs.add_argument("-n", "--lines", type=_positive_int, default=50,
|
|
243
|
+
help="how many lines from the end to show (default 50)")
|
|
244
|
+
p_logs.add_argument("-f", "--follow", action="store_true",
|
|
245
|
+
help="keep printing new lines until the server stops or you press Ctrl-C")
|
|
246
|
+
|
|
205
247
|
p_report = sub.add_parser(
|
|
206
248
|
"report", help="reprint the last setup's report (paste this into a bug report)")
|
|
207
249
|
common(p_report)
|
|
@@ -813,6 +855,86 @@ def cmd_report(args, console: Console) -> int:
|
|
|
813
855
|
return 0
|
|
814
856
|
|
|
815
857
|
|
|
858
|
+
def cmd_start(args, console: Console) -> int:
|
|
859
|
+
"""Run the last verified setup again, with the exact command it was tested with."""
|
|
860
|
+
from llmsetup.launch import load_launch, start
|
|
861
|
+
from llmsetup.util.fs import read_json
|
|
862
|
+
|
|
863
|
+
path = args.setup or (app_dir() / "last-setup.json")
|
|
864
|
+
if not Path(path).exists():
|
|
865
|
+
raise LlmsetupError(
|
|
866
|
+
f"no saved setup at {path}",
|
|
867
|
+
hint="run `llmsetup setup` first; a verified run records how to start it",
|
|
868
|
+
)
|
|
869
|
+
record = load_launch(read_json(Path(path)), Path(path))
|
|
870
|
+
if args.json:
|
|
871
|
+
print(json.dumps(record, indent=2))
|
|
872
|
+
return 0
|
|
873
|
+
if args.detach and not args.print_only and not record.get("shared_daemon"):
|
|
874
|
+
from llmsetup.launch import preflight
|
|
875
|
+
from llmsetup.server import ensure_not_running, start_detached
|
|
876
|
+
|
|
877
|
+
ensure_not_running()
|
|
878
|
+
preflight(record)
|
|
879
|
+
return start_detached(record, console, wait_s=args.wait)
|
|
880
|
+
return start(record, console, print_only=args.print_only)
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
def cmd_status(args, console: Console) -> int:
|
|
884
|
+
"""Report the background server started by `llmsetup start --detach`."""
|
|
885
|
+
from llmsetup.server import status
|
|
886
|
+
|
|
887
|
+
report = status()
|
|
888
|
+
if args.json:
|
|
889
|
+
print(json.dumps(report, indent=2))
|
|
890
|
+
return 0 if report["running"] else 3
|
|
891
|
+
if not report["managed"]:
|
|
892
|
+
console.info("no background server is recorded; start one with `llmsetup start --detach`")
|
|
893
|
+
return 3
|
|
894
|
+
if not report["running"]:
|
|
895
|
+
console.warn(f"the recorded server (pid {report['pid']}) is not running")
|
|
896
|
+
console.info(f"its log is {report['log']}; start it again with `llmsetup start --detach`")
|
|
897
|
+
return 3
|
|
898
|
+
(console.ok if report["healthy"] else console.warn)(
|
|
899
|
+
f"{report['model']} is running (pid {report['pid']}) and "
|
|
900
|
+
+ ("answering" if report["healthy"] else "not answering yet"))
|
|
901
|
+
console.info(f"OpenAI-compatible endpoint: {report['base_url']}/v1")
|
|
902
|
+
from llmsetup.server import format_duration
|
|
903
|
+
|
|
904
|
+
uptime = f" (up {format_duration(report['uptime_s'])})" if report.get("uptime_s") is not None else ""
|
|
905
|
+
console.info(console.dim(f"started {report['started_at']}{uptime} log {report['log']}"))
|
|
906
|
+
return 0
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
def cmd_stop(args, console: Console) -> int:
|
|
910
|
+
from llmsetup.server import stop
|
|
911
|
+
|
|
912
|
+
return stop(console)
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
def cmd_restart(args, console: Console) -> int:
|
|
916
|
+
"""Stop the background server, if one is running, and start the verified setup detached."""
|
|
917
|
+
from llmsetup.server import read_state, server_running, stop
|
|
918
|
+
|
|
919
|
+
state = read_state()
|
|
920
|
+
if state is not None and server_running(state):
|
|
921
|
+
stop(console)
|
|
922
|
+
else:
|
|
923
|
+
console.info("no background server was running; starting one")
|
|
924
|
+
args.detach, args.print_only, args.json = True, False, False
|
|
925
|
+
return cmd_start(args, console)
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
def cmd_logs(args, console: Console) -> int:
|
|
929
|
+
from llmsetup.server import current_log, logs, tail
|
|
930
|
+
|
|
931
|
+
if args.json:
|
|
932
|
+
path = current_log()
|
|
933
|
+
print(json.dumps({"log": str(path), "lines": tail(path, args.lines)}, indent=2))
|
|
934
|
+
return 0
|
|
935
|
+
return logs(console, lines=args.lines, follow=args.follow)
|
|
936
|
+
|
|
937
|
+
|
|
816
938
|
def _save_last(result) -> None:
|
|
817
939
|
"""Record the run so `llmsetup doctor` can re-test it and `llmsetup report` can
|
|
818
940
|
reprint it.
|
|
@@ -825,7 +947,13 @@ def _save_last(result) -> None:
|
|
|
825
947
|
|
|
826
948
|
try:
|
|
827
949
|
directory = ensure_dir(app_dir())
|
|
828
|
-
|
|
950
|
+
from llmsetup.launch import launch_record
|
|
951
|
+
|
|
952
|
+
record = result.to_dict()
|
|
953
|
+
launch = launch_record(result)
|
|
954
|
+
if launch is not None:
|
|
955
|
+
record["launch"] = launch
|
|
956
|
+
write_json(directory / "last-setup.json", record)
|
|
829
957
|
write_text(directory / "last-report.md", render_markdown(result))
|
|
830
958
|
except OSError:
|
|
831
959
|
pass
|
|
@@ -19,14 +19,15 @@ import urllib.parse
|
|
|
19
19
|
import urllib.request
|
|
20
20
|
from dataclasses import dataclass
|
|
21
21
|
from pathlib import Path
|
|
22
|
-
from typing import Callable, List, Optional
|
|
22
|
+
from typing import Callable, Dict, List, Optional
|
|
23
23
|
|
|
24
24
|
from llmsetup.util.errors import ProvisionError
|
|
25
25
|
from llmsetup.util.fs import app_dir, ensure_dir, write_text
|
|
26
26
|
from llmsetup.util.units import human_bytes
|
|
27
|
+
from llmsetup.version import __version__
|
|
27
28
|
|
|
28
29
|
HF_ENDPOINT = os.environ.get("HF_ENDPOINT", "https://huggingface.co").rstrip("/")
|
|
29
|
-
USER_AGENT = "llmsetup/
|
|
30
|
+
USER_AGENT = f"llmsetup/{__version__} (+https://github.com/catfish-1234/llmsetup)"
|
|
30
31
|
CHUNK = 1024 * 1024
|
|
31
32
|
|
|
32
33
|
|
|
@@ -74,13 +75,22 @@ def validate_repo(repo: str) -> str:
|
|
|
74
75
|
return text
|
|
75
76
|
|
|
76
77
|
|
|
77
|
-
def
|
|
78
|
-
|
|
78
|
+
def hub_request(url: str, headers: Optional[Dict[str, str]] = None) -> urllib.request.Request:
|
|
79
|
+
"""A Hub request whose token cannot follow a redirect to another host.
|
|
80
|
+
|
|
81
|
+
The token is needed for gated repos (Llama, Gemma) the user has already
|
|
82
|
+
accepted. Hub downloads redirect to a CDN, and urllib copies ordinary
|
|
83
|
+
headers onto every redirect, so a plain ``Authorization`` header would be
|
|
84
|
+
replayed to whichever host the redirect names, including one chosen by a
|
|
85
|
+
misbehaving ``HF_ENDPOINT`` mirror. An unredirected header is never copied.
|
|
86
|
+
:class:`llmsetup.util.http.CredentialSafeRedirectHandler`, installed by the
|
|
87
|
+
CLI, restores it for redirects that stay on the same scheme, host and port.
|
|
88
|
+
"""
|
|
89
|
+
request = urllib.request.Request(url, headers={"User-Agent": USER_AGENT, **(headers or {})})
|
|
79
90
|
token = os.environ.get("HF_TOKEN") or os.environ.get("HUGGING_FACE_HUB_TOKEN")
|
|
80
91
|
if token:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return headers
|
|
92
|
+
request.add_unredirected_header("Authorization", f"Bearer {token}")
|
|
93
|
+
return request
|
|
84
94
|
|
|
85
95
|
|
|
86
96
|
def validate_revision(revision: Optional[str]) -> str:
|
|
@@ -118,7 +128,7 @@ def _repo_info(repo: str, revision: Optional[str] = None, timeout: float = 30.0)
|
|
|
118
128
|
url = f"{HF_ENDPOINT}/api/models/{urllib.parse.quote(validate_repo(repo), safe='/')}"
|
|
119
129
|
if revision:
|
|
120
130
|
url += f"/revision/{validate_revision(revision)}"
|
|
121
|
-
req =
|
|
131
|
+
req = hub_request(url)
|
|
122
132
|
try:
|
|
123
133
|
with urllib.request.urlopen(req, timeout=timeout) as resp:
|
|
124
134
|
data = json.loads(resp.read().decode("utf-8"))
|
|
@@ -307,14 +317,12 @@ def download_file(
|
|
|
307
317
|
if remote.size is not None and existing > remote.size:
|
|
308
318
|
part.unlink()
|
|
309
319
|
existing = 0
|
|
310
|
-
headers =
|
|
311
|
-
if existing:
|
|
312
|
-
headers["Range"] = f"bytes={existing}-"
|
|
320
|
+
headers = {"Range": f"bytes={existing}-"} if existing else {}
|
|
313
321
|
|
|
314
322
|
try:
|
|
315
323
|
if time.monotonic() >= deadline:
|
|
316
324
|
raise TimeoutError(f"download timed out after {total_timeout:g}s")
|
|
317
|
-
req =
|
|
325
|
+
req = hub_request(remote.url, headers)
|
|
318
326
|
with urllib.request.urlopen(req, timeout=min(timeout, deadline - time.monotonic())) as resp:
|
|
319
327
|
# A server that ignores Range restarts the file; don't append to it.
|
|
320
328
|
mode = "ab" if (existing and resp.status == 206) else "wb"
|
|
@@ -14,6 +14,7 @@ from typing import Any, Dict, Optional
|
|
|
14
14
|
from llmsetup.types import ModelSpec, RuntimeConfig
|
|
15
15
|
from llmsetup.util import http
|
|
16
16
|
from llmsetup.util.fs import app_dir, ensure_dir, write_text
|
|
17
|
+
from llmsetup.util.modelfile import modelfile_bare, modelfile_string
|
|
17
18
|
from llmsetup.util.proc import run, which
|
|
18
19
|
|
|
19
20
|
|
|
@@ -72,7 +73,7 @@ def register_in_ollama(spec: ModelSpec, config: RuntimeConfig,
|
|
|
72
73
|
def _modelfile(source: str, config: RuntimeConfig) -> str:
|
|
73
74
|
lines = [
|
|
74
75
|
"# Generated by llmsetup, tuned for this machine and use case.",
|
|
75
|
-
f"FROM {source}",
|
|
76
|
+
f"FROM {modelfile_bare(source)}",
|
|
76
77
|
"",
|
|
77
78
|
f"PARAMETER num_ctx {config.context_tokens}",
|
|
78
79
|
f"PARAMETER num_gpu {config.gpu_layers}",
|
|
@@ -86,5 +87,5 @@ def _modelfile(source: str, config: RuntimeConfig) -> str:
|
|
|
86
87
|
if config.threads:
|
|
87
88
|
lines.append(f"PARAMETER num_thread {config.threads}")
|
|
88
89
|
for stop in config.extra.get("stop", []):
|
|
89
|
-
lines.append(f
|
|
90
|
+
lines.append(f"PARAMETER stop {modelfile_string(stop)}")
|
|
90
91
|
return "\n".join(lines) + "\n"
|
|
@@ -79,13 +79,23 @@ def snippets(endpoint: Endpoint, spec: ModelSpec,
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
|
|
82
|
+
def _q(value: str) -> str:
|
|
83
|
+
"""A YAML scalar that cannot change the document's structure.
|
|
84
|
+
|
|
85
|
+
Model names come from the catalog and from Hugging Face, and Ollama tags
|
|
86
|
+
contain colons. A JSON string is a valid YAML double-quoted scalar, so
|
|
87
|
+
``#``, ``: `` and line breaks stay inside the value.
|
|
88
|
+
"""
|
|
89
|
+
return json.dumps(str(value), ensure_ascii=False)
|
|
90
|
+
|
|
91
|
+
|
|
82
92
|
def _continue_yaml(model: str, base: str, spec: ModelSpec,
|
|
83
93
|
config: RuntimeConfig) -> str:
|
|
84
94
|
return f"""models:
|
|
85
|
-
- name: {spec.name} (llmsetup)
|
|
95
|
+
- name: {_q(f"{spec.name} (llmsetup)")}
|
|
86
96
|
provider: openai
|
|
87
|
-
model: {model}
|
|
88
|
-
apiBase: {base}
|
|
97
|
+
model: {_q(model)}
|
|
98
|
+
apiBase: {_q(base)}
|
|
89
99
|
apiKey: {DUMMY_KEY}
|
|
90
100
|
defaultCompletionOptions:
|
|
91
101
|
contextLength: {config.context_tokens}
|
|
@@ -106,10 +116,10 @@ def _continue_autocomplete(model: str, base: str, spec: ModelSpec) -> str:
|
|
|
106
116
|
Where the same model can do both, it still has to be listed twice, because
|
|
107
117
|
the roles carry different settings.
|
|
108
118
|
"""
|
|
109
|
-
return f""" - name: {spec.name} autocomplete (llmsetup)
|
|
119
|
+
return f""" - name: {_q(f"{spec.name} autocomplete (llmsetup)")}
|
|
110
120
|
provider: openai
|
|
111
|
-
model: {model}
|
|
112
|
-
apiBase: {base}
|
|
121
|
+
model: {_q(model)}
|
|
122
|
+
apiBase: {_q(base)}
|
|
113
123
|
apiKey: {DUMMY_KEY}
|
|
114
124
|
defaultCompletionOptions:
|
|
115
125
|
# Completions are read at a glance and replaced by the next keystroke, so
|
|
@@ -122,15 +132,16 @@ def _continue_autocomplete(model: str, base: str, spec: ModelSpec) -> str:
|
|
|
122
132
|
|
|
123
133
|
|
|
124
134
|
def _aider(model: str, base: str) -> str:
|
|
135
|
+
one_line = " ".join(f"openai/{model}".split())
|
|
125
136
|
return f"""# ~/.aider.conf.yml
|
|
126
|
-
openai-api-base: {base}
|
|
137
|
+
openai-api-base: {_q(base)}
|
|
127
138
|
openai-api-key: {DUMMY_KEY}
|
|
128
|
-
model: openai/{model}
|
|
139
|
+
model: {_q(f"openai/{model}")}
|
|
129
140
|
|
|
130
141
|
# Or on the command line:
|
|
131
|
-
# aider --openai-api-base {base} \\
|
|
142
|
+
# aider --openai-api-base {shlex.quote(" ".join(base.split()))} \\
|
|
132
143
|
# --openai-api-key {DUMMY_KEY} \\
|
|
133
|
-
# --model
|
|
144
|
+
# --model {shlex.quote(one_line)}
|
|
134
145
|
"""
|
|
135
146
|
|
|
136
147
|
|