hf

package
v0.1.24 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(ctx context.Context, p Path) ([]byte, error)

Download retrieves the contents of a file in a Hugging Face repository.

func DownloadStream added in v0.1.8

func DownloadStream(ctx context.Context, p Path) (io.ReadCloser, error)

func ListFiles

func ListFiles(ctx context.Context, p Path) ([]string, error)

ListFiles retrieves repo files for directory-like paths.

func SetHTTPClient added in v0.1.21

func SetHTTPClient(c *http.Client)

SetHTTPClient installs a process-wide HTTP client used for all requests issued by this package. Passing nil clears the override and restores http.DefaultClient behavior.

This must be called before any request is issued, e.g. from main's Before: hook, so that all callers observe the override.

Types

type HTTPStatusError added in v0.1.17

type HTTPStatusError struct {
	StatusCode int
	Status     string
}

HTTPStatusError is returned when an HTTP request returns a non-2xx status code.

func (*HTTPStatusError) Error added in v0.1.17

func (e *HTTPStatusError) Error() string

type Path

type Path struct {
	Repo string // owner/name
	File string // optional file path within repo
}

Path represents a Hugging Face repository or file.

func Parse

func Parse(raw string) (Path, error)

Parse parses hf://owner/repo[/file] and hf://datasets/owner/repo[/file] paths.

func (Path) DefaultFilename

func (p Path) DefaultFilename() string

DefaultFilename returns the filename to use when writing this path to a directory.

func (Path) String

func (p Path) String() string

func (Path) URL

func (p Path) URL() (string, error)

URL returns the download URL for the path.

Jump to

Keyboard shortcuts

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