Search Hugging Face from the console and serve what is found
CI / test (push) Successful in 5m3s

Serve a model is a view of the registry's GGUF models, trending or searched;
Enter on one lists its files, and the one chosen is served with
llmgw ctl model serve. A form of one field is applied by Enter on it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-03 23:44:51 +02:00
1 parent 6a7b4bb6a0
commit 2bf43ed90c
5 files changed
+300 -31

No files matched your search

+62
View File
@@ -257,3 +257,65 @@ func TestTheSidebarFitsAShortScreen(t *testing.T) {
}
}
}
func TestAModelIsFoundOnTheRegistryAndServedFromTheConsole(t *testing.T) {
reg := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch {
case r.URL.Path == "/api/models":
if r.URL.Query().Get("search") != "qwen" || r.URL.Query().Get("filter") != "gguf" {
_, _ = w.Write([]byte(`[]`))
return
}
_, _ = w.Write([]byte(`[{"id":"bartowski/Qwen2.5-3B-Instruct-GGUF","downloads":1200,"gguf":{"total":3000000000,"architecture":"qwen2"}}]`))
case r.URL.Path == "/api/models/bartowski/Qwen2.5-3B-Instruct-GGUF":
_, _ = w.Write([]byte(`{"id":"bartowski/Qwen2.5-3B-Instruct-GGUF","sha":"abc"}`))
case strings.HasPrefix(r.URL.Path, "/api/models/bartowski/Qwen2.5-3B-Instruct-GGUF/tree/"):
_, _ = w.Write([]byte(`[{"type":"file","path":"Qwen2.5-3B-Instruct-Q4_K_M.gguf","lfs":{"oid":"x","size":2000000000}},
{"type":"file","path":"Qwen2.5-3B-Instruct-Q8_0.gguf","lfs":{"oid":"y","size":3000000000}},
{"type":"file","path":"mmproj-f16.gguf","size":10}]`))
default:
http.NotFound(w, r)
}
}))
defer reg.Close()
dir := t.TempDir()
cfgPath := dir + "/server.yaml"
if err := os.WriteFile(cfgPath, []byte("mirror:\n api: http://127.0.0.1:1\n registry: "+reg.URL+"\n"), 0o600); err != nil {
t.Fatal(err)
}
m := newConsoleModel("127.0.0.1:9090", cfgPath)
m.loaded, m.menu, m.inPanel = true, cServe, true
var tm tea.Model = m
run := func(tm tea.Model, cmd tea.Cmd) tea.Model {
if cmd != nil {
tm, _ = tm.Update(cmd())
}
return tm
}
tm, _ = tm.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune("/")})
tm = press(tm, "q", "w", "e", "n")
tm, cmd := tm.Update(tea.KeyMsg{Type: tea.KeyEnter})
tm = run(tm, cmd)
if v := tm.View(); !strings.Contains(v, "bartowski/Qwen2.5-3B-Instruct-GGUF") || !strings.Contains(v, "3.0B") {
t.Fatalf("no result:\n%s", v)
}
tm, cmd = tm.Update(tea.KeyMsg{Type: tea.KeyEnter})
tm = run(tm, cmd)
d := tm.(consoleModel).menuD
if d == nil || len(d.items) != 2 {
t.Fatalf("files offered: %+v", d)
}
tm = press(tm, "down", "enter")
f := tm.(consoleModel).formD
if f == nil || f.fields[0].value() != "qwen2.5-3b-instruct" {
t.Fatalf("form: %+v", f)
}
f.focus = len(f.fields)
tm, _ = tm.Update(tea.KeyMsg{Type: tea.KeyEnter})
act := tm.(consoleModel).action
got := strings.Join(act.targets, " ")
if act.kind != "run" || !strings.Contains(got, "model serve bartowski/Qwen2.5-3B-Instruct-GGUF --file=Qwen2.5-3B-Instruct-Q8_0.gguf --name=qwen2.5-3b-instruct --replicas=1") {
t.Fatalf("would run %q %q", act.kind, got)
}
}