| Crates.io | ollama2llama |
| lib.rs | ollama2llama |
| version | 0.1.1 |
| created_at | 2025-08-17 18:10:59.475362+00 |
| updated_at | 2025-08-18 16:42:43.667289+00 |
| description | A tool for constructing and managing a llama-swap configuration file with Ollama models |
| homepage | |
| repository | https://github.com/Exotik850/ollama2llama |
| max_upload_size | |
| id | 1799619 |
| size | 45,743 |
Import locally installed Ollama models into a YAML configuration consumable by llama-swap (a model hot‑swap / lifecycle manager). It scans your Ollama manifests and (a) generates a fresh config or (b) incrementally augments an existing one without clobbering custom edits unless you explicitly request overrides.
From source (latest main):
cargo install --path . # in a cloned repo
From Git (exact revision):
cargo install --git https://github.com/Exotik850/ollama2llama --rev <commit>
Using cargo-binstall (prebuilt if available):
cargo binstall ollama2llama
Generate a config for all discovered models:
ollama2llama --all-models --output-config llama-swap.yaml
This scans $OLLAMA_MODELS (or ~/.ollama/models) and writes llama-swap.yaml with one entry per model.
Dry run (no file writes):
ollama2llama --all-models --dry-run
Update an existing config in place (retains prior per‑model tweaks unless you pass template overrides):
ollama2llama -i llama-swap.yaml --all-models
Import only selected models:
ollama2llama --specify-models llama3:8b,phi3:3.8b --output-config llama-swap.yaml
Add aliases & filters while importing:
ollama2llama \
--specify-models llama3:8b \
--alias llama3:8b=llama3|meta-llama3 \
--filter llama3:8b=family:llama|quant:Q4_K_M \
--output-config llama-swap.yaml
Default launch template: {model_path} (the resolved blob path).
Override launch & stop commands (placeholders are substituted literally):
--cmd-template "./serve --model {model_path} --name {model_name} --port ${PORT}" \
--stop-cmd-template "pkill -f {model_name}"
Placeholders:
{model_path} – Absolute path to the primary model blob.{model_name} – The Ollama model identifier (e.g. llama3:8b).Only when you pass --cmd-template / --stop-cmd-template are existing cmd / cmd_stop values overwritten; otherwise they are preserved (idempotent incremental updates).
| Flag | Description |
|---|---|
-i, --input-config <FILE> |
Existing YAML to load (else start from defaults). |
-o, --output-config <FILE> |
Destination YAML (else overwrite input, else stdout). |
-m, --model-dir <DIR> |
Override models directory (default: $OLLAMA_MODELS or ~/.ollama/models). |
-s, --specify-models <MODEL> |
One or more model names to import (repeat / comma separated). |
-a, --all-models |
Import every discovered model (ignored if --specify-models used) (default: enabled). |
-v, --verbose |
Progress + warnings (e.g. missing blob path). |
--cmd-template <CMD> |
Launch command template. |
--stop-cmd-template <CMD> |
Stop command template. |
--start-port <PORT> |
Set ${PORT} macro base value. |
--health-check-timeout <SECONDS> |
Override readiness timeout (default 120). |
--log-level <LEVEL> |
`debug |
-M, --macro-override <K=V> |
Add / override macros (repeatable). |
| `--alias <NAME=A1 | A2>` |
| `--filter <NAME=k:v | k=v>` |
--unlisted |
Mark imported models as hidden (unlisted: true). |
--single-group |
Create one swap group containing all imported models. |
--single-group-name <NAME> |
Name of created group (default imported). |
--dry-run |
Print YAML only. |
--no-clobber |
Error if output file already exists. |
-h, --help |
Help. |
-V, --version |
Version. |
health_check_timeout: 120
log_level: info
models:
llama3:8b:
cmd: /home/user/.ollama/models/blobs/sha256-<truncated>
aliases:
- llama3
filters:
family: llama
quant: Q4_K_M
groups:
imported:
swap: true
members:
- llama3:8b
Top‑level keys:
health_check_timeout – u64 seconds (default 120)log_level – debug | info | warn | error (default info)start_port – u16; starting value for a downstream ${PORT} macro (if used by llama-swap)macros – map<string,string> of user macrosmodels – map<string, ModelConfig>groups – map<string, GroupConfig>ModelConfig:
cmd – required launch commandenv – array of KEY=VALUE strings (manually editable)cmd_stop – optional graceful stop commandproxy – optional proxy URLaliases – alternative namescheck_endpoint – readiness probe endpointttl – inactivity timeout secondsuse_model_name – upstream name overridefilters – arbitrary metadata key/value pairsunlisted – hide from listing endpointsGroupConfig:
swap – only one member active at a timeexclusive – starting a member unloads models in other groupspersistent – prevent other groups from unloading these modelsmembers – required list of model namesalso see here for more details about the configuration of llama-swap
Add / override macros:
ollama2llama -M PORT=5800,HOST=0.0.0.0 --all-models -o llama-swap.yaml
They appear under macros:; identical keys in an existing file are replaced.
Aliases use = then | separated names:
--alias llama3:8b=llama3|meta-llama3
Filters accept k:v or k=v inside the right-hand side, separated by |:
--filter llama3:8b=family:llama|quant:Q4_K_M
Create a simple swapping group (mutual exclusion):
ollama2llama --all-models --single-group -o llama-swap.yaml
Produces a group named imported (or your override) with swap: true.
cmd, add env, check_endpoint, or ttl as needed.--specify-models to import new additions; existing customized entries remain unless you supply overriding templates.cmd, cmd_stop) are overwritten when you explicitly pass their flags.--macro-override always overwrites keys of same name.--no-clobber ensures you never accidentally overwrite a pre-existing output file.--verbose) and those models are skipped.The tool focuses on discovery + structured augmentation, leaving nuanced runtime parameters (environment, health endpoints) for manual curation so you keep full control while still automating the repetitive parts.
These are reasonable, non-breaking extensions you may consider (PRs welcome):
--exclude-models or pattern / glob filtering.--match <regex> to import models by regex.--alias-file, --filter-file (YAML/CSV).--env llama3:8b=KEY=VAL|KEY2=VAL2 syntax.--ttl 1800, --check-endpoint /health applied to newly imported models only.--group-by family to auto-create groups from a filter key or from name prefixes.--diff mode to show changes vs existing config without writing.--format json).--quiet.Issues & PRs are welcome. Please keep additions minimally invasive and documented. For feature ideas see the list above; feel free to open a discussion first.
This crate is licensed under the MIT License