Release 0.4.0: Kaname, search, filters and tags
Release / release (push) Successful in 11m41s

- Rename the app to Kaname
- Hub metadata per model (base models, architecture, license, Hub tags),
  backfilled by the worker for existing models
- Library search across repo/author/family/quant/tags and multi-select
  facet filters (author, family, quant, tag, status) kept in the URL
- Custom tags (model page editor, on add, click-to-filter)
- README rewritten around a quick install, with banner and screenshots
- deploy/compose.yaml: models in a host folder (KANAME_MODELS_DIR)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-10-05 19:49:17 +02:00
1 parent 2167ea0950
commit 67191b3e16
37 files changed
+2028 -206

No files matched your search

+116 -65
View File
@@ -1,94 +1,145 @@
# Model Manager
<p align="center">
<img src="docs/banner.png" alt="Kaname: self-hosted model manager for Hugging Face" width="100%" />
</p>
Self-hosted web UI for downloading and managing local LLMs from Hugging Face.
Downloads are done by the official `hf` CLI; the Hub API is used for metadata.
**Kaname** (要, "the pivot") is a self-hosted web app for downloading and managing local LLMs from
Hugging Face. Look up a repo, pick the quant you want, and Kaname downloads exactly those files with
the official `hf` CLI, pinned to a specific commit so every download is reproducible.
## Architecture
- **Pick files, not whole repos:** one-click quant selection for GGUF repos, or include/exclude globs.
- **Pinned and reproducible:** every model is pinned to the exact commit SHA you reviewed.
- **Downloads in the background:** live progress, speed and ETA per file; keeps going when you close
the browser; cancel any time.
- **Find things again:** search and filter by author, model family (e.g. Qwen, Gemma), quant, status
and your own tags like `roleplay` or `security`.
- **Homelab-friendly:** two containers, SQLite, OIDC single sign-on (e.g. Pocket ID), models on any
folder or NAS share.
- **web** (`next start`): Next.js App Router UI + API routes, OIDC login via Auth.js.
- **worker** (`src/worker`): owns the job queue, spawns `hf download`, tracks progress from bytes on
disk, applies DB migrations at startup. Only one worker runs at a time (DB lease).
- They talk only through the SQLite database (`DATABASE_URL`); the UI gets live updates via SSE
(`/api/stream`).
## Install
## Run with Docker (recommended)
You need Docker with Compose and an OIDC provider (e.g. [Pocket ID](https://pocket-id.org)).
**1. Get the compose file and the config template**
```bash
cp .env.example .env # fill in HF_TOKEN, AUTH_SECRET, OIDC_*; AUTH_URL = URL you open in the browser
docker compose up --build
mkdir kaname && cd kaname
curl -fsSLo compose.yaml https://git.linxweiler.xyz/pascallinxweiler/Kaname/raw/branch/main/deploy/compose.yaml
curl -fsSLo .env https://git.linxweiler.xyz/pascallinxweiler/Kaname/raw/branch/main/.env.example
```
Open `AUTH_URL` (e.g. http://localhost:3000). `WEB_PORT=3100 docker compose up` changes the host port.
Volumes: `data` (SQLite + hf home, keep on local disk) and `models` (downloaded models).
**2. Create an OIDC client** in your identity provider with the redirect URI
`<AUTH_URL>/api/auth/callback/pocket-id`, e.g. `http://192.168.1.10:3000/api/auth/callback/pocket-id`.
Request the `groups` scope if you want to restrict access by group.
OIDC redirect URI for the client in Pocket ID: `<AUTH_URL>/api/auth/callback/pocket-id`.
**3. Fill in `.env`.** At minimum: `AUTH_URL` (the address you open in the browser), `AUTH_SECRET`
(`openssl rand -base64 33`), `OIDC_ISSUER`, `OIDC_CLIENT_ID`, `OIDC_CLIENT_SECRET`, and ideally a
read-only `HF_TOKEN`.
## Releases and deployment
Pushing a tag `vX.Y.Z` (must equal `version` in `package.json` and have a `## [X.Y.Z]` section in
`CHANGELOG.md`) runs `.gitea/workflows/release.yaml` on Gitea Actions:
1. lint, typecheck, unit tests
2. builds the image and pushes `git.linxweiler.xyz/pascallinxweiler/kaname:X.Y.Z`, `:X.Y` and `:latest`
3. creates a Gitea release with the CHANGELOG section as notes
Requirements: an `act_runner` registered for the repo/user with Docker access, and a repo secret
`REGISTRY_TOKEN` (personal access token with *package: read and write*).
On the server you only need `deploy/compose.yaml` and a filled-in `.env` (from `.env.example`) in
one folder; no source code, no Dockerfile:
**4. Create the folders and start**
```bash
mkdir -p data && sudo chown 1000:1000 data # SQLite DB, shared by web and worker (local disk!)
docker compose pull && docker compose up -d
mkdir -p data models && sudo chown 1000:1000 data models
docker compose up -d
```
Storage layout on the server:
Open your `AUTH_URL`, sign in, click **Add model**. That's it.
- `KANAME_DATA_DIR` (default `./data`): bind mount for the SQLite DB, mounted by both services.
Must be on local disk (SQLite breaks on NFS) and owned by uid 1000.
- `models`: NFS volume from `NFS_SERVER`/`NFS_EXPORT`, mounted only by the worker. Use NFSv4
(hf needs file locks) and make the dataset writable for uid 1000 (owner 1000, or TrueNAS
*Mapall User/Group*). After changing NFS settings: `docker compose down && docker volume rm kaname_models`.
**Updating:** `docker compose pull && docker compose up -d`. To stay on a version, set e.g.
`KANAME_VERSION=0.4.0` in `.env`. The running version is shown next to the app name.
Pin a version with `KANAME_VERSION=0.4.0` in `.env`; the running version is shown next to the app
name in the header.
### Storing models on a NAS
The image picks its role from the first argument: `web` (default) or `worker`. Both run pending
DB migrations at startup (serialized with a file lock on `/data`), and the image has a built-in
healthcheck for both roles.
Mount the share on the Docker host and point `KANAME_MODELS_DIR` at it, e.g. in `/etc/fstab`:
## Local development
```
truenas.lan:/mnt/tank/models /mnt/nas/models nfs4 rw,hard,noatime,_netdev 0 0
```
```bash
# .env
KANAME_MODELS_DIR=/mnt/nas/models
```
- Use NFSv4: the `hf` CLI uses file locks.
- The share must be writable for uid 1000 (dataset owner 1000, or TrueNAS *Mapall User/Group*).
- Mount it before the containers start (`_netdev`), otherwise Docker uses the empty local folder.
- Keep `KANAME_DATA_DIR` on local disk: SQLite doesn't work reliably on NFS.
## Configuration
All settings live in `.env` (see [`.env.example`](.env.example)):
| Variable | Default | |
| --- | --- | --- |
| `AUTH_URL` | | Public URL of Kaname (used for the OIDC redirect) |
| `AUTH_SECRET` | | Secret for session cookies |
| `OIDC_ISSUER`, `OIDC_CLIENT_ID`, `OIDC_CLIENT_SECRET` | | OIDC provider (authorization code + PKCE) |
| `OIDC_ALLOWED_GROUPS` | *(anyone)* | Comma-separated groups from the `groups` claim |
| `HF_TOKEN` | | Hugging Face token (read-only is enough) |
| `KANAME_DATA_DIR` | `./data` | Host folder for the SQLite DB (local disk) |
| `KANAME_MODELS_DIR` | `./models` | Host folder for downloaded models |
| `WEB_PORT` | `3000` | Host port of the web UI |
| `KANAME_VERSION` | `latest` | Image tag to run |
| `MAX_CONCURRENT_DOWNLOADS` | `1` | Downloads running in parallel |
| `UPDATE_CHECK_INTERVAL_HOURS` | `12` | Hub update checks (`0` = off) |
| `HF_HUB_DISABLE_XET` | `1` | `0` uses Xet transfers (progress then only moves in large jumps) |
Models end up in `<models folder>/<org>/<repo>/`, e.g. `models/unsloth/Qwen3-8B-GGUF/`.
## Using it
<p align="center">
<img src="docs/screenshots/add-model.png" alt="Adding a model: quant quick-select" width="100%" />
</p>
- **Add model:** enter a repo ID like `unsloth/Qwen3-8B-GGUF` (or paste the URL), click a quant, and
**Add & download**. You can add tags right there.
- **Search:** type anything: `unsloth qwen`, `q4_k_m`, `gemma`, `roleplay`. Every word has to match
somewhere (repo, author, base model family, architecture, quant, tags).
- **Filter:** combine Author, Family, Quant, Tag and Status filters. The URL keeps the filters, so
you can bookmark a view.
- **Tags:** add or remove your own tags on a model's page; click a tag in the list to filter by it.
- **Jobs:** each download has a page with per-file progress and the full `hf` log.
## How it works
Two containers from the same image share one SQLite database:
- **web:** Next.js UI and API, OIDC login (Auth.js); live updates via Server-Sent Events.
- **worker:** runs the download queue, spawns `hf download --revision <sha> --include <files>`, and
measures progress from bytes on disk. Only one worker runs at a time.
Notes on the `hf` CLI (huggingface_hub 2.1.1, pinned in the image):
- Interrupted files are **not resumed**: a re-run skips finished files and restarts unfinished ones.
Kaname cleans up the leftover partial files.
- With Xet transfers the partial file only grows in large bursts, so Kaname disables Xet by default
to show accurate progress.
- `hf` exits successfully even if nothing matched, so Kaname checks every file's size and hash
metadata after each download.
## Development
```bash
npm install
npm run dev # web (http://localhost:3000) + worker
cp .env.example .env # plus DATABASE_URL=file:./data/app.db and MODELS_DIR=./data/models
npm run dev # web on http://localhost:3000 + worker
```
Use local paths in `.env` (`DATABASE_URL=file:./data/app.db`, `MODELS_DIR=./data/models`).
The worker needs the `hf` CLI on `PATH` (`pip install "huggingface_hub[hf_xet]==2.1.1"`); without it
everything but downloading works. Don't point a Windows-native web app and a containerized worker at
the same SQLite file: SQLite locking doesn't work across that boundary.
The worker needs `hf` on `PATH` (`pip install "huggingface_hub[hf_xet]==2.1.1"`). Without it,
everything but downloading works. `docker compose up --build` (root `compose.yaml`) builds and runs
the image locally.
| Script | What it does |
| --- | --- |
| `npm run dev:web` / `npm run dev:worker` | run one side only |
| `npm run db:generate` | create a migration after changing `src/lib/db/schema.ts` |
| `npm run db:migrate` | apply migrations without starting the worker |
| `npm run build:worker` | bundle the worker to `dist/worker.mjs` (used in the image) |
| `npm test` | unit tests (Node test runner via tsx) |
| `npm test` | unit tests |
| `npm run typecheck`, `npm run lint` | checks |
| `npm run db:generate` | new migration after changing `src/lib/db/schema.ts` |
| `npm run build:worker` | bundle worker + migrate script into `dist/` (used by the image) |
## How `hf download` behaves (huggingface_hub 2.1.1)
Verified in a container; the image pins this version. Re-check before bumping it.
- With `--local-dir`, partial files live in `<dir>/.cache/huggingface/download/` as
`<hash>.<etag>.<random>.incomplete` and are moved into place when complete.
- **Partial files are not resumed.** A re-run skips completed files but restarts unfinished ones
from zero (new random name). The worker deletes leftover partials.
- With Xet enabled the partial file only grows in large bursts, so the worker sets
`HF_HUB_DISABLE_XET=1` by default for accurate progress (configurable in `.env`).
- SIGTERM stops a download (exit 143); SIGINT does not stop a Xet download.
- Exit code 0 doesn't guarantee the files are there (e.g. a pattern that matched nothing), so the
worker checks every expected file's size and metadata afterwards.
**Releases:** bump `version` in `package.json`, add a `## [X.Y.Z]` section to
[`CHANGELOG.md`](CHANGELOG.md), commit and push a `vX.Y.Z` tag. Gitea Actions
([`.gitea/workflows/release.yaml`](.gitea/workflows/release.yaml)) runs the checks, pushes
`git.linxweiler.xyz/pascallinxweiler/kaname:X.Y.Z` (+ `X.Y`, `latest`) and creates the release.
It needs an `act_runner` with Docker access and a `REGISTRY_TOKEN` repo secret (package read/write).