store

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*client.Client
}

func NewClient

func NewClient(opts ...client.ClientOpt) (*Client, error)

func (*Client) GetDestPath

func (c *Client) GetDestPath(url string) (string, error)

GetDestPath returns the suggested destination path for a model URL without downloading.

func (*Client) GetModelSize

func (c *Client) GetModelSize(ctx context.Context, url string) (uint64, error)

GetModelSize returns the remote file size by making a HEAD request.

func (*Client) PullModel

func (c *Client) PullModel(ctx context.Context, w io.Writer, url string, fn ClientCallback, additionalOpts ...client.RequestOpt) (destPath string, err error)

PullModel downloads a model from the given URL and returns the suggested destination path. Supports HuggingFace URLs with hf:// scheme and regular HTTP(S) URLs. If a callback is provided, it first makes a HEAD request and calls the callback with (filename, 0, total_size). If the callback returns an error, the download is aborted.

type ClientCallback

type ClientCallback func(filename string, bytes_received uint64, total_bytes uint64) error

type ClientModel

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

func NewClientModel

func NewClientModel(w io.Writer, fn ClientCallback) *ClientModel

func (*ClientModel) Unmarshal

func (g *ClientModel) Unmarshal(headers http.Header, r io.Reader) error

func (*ClientModel) Write

func (g *ClientModel) Write(p []byte) (int, error)

type PullCallbackFunc

type PullCallbackFunc func(filename string, bytes_received uint64, total_bytes uint64)

type Store

type Store struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Store manages a collection of GGUF models in a directory.

func New

func New(path string, opts ...client.ClientOpt) (*Store, error)

New creates new model storage at the given path. The path must be an existing directory.

func (*Store) DeleteModel

func (s *Store) DeleteModel(ctx context.Context, name string) error

DeleteModel deletes a model from the store by name. It matches against the full relative path, filename, or model name. Returns ErrNotFound if the model doesn't exist.

func (*Store) GetModel

func (s *Store) GetModel(ctx context.Context, name string) (*schema.Model, error)

GetModel returns a model by name. It matches against the full relative path or the filename (last element of the path). Returns ErrNotFound if not found.

func (*Store) ListModels

func (s *Store) ListModels(ctx context.Context) ([]*schema.Model, error)

ListModels scans the store directory for GGUF models and returns their metadata. Hidden files and directories are skipped. Invalid GGUF files are silently skipped.

func (*Store) Path

func (s *Store) Path() string

Path returns the store's root directory path.

func (*Store) PullModel

func (s *Store) PullModel(ctx context.Context, url string, callback ClientCallback) (*schema.Model, error)

PullModel downloads a model from the given URL into the store and returns the loaded model. Supports HuggingFace URLs with hf:// scheme and regular HTTP(S) URLs. The callback receives progress updates during download.

Jump to

Keyboard shortcuts

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