A page for anyone in a project, built for the one who knows least: an Excel, CSV or JSONL file of questions and answers, previewed; a model; a name; who may use it; and a button. The weights to train on are found from where the model's came (a GGUF repository's base model), the card's memory from their size, the node as the one with the most free. When it is done the adapter is published by itself (a llama.cpp model's replicas replaced to load it) and is a model of its own in the chat and the API. The project's by default; its members share it wider (confirmed, and never wider than the knowledge bases its pairs came from) or delete it. One trains at a time per project. ctl train start needs only --model and --data now, and --publish publishes when done. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
50 lines
1.6 KiB
Go
50 lines
1.6 KiB
Go
package web
|
|
|
|
import (
|
|
"net/http/httptest"
|
|
"regexp"
|
|
"strings"
|
|
"testing"
|
|
|
|
"gitea.mynodes.xyz/ilker/llmgw/internal/store"
|
|
)
|
|
|
|
var untranslated = regexp.MustCompile(`train\.[a-z]`)
|
|
|
|
func TestTheTrainingPageDrawsInEveryLanguage(t *testing.T) {
|
|
for _, lang := range []string{"en", "tr"} {
|
|
req := httptest.NewRequest("GET", "/train", nil)
|
|
req.Header.Set("Accept-Language", lang)
|
|
rec := httptest.NewRecorder()
|
|
Train(store.User{Email: "a@b.c"}, []string{"qwen2.5-7b"}, []ChatContext{{Value: "p1", Label: "Acme / hr / bot"}}, "v0")(rec, req)
|
|
if rec.Code != 200 {
|
|
t.Fatalf("%s: %d %s", lang, rec.Code, rec.Body.String())
|
|
}
|
|
page := rec.Body.String()
|
|
for _, want := range []string{`<option>qwen2.5-7b</option>`, `id="file"`, `/train/start`, `value="p1"`, `Acme / hr / bot`} {
|
|
if !strings.Contains(page, want) {
|
|
t.Errorf("%s: %s missing", lang, want)
|
|
}
|
|
}
|
|
if untranslated.MatchString(page) {
|
|
t.Errorf("%s: an untranslated key is on the page", lang)
|
|
}
|
|
}
|
|
for name, page := range map[string]func() string{
|
|
"no project": func() string {
|
|
rec := httptest.NewRecorder()
|
|
Train(store.User{}, []string{"q"}, nil, "v0")(rec, httptest.NewRequest("GET", "/train", nil))
|
|
return rec.Body.String()
|
|
},
|
|
"no model": func() string {
|
|
rec := httptest.NewRecorder()
|
|
Train(store.User{}, nil, []ChatContext{{Value: "p"}}, "v0")(rec, httptest.NewRequest("GET", "/train", nil))
|
|
return rec.Body.String()
|
|
},
|
|
} {
|
|
if p := page(); !strings.Contains(p, `class="empty"`) || strings.Contains(p, `id="start"`) {
|
|
t.Errorf("%s: the page offers training", name)
|
|
}
|
|
}
|
|
}
|