registry

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HFModelInfo

type HFModelInfo struct {
	ID       string      `json:"id"`
	Siblings []HFSibling `json:"siblings"`
}

HFModelInfo represents the model metadata returned by the HuggingFace API.

type HFPullOptions

type HFPullOptions struct {
	// APIURL overrides the HuggingFace API endpoint.
	APIURL string
	// CDNURL overrides the HuggingFace CDN endpoint.
	CDNURL string
	// Token is an optional HuggingFace API token for gated models.
	Token string
	// OnProgress is called during file downloads.
	OnProgress ProgressFunc
	// Client overrides the HTTP client used for downloads.
	Client *http.Client
}

HFPullOptions configures HuggingFace model downloads.

type HFSibling

type HFSibling struct {
	Filename string `json:"rfilename"`
}

HFSibling represents a file entry in a HuggingFace model listing.

type LocalRegistry

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

LocalRegistry implements ModelRegistry with a local filesystem cache. Cache layout: <cacheDir>/<org>/<model>/ containing model.zmf, tokenizer.json, config.json.

func NewLocalRegistry

func NewLocalRegistry(cacheDir string) (*LocalRegistry, error)

NewLocalRegistry creates a LocalRegistry with the given cache directory. If cacheDir is empty, it defaults to ~/.zerfoo/models/.

func (*LocalRegistry) CacheDir

func (r *LocalRegistry) CacheDir() string

CacheDir returns the path to the local model cache directory.

func (*LocalRegistry) Delete

func (r *LocalRegistry) Delete(modelID string) error

Delete removes a locally cached model.

func (*LocalRegistry) Get

func (r *LocalRegistry) Get(modelID string) (*ModelInfo, bool)

Get returns a locally cached model by ID.

func (*LocalRegistry) List

func (r *LocalRegistry) List() []ModelInfo

List returns all locally cached models.

func (*LocalRegistry) Pull

func (r *LocalRegistry) Pull(ctx context.Context, modelID string) (*ModelInfo, error)

Pull downloads a model and caches it locally.

func (*LocalRegistry) SetPullFunc

func (r *LocalRegistry) SetPullFunc(fn PullFunc)

SetPullFunc sets the function used by Pull to download models.

type ModelInfo

type ModelInfo struct {
	ID           string `json:"id"`
	Path         string `json:"path"`
	Architecture string `json:"architecture"`
	VocabSize    int    `json:"vocab_size"`
	MaxSeqLen    int    `json:"max_seq_len"`
	Size         int64  `json:"size"`
}

ModelInfo describes a locally cached model.

type ModelRegistry

type ModelRegistry interface {
	// Pull downloads a model by ID and caches it locally.
	Pull(ctx context.Context, modelID string) (*ModelInfo, error)
	// Get returns a locally cached model by ID.
	Get(modelID string) (*ModelInfo, bool)
	// List returns all locally cached models.
	List() []ModelInfo
	// Delete removes a locally cached model.
	Delete(modelID string) error
}

ModelRegistry manages local model storage and retrieval.

type ProgressFunc

type ProgressFunc func(downloaded, total int64)

ProgressFunc reports download progress. total may be -1 if unknown.

type PullFunc

type PullFunc func(ctx context.Context, modelID string, targetDir string) (*ModelInfo, error)

PullFunc downloads or converts a model into the target directory. The target directory is guaranteed to exist when this function is called.

func NewHFPullFunc

func NewHFPullFunc(opts HFPullOptions) PullFunc

NewHFPullFunc creates a PullFunc that downloads models from HuggingFace Hub.

Jump to

Keyboard shortcuts

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