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>
94 lines
2.9 KiB
Go
94 lines
2.9 KiB
Go
package web
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"gitea.mynodes.xyz/ilker/llmgw/internal/store"
|
|
)
|
|
|
|
// Nav is the menu at the top of every signed-in page.
|
|
//
|
|
// One menu, drawn by one template, because each page used to write its own:
|
|
// the same links in a different order, some missing, and the page you were on
|
|
// sometimes listed and sometimes not. Moving between pages then read as moving
|
|
// between different programs.
|
|
type Nav struct {
|
|
// Current is the page being shown, so its link is marked rather than
|
|
// offered: "cluster", "people", "quotas", "usage", "mirror", "chat", "images",
|
|
// "keys".
|
|
Current string
|
|
// Admin shows the administration links, and Role which of them: a
|
|
// billing role sees usage and quotas only.
|
|
Admin bool
|
|
Role string
|
|
// Mirror and Quotas are whether those pages were mounted at all; usage is
|
|
// mounted with quotas.
|
|
Mirror, Quotas bool
|
|
// Guard is whether the guardrails page was mounted.
|
|
Guard bool
|
|
// Settings offers the cluster's settings: mounted, and to an
|
|
// administrator only.
|
|
Settings bool
|
|
// MCP offers the company's MCP servers, the same way.
|
|
MCP bool
|
|
// CSRF signs the sign-out form.
|
|
CSRF string
|
|
// Org offers the organization page: to an administrator, and to anyone
|
|
// who manages an organization.
|
|
Org bool
|
|
// Images offers the pictures page, while some model makes them; Meshes
|
|
// the 3D page.
|
|
Images, Meshes bool
|
|
// Train offers the page that customises a model, while some model can be.
|
|
Train bool
|
|
}
|
|
|
|
type navKey struct{}
|
|
|
|
// navFor builds the menu for a signed-in person.
|
|
func (p *AccountPages) navFor(r *http.Request, user store.User, current string) Nav {
|
|
n := Nav{
|
|
Current: current,
|
|
Admin: user.Staff(),
|
|
Role: user.StaffRole(),
|
|
Mirror: p.hasMirror,
|
|
Quotas: p.hasQuotas,
|
|
Guard: p.hasGuard,
|
|
Settings: p.hasSettings && user.IsAdmin,
|
|
MCP: p.hasMCP && user.IsAdmin,
|
|
CSRF: csrfFor(r),
|
|
Images: p.images != nil && p.images(),
|
|
Meshes: p.meshes != nil && p.meshes(),
|
|
Train: p.train != nil && p.train(),
|
|
}
|
|
// Only when there is an organization to show: a link that leads to "there
|
|
// are none" on every page is noise.
|
|
if p.orgs != nil {
|
|
var orgs []store.Org
|
|
var err error
|
|
if user.IsAdmin {
|
|
orgs, err = p.orgs.AllOrgs(r.Context())
|
|
} else {
|
|
orgs, err = p.orgs.ManagedOrgs(r.Context(), user.ID)
|
|
}
|
|
n.Org = err == nil && len(orgs) > 0
|
|
}
|
|
return n
|
|
}
|
|
|
|
// withNav carries the menu to a page rendered by a handler that has no
|
|
// session of its own — the dashboard and the node logs are built without the
|
|
// account pages and wrapped by them.
|
|
func (p *AccountPages) withNav(r *http.Request, user store.User) *http.Request {
|
|
return r.WithContext(context.WithValue(r.Context(), navKey{}, p.navFor(r, user, "")))
|
|
}
|
|
|
|
// navFrom reads the menu withNav stored, marked for the page being drawn.
|
|
// Zero when there is none, which draws no admin links.
|
|
func navFrom(r *http.Request, current string) Nav {
|
|
n, _ := r.Context().Value(navKey{}).(Nav)
|
|
n.Current = current
|
|
return n
|
|
}
|