Documentation
¶
Overview ¶
Package modelacquisition owns curated native-model discovery and acquisition.
Index ¶
- Variables
- type DownloadProgress
- type Installer
- type LibraryEntry
- type Progress
- type ProviderRefresher
- type ProviderSetup
- type Request
- type Service
- func (s *Service) Catalog(ctx context.Context) ([]modelregistry.ModelDescriptor, error)
- func (s *Service) Library(ctx context.Context) ([]LibraryEntry, error)
- func (s *Service) Pull(ctx context.Context, model string, progress Progress) error
- func (s *Service) PullTo(ctx context.Context, request Request, progress Progress) error
- type StoreInstaller
- type UnknownModelError
Constants ¶
This section is empty.
Variables ¶
var Contract = servicecontract.Contract{ ID: "model-acquisition", Summary: "List and download local models", Description: "List the curated local models with the roles each serves, then download one complete model bundle to this computer or to a selected modeld connection so a role can be assigned to and verified on it.", Operations: []servicecontract.Operation{ { ID: "catalog", Summary: "List the downloadable local models", Description: "Read the curated local-model catalog with each model's size, the roles it can serve and whether it is already downloaded.", Spec: "List the curated local models this computer can download. Each entry carries the model's name, its size, the roles it can serve and whether its bundle is already on this computer. The names are the identities the download operation accepts.", Output: servicecontract.Output{ Stdout: "One entry per curated model: name, engine, size and description.", Format: "text", }, Outcomes: []servicecontract.Outcome{ {Code: 0, When: "the catalog is read", Meaning: "every listed name can be downloaded"}, }, Refusals: []servicecontract.Refusal{ {When: "the catalog cannot be read", Message: "names the failure"}, }, }, { ID: "pull", Summary: "Acquire a complete model bundle", Description: "Download one curated model's complete bundle to the chosen host, register the local connection that serves it and rediscover that connection's models. Assigning and verifying the model for a role is a separate step.", Spec: "Download one curated local model, with every file its engine needs, to this computer or to a selected modeld connection. The download reports its progress, can be stopped, and installs nothing until the whole bundle has arrived, so a stopped or failed download leaves no partial model and can simply be run again. Afterwards the connection that serves the model is registered if none exists and its models are rediscovered; a role is assigned to the model with its own command.", Usage: "<name>", Inputs: []servicecontract.Input{ {ID: "model", Summary: "Curated model identity, as the catalog lists it", Type: "string", Required: true, Positional: 1, Placeholder: "name"}, {ID: "acquisition", Summary: "The host that receives the bundle: target local or connection, with the connection id for a connection; absent installs on this computer", Type: "object"}, }, Output: servicecontract.Output{ Stdout: "The download's progress, then the model's name once it is available.", Format: "text", }, Outcomes: []servicecontract.Outcome{ {Code: 0, When: "the complete bundle is installed", Meaning: "the model is discovered on its connection and can be assigned to a role"}, }, Refusals: []servicecontract.Refusal{ {When: "the name is not in the catalog", Message: "names the unknown model and lists the catalog's names"}, {When: "the host is not a reachable modeld owner", Message: "names the host and what it answered"}, {When: "the download is stopped or fails", Message: "reports the cause and leaves nothing installed"}, }, }, }, }
Contract describes model acquisition independently of the selected transport or host.
Functions ¶
This section is empty.
Types ¶
type DownloadProgress ¶
type DownloadProgress = modelstore.DownloadProgress
DownloadProgress is the byte position reported while acquiring a model.
type Installer ¶
type Installer interface {
Ensure(context.Context, modelregistry.Registry, string, modelstore.AutoPullOptions) error
EnsureAt(context.Context, modelregistry.Registry, string, string, modelstore.AutoPullOptions) error
}
Installer acquires curated models through local and remote model-store owners.
type LibraryEntry ¶
type LibraryEntry struct {
Model modelregistry.ModelDescriptor
Roles []string
Downloaded bool
}
LibraryEntry is one catalog model with the roles it serves and whether its bundle is already on this computer.
type Progress ¶
type Progress func(modelstore.DownloadProgress) error
Progress receives download byte positions.
type ProviderRefresher ¶
ProviderRefresher refreshes discovered models for selected connections.
type ProviderSetup ¶
type ProviderSetup interface {
ConnectProvider(context.Context, inferencesetup.ProviderRequest) (inferencesetup.ProviderResult, error)
}
ProviderSetup registers the local provider used after acquisition.
type Request ¶
type Request struct {
Target string `json:"target"`
ConnectionID string `json:"connectionId"`
Model string `json:"model"`
}
Request selects the host that receives the complete model bundle.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service owns native-model discovery and acquisition.
func New ¶
func New(db libdbexec.DBManager, setup ProviderSetup, state ProviderRefresher, registry modelregistry.Registry, installer Installer, dataRoot string, tracker libtracker.ActivityTracker) (*Service, error)
New constructs model acquisition from required runtime dependencies.
func (*Service) Catalog ¶
func (s *Service) Catalog(ctx context.Context) ([]modelregistry.ModelDescriptor, error)
Catalog returns the current curated local-model catalog.
func (*Service) Library ¶
func (s *Service) Library(ctx context.Context) ([]LibraryEntry, error)
Library returns the catalog with the roles each model serves and whether its bundle is already in this computer's model store.
type StoreInstaller ¶
type StoreInstaller struct{}
StoreInstaller acquires models through the runtime model store.
func (StoreInstaller) Ensure ¶
func (StoreInstaller) Ensure(ctx context.Context, registry modelregistry.Registry, model string, options modelstore.AutoPullOptions) error
Ensure acquires a model through the shared owner's model store.
func (StoreInstaller) EnsureAt ¶
func (StoreInstaller) EnsureAt(ctx context.Context, registry modelregistry.Registry, model, endpoint string, options modelstore.AutoPullOptions) error
EnsureAt acquires a model through the selected remote owner's model store.
type UnknownModelError ¶
UnknownModelError reports a model name the catalog does not carry, with the names it does.
func (*UnknownModelError) Error ¶
func (e *UnknownModelError) Error() string
Error implements error.