Add three new tabs to allow models and backends management from within the UI - #851
Add three new tabs to allow models and backends management from within the UI#851srossitto79 wants to merge 46 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Filename | Overview |
|---|---|
| internal/mantle/download.go | New file — handles single-file and whole-repo HuggingFace downloads. The filename parameter written to disk via filepath.Join is not validated, allowing path traversal to write files outside modelsDir. |
| internal/mantle/api.go | New HTTP handler file — registers all mantle API routes directly via mux.HandleFunc (bypassing the apiChain middleware used by other API routes). handleDeleteBackend lacks the isSafeBackendName check that handleStartBuild applies. |
| internal/mantle/mantle.go | New file — task manager, HuggingFace search/list. SearchHFModels inserts the user query into the URL without encoding; ListHFFiles inserts modelID without encoding. TaskManager.tasks is never pruned so completed tasks accumulate in memory. |
| internal/mantle/build.go | New file — spawns bash build-llamacpp.sh with user-supplied repo, branch, and cmake args. Args are passed as separate exec.Command arguments (no shell injection), and backendName is validated before this point. |
| internal/mantle/config.go | New file — lists/deletes local models and backends. DeleteLocalModel and DeleteBackend rely on filepath.Join path resolution; URL normalization in Go's mux limits traversal risk for URL-sourced names. |
| internal/server/server.go | Wires mantle handler into the server. Mantle routes are registered via mux.HandleFunc directly, not through apiChain, so they do not benefit from whatever middleware apiChain provides. |
| llama-swap.go | Adds three new CLI flags (--models-dir, --backends-dir, --build-script) with sane defaults derived from the config file's directory; runtime paths are re-applied on config reload. |
| scripts/pipe-wrap.py | New Python helper that wraps a stdin/stdout CLI inference tool as an OpenAI-compatible HTTP server. Serialises concurrent requests with a lock; streaming uses two SSE chunks (full text + stop). |
Comments Outside Diff (2)
-
internal/mantle/download.go, line 738 (link)Path traversal via
filenameparameterThe
filenamevalue from the JSON body is placed directly intofilepath.Join(modelsDir, ..., filename).filepath.Joinresolves..segments, so a caller supplying"filename": "../../etc/cron.d/backdoor"causeslocalPathto escapemodelsDirentirely — the downloaded content is then written to that resolved path viaos.Rename. In a containerised deployment running as root this means any file on the host-mapped filesystem can be overwritten.Add a guard before the download starts: reject any
filenamethat is absolute or whose cleaned form contains a..component. -
internal/mantle/mantle.go, line 1070-1073 (link)queryinserted into HuggingFace URL without encodingquery(taken directly from the user-suppliedqquery parameter) is interpolated into the URL string withfmt.Sprintfwithouturl.QueryEscape. A value likeggml&pipeline_tag=text-to-imagewould inject an extra parameter into the HuggingFace API request, bypassing thekindfilter logic and potentially returning unexpected results. Useurl.Valuesto build the URL safely.
Reviews (1): Last reviewed commit: "Merge branch 'mostlygeek:main' into main" | Re-trigger Greptile
…skip any that already exist as a local model. Fix: ui-svelte/src/components/playground/ConcurrencyInterface.svelte:395-397 — show "Connecting…" instead of "No models configured." when the SSE isn't yet connected.
…not delete on failed build
Merge upstream changes (v229-v241) while preserving llama-mantle features: - Resolved event ID conflicts (ProfileChangedEvent=0x08, mantle events at 0x09,0x0A) - Updated server.New() to accept both store.Store and mantle.TaskManager - Preserved mantle runtime paths (ConfigPath, ModelsDir, BackendsDir, BuildScript) - Kept upstream's UpstreamConfig field - Adopted upstream's shadcn-svelte UI rewrite with profile support - Added mantle routes (Model Hub, Config Editor, Backend Manager) to new router - Accepted upstream deletions of Header/ModelsPanel (replaced by AppSidebar) - Kept docker/unified/build-image.sh deleted (our docker refactoring)
This PR add some functionality that I found useful to myself.
The additions are mostly graphical changes in the UI and the addition of some backend endpoint to serve the new pages.
I also added a shell script to build llama.cpp that is invoked from go to builds from within the web-ui.
I don't know how useful you could find them but I leave this decision to the maintainer.
Hope they can come helpful for someone...
In case of PR accepted, consider removing Dockerfile.simplified because it doesn't follow the smart layer approach used in build-image.sh, also the docker compose is pretty customized to my needs and it would be better to generalize it.
If you find the work useful and want to include it, I can eventually make a branch do some change as per your requests.