huggingface

package
v0.264.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultBaseURL = "https://huggingface.co"

DefaultBaseURL is the public Hugging Face Hub.

Variables

View Source
var ErrNotCached = errors.New("file not cached and download not allowed")

ErrNotCached reports a file that is missing from the cache while the caller did not allow a download. Callers wrap it with the config key that gates it.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL string
	HTTP    *http.Client
}

Client downloads repository files. BaseURL and HTTP are overridable in tests.

func NewClient

func NewClient() *Client

NewClient returns a Client for the public Hub. Its transport bounds the response-header wait so a non-responding Hub errors instead of hanging the download - the request context bounds the body read for large models.

func (*Client) EnsureFile

func (c *Client) EnsureFile(ctx context.Context, repo Repo, file, dir, label string, allowDownload bool, report func(string)) (string, error)

EnsureFile returns the local path of file inside dir, downloading it from repo when it is missing and allowDownload is true. A missing file with downloads disallowed yields ErrNotCached. label names the file in progress reports (sent to report, nil for none) and errors (e.g. "whisper model").

func (*Client) Files added in v0.262.0

func (c *Client) Files(ctx context.Context, repo Repo) ([]File, error)

Files lists the files of repo at its revision, folders left out. shortcut: reads the first page the Hub answers, follow its Link header once a repository outgrows it.

func (*Client) Search added in v0.262.0

func (c *Client) Search(ctx context.Context, query string, limit int) ([]Model, error)

Search returns up to limit model repositories matching query, the most downloaded first.

type File added in v0.262.0

type File struct {
	Path string `json:"path"`
	Size int64  `json:"size"`
}

File is one file of a repository, with its size in bytes.

type Model added in v0.262.0

type Model struct {
	ID          string `json:"id"`
	Downloads   int64  `json:"downloads"`
	Likes       int64  `json:"likes"`
	PipelineTag string `json:"pipeline_tag,omitempty"`
}

Model is a model repository as the Hub's search lists it.

type Repo

type Repo struct {
	ID       string
	Revision string
}

Repo identifies a model repository on the Hub, e.g. "ggerganov/whisper.cpp". An empty Revision means "main". Set a commit SHA to pin the files.

Jump to

Keyboard shortcuts

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