CI / test (push) Successful in 10m51s
The row of a served model leads to its card, which now changes its context and longest answer, its cards, its replicas on each profile with a profile on CPUs to add and its speed beside, stops, starts and restarts it, and removes it with its files or without. Stopped on the row stops the model rather than setting its scaling to nothing. The console gains Replicas per profile, and ctl models shows the counts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
2.0 KiB
Go
60 lines
2.0 KiB
Go
package adminapi
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"gitea.mynodes.xyz/ilker/llmgw/internal/control/modelserve"
|
|
"gitea.mynodes.xyz/ilker/llmgw/internal/control/reconciler"
|
|
)
|
|
|
|
// What the portal changes of a served model beside what the catalog holds:
|
|
// the same as the API's routes, called in the process.
|
|
|
|
// SetModelContext changes a served model's context and longest answer.
|
|
func (a *API) SetModelContext(ctx context.Context, name string, req modelserve.ContextRequest, by string) (modelserve.ContextChange, error) {
|
|
if a.serve == nil {
|
|
return modelserve.ContextChange{}, errors.New("this control plane cannot change a model's context")
|
|
}
|
|
return a.serve.SetContext(ctx, name, req, by)
|
|
}
|
|
|
|
// SetModelGPUs spreads a served model over more cards a replica, or fewer.
|
|
func (a *API) SetModelGPUs(ctx context.Context, name string, req modelserve.GPUsRequest, by string) (modelserve.GPUsChange, error) {
|
|
if a.serve == nil {
|
|
return modelserve.GPUsChange{}, errors.New("this control plane cannot change a model's cards")
|
|
}
|
|
return a.serve.SetGPUs(ctx, name, req, by)
|
|
}
|
|
|
|
// RestartModel starts each of a model's ready replicas again, one at a time,
|
|
// and says how many.
|
|
func (a *API) RestartModel(name string) (int, error) {
|
|
var ids []string
|
|
for _, rep := range a.ctl.Reconciler().ReadyReplicas() {
|
|
if rep.Model == name {
|
|
ids = append(ids, rep.ID)
|
|
}
|
|
}
|
|
if len(ids) == 0 {
|
|
return 0, errors.New("none of its replicas is ready to restart")
|
|
}
|
|
return len(ids), a.ctl.Reconciler().RestartPaced(reconciler.RestartPace{}, false, ids...)
|
|
}
|
|
|
|
// RemoveModel takes a model out of the catalog, with its files on the mirror
|
|
// and the nodes when purge.
|
|
func (a *API) RemoveModel(ctx context.Context, name string, purge bool, by string) (PurgeView, error) {
|
|
if purge {
|
|
return a.Purge(ctx, name, by)
|
|
}
|
|
if a.models == nil {
|
|
return PurgeView{}, errors.New("this control plane has no store")
|
|
}
|
|
if err := a.models.Remove(ctx, name); err != nil {
|
|
return PurgeView{}, err
|
|
}
|
|
a.presetDeclined(ctx, name, by)
|
|
return PurgeView{Removed: name}, nil
|
|
}
|