hf

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package hf implements backend.Repo over the Hugging Face Hub HTTP API with a hand-rolled net/http client, the same shape as the ghapi backend: bearer auth, conditional requests (ETag), Link-header pagination, and rate-limit errors. Commit detail, Blame, and Archive return backend.ErrUnsupported because the Hub API has no endpoint for them; the server degrades those views per the capability model.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repo

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

Repo is a backend.Repo bound to one Hub repository on one API host.

func New

func New(kind, owner, name, token string) *Repo

New returns a Repo talking to huggingface.co. kind is "model", "dataset", or "space"; anything else panics, because the CLI validates kinds before construction. An empty token means anonymous access.

func NewWithBaseURL

func NewWithBaseURL(kind, owner, name, token, baseURL string, client *http.Client) *Repo

NewWithBaseURL is New with the API host and HTTP client injectable, which tests use to point at a mock server. A nil client means http.DefaultClient.

func (*Repo) Archive

func (r *Repo) Archive(ctx context.Context, rev, format, prefix string, w io.Writer) error

func (*Repo) Blame

func (r *Repo) Blame(ctx context.Context, rev, pth string) ([]backend.BlameHunk, error)

func (*Repo) Blob

func (r *Repo) Blob(ctx context.Context, rev, pth string) (backend.Blob, error)

func (*Repo) Commit

func (r *Repo) Commit(ctx context.Context, sha string) (backend.CommitDetail, error)

func (*Repo) Commits

func (r *Repo) Commits(ctx context.Context, rev, pth string, n, skip int) ([]backend.Commit, bool, error)

func (*Repo) Files

func (r *Repo) Files(ctx context.Context, rev string) ([]string, error)

func (*Repo) Info

func (r *Repo) Info(ctx context.Context) (backend.Info, error)

func (*Repo) LastCommit

func (r *Repo) LastCommit(ctx context.Context, rev, pth string) (backend.Commit, error)

func (*Repo) Refs

func (r *Repo) Refs(ctx context.Context) (backend.Refs, error)

func (*Repo) Resolve

func (r *Repo) Resolve(ctx context.Context, ref string) (string, error)

func (*Repo) Tree

func (r *Repo) Tree(ctx context.Context, rev, pth string) ([]backend.TreeEntry, error)

Jump to

Keyboard shortcuts

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