models

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2025 License: Apache-2.0 Imports: 21 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeModelName

func NormalizeModelName(model string) string

NormalizeModelName adds the default organization prefix (ai/) and tag (:latest) if missing. It also converts Hugging Face model names to lowercase. Examples:

  • "gemma3" -> "ai/gemma3:latest"
  • "gemma3:v1" -> "ai/gemma3:v1"
  • "myorg/gemma3" -> "myorg/gemma3:latest"
  • "ai/gemma3:latest" -> "ai/gemma3:latest" (unchanged)
  • "hf.co/model" -> "hf.co/model:latest" (unchanged - has registry)
  • "hf.co/Model" -> "hf.co/model:latest" (converted to lowercase)

Types

type ClientConfig

type ClientConfig struct {
	// StoreRootPath is the root path for the model store.
	StoreRootPath string
	// Logger is the logger to use.
	Logger *logrus.Entry
	// Transport is the HTTP transport to use.
	Transport http.RoundTripper
	// UserAgent is the user agent to use.
	UserAgent string
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager manages inference model pulls and storage.

func NewManager

func NewManager(log logging.Logger, c ClientConfig, allowedOrigins []string, memoryEstimator memory.MemoryEstimator) *Manager

NewManager creates a new model's manager.

func (*Manager) BearerTokenForModel

func (m *Manager) BearerTokenForModel(ctx context.Context, ref string) (string, error)

BearerTokenForModel returns the bearer token needed to pull a given model.

func (*Manager) DeleteModel added in v1.0.6

func (m *Manager) DeleteModel(reference string, force bool) (*distribution.DeleteModelResponse, error)

DeleteModel deletes a model from storage and returns the delete response

func (*Manager) GetBundle

func (m *Manager) GetBundle(ref string) (types.ModelBundle, error)

GetBundle returns model bundle.

func (*Manager) GetDiskUsage

func (m *Manager) GetDiskUsage() (int64, int, error)

GetDiskUsage returns the disk usage of the model store.

func (*Manager) GetModel

func (m *Manager) GetModel(ref string) (types.Model, error)

GetModel returns a single model.

func (*Manager) GetModels added in v1.0.5

func (m *Manager) GetModels() ([]*Model, error)

GetModels returns all models.

func (*Manager) GetRemoteModel

func (m *Manager) GetRemoteModel(ctx context.Context, ref string) (types.ModelArtifact, error)

GetRemoteModel returns a single remote model.

func (*Manager) GetRemoteModelBlobURL

func (m *Manager) GetRemoteModelBlobURL(ref string, digest v1.Hash) (string, error)

GetRemoteModelBlobURL returns the URL of a given model blob.

func (*Manager) IsModelInStore

func (m *Manager) IsModelInStore(ref string) (bool, error)

IsModelInStore checks if a given model is in the local store.

func (*Manager) PullModel

func (m *Manager) PullModel(model string, bearerToken string, r *http.Request, w http.ResponseWriter) error

PullModel pulls a model to local storage. Any error it returns is suitable for writing back to the client.

func (*Manager) PushModel

func (m *Manager) PushModel(model string, r *http.Request, w http.ResponseWriter) error

PushModel pushes a model from the store to the registry.

func (*Manager) RebuildRoutes

func (m *Manager) RebuildRoutes(allowedOrigins []string)

func (*Manager) ResolveModelID

func (m *Manager) ResolveModelID(modelRef string) string

ResolveModelID resolves a model reference to a model ID. If resolution fails, it returns the original ref.

func (*Manager) ServeHTTP

func (m *Manager) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implement net/http.Handler.ServeHTTP.

type Model

type Model struct {
	// ID is the globally unique model identifier.
	ID string `json:"id"`
	// Tags are the list of tags associated with the model.
	Tags []string `json:"tags,omitempty"`
	// Created is the Unix epoch timestamp corresponding to the model creation.
	Created int64 `json:"created"`
	// Config describes the model.
	Config types.Config `json:"config"`
}

func ToModel

func ToModel(m types.Model) (*Model, error)

type ModelCreateRequest

type ModelCreateRequest struct {
	// From is the name of the model to pull.
	From string `json:"from"`
	// IgnoreRuntimeMemoryCheck indicates whether the server should check if it has sufficient
	// memory to run the given model (assuming default configuration).
	IgnoreRuntimeMemoryCheck bool `json:"ignore-runtime-memory-check,omitempty"`
	// BearerToken is an optional bearer token for authentication.
	BearerToken string `json:"bearer-token,omitempty"`
}

ModelCreateRequest represents a model create request. It is designed to follow Docker Engine API conventions, most closely following the request associated with POST /images/create. At the moment is only designed to facilitate pulls, though in the future it may facilitate model building and refinement (such as fine tuning, quantization, or distillation).

type ModelPackageRequest

type ModelPackageRequest struct {
	// From is the name of the source model to package from.
	From string `json:"from"`
	// Tag is the name to give the new packaged model.
	Tag string `json:"tag"`
	// ContextSize specifies the context size to set for the new model.
	ContextSize uint64 `json:"context-size,omitempty"`
}

ModelPackageRequest represents a model package request, which creates a new model from an existing one with modified properties (e.g., context size).

type OpenAIModel

type OpenAIModel struct {
	// ID is the model tag.
	ID string `json:"id"`
	// Object is the object type. For OpenAIModel, it is always "model".
	Object string `json:"object"`
	// Created is the Unix epoch timestamp corresponding to the model creation.
	Created int64 `json:"created"`
	// OwnedBy is the model owner. At the moment, it is always "docker".
	OwnedBy string `json:"owned_by"`
}

OpenAIModel represents a locally stored model using OpenAI conventions.

func ToOpenAI

func ToOpenAI(m types.Model) (*OpenAIModel, error)

ToOpenAI converts a types.Model to its OpenAI API representation.

type OpenAIModelList

type OpenAIModelList struct {
	// Object is the object type. For OpenAIModelList, it is always "list".
	Object string `json:"object"`
	// Data is the list of models.
	Data []*OpenAIModel `json:"data"`
}

OpenAIModelList represents a list of models using OpenAI conventions.

func ToOpenAIList

func ToOpenAIList(l []types.Model) (*OpenAIModelList, error)

ToOpenAIList converts the model list to its OpenAI API representation. This function never returns a nil slice (though it may return an empty slice).

type SimpleModel

type SimpleModel struct {
	types.Model
	ConfigValue     types.Config
	DescriptorValue types.Descriptor
}

SimpleModel is a wrapper that allows creating a model with modified configuration

func (*SimpleModel) Config

func (s *SimpleModel) Config() (types.Config, error)

func (*SimpleModel) Descriptor

func (s *SimpleModel) Descriptor() (types.Descriptor, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL