hub

package
v0.0.0-...-0a21d2c Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 20 Imported by: 1

Documentation

Overview

hub/download.go

Index

Constants

View Source
const (
	DownloadChunkSize = 1024 * 1024 // 1MB
	DefaultRetries    = 5
)
View Source
const (
	ModelRepoType   = "model"
	SpaceRepoType   = "space"
	DatasetRepoType = "dataset"

	DefaultRevision = "main"
	DefaultCacheDir = "~/.cache/huggingface/hub"
)

Variables

This section is empty.

Functions

func GetToken

func GetToken() string

func IsOfflineMode

func IsOfflineMode() bool

Types

type CivitaiSource

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

func NewCivitaiSource

func NewCivitaiSource(url string, apiKey string) *CivitaiSource

func (*CivitaiSource) Download

func (s *CivitaiSource) Download(destPath string, progress *mpb.Progress) error

func (*CivitaiSource) GetFileInfo

func (s *CivitaiSource) GetFileInfo() (*FileInfo, error)

type Client

type Client struct {
	Endpoint  string
	Token     string
	CacheDir  string
	UserAgent string
	Progress  *mpb.Progress
}

func DefaultClient

func DefaultClient() *Client

func NewClient

func NewClient(endpoint string, token string, cacheDir string) *Client

func (*Client) Download

func (client *Client) Download(params *DownloadParams) (string, error)

func (*Client) WithToken

func (client *Client) WithToken(token string) *Client

type ComponentDef

type ComponentDef struct {
	ClassName string `json:"class_name"`
	Source    string `json:"source"`
}

type DirectURLSource

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

func NewDirectURLSource

func NewDirectURLSource(url string) *DirectURLSource

func (*DirectURLSource) Download

func (s *DirectURLSource) Download(destPath string, progress *mpb.Progress) error

func (*DirectURLSource) GetFileInfo

func (s *DirectURLSource) GetFileInfo() (*FileInfo, error)

type DownloadParams

type DownloadParams struct {
	Repo           *Repo
	FileName       string
	SubFolder      string
	Revision       string
	ForceDownload  bool
	LocalFilesOnly bool
	AllowPatterns  []string
	IgnorePatterns []string
	Components     map[string]ComponentDef
}

type DownloadSource

type DownloadSource interface {
	GetFileInfo() (*FileInfo, error)
	Download(destPath string, progress *mpb.Progress) error
}

type FileInfo

type FileInfo struct {
	URL      string
	Size     int64
	Filename string
}

type FileMetadata

type FileMetadata struct {
	CommitHash string
	ETag       string
	Location   string
	Size       int
}

type LFSPointer

type LFSPointer struct {
	Sha256 string
	Size   int
}

type ModelInfo

type ModelInfo struct {
	Sha      string         `json:"sha"`
	Files    []string       `json:"files"`
	Siblings []ModelSibling `json:"siblings"`
}

type ModelSibling

type ModelSibling struct {
	RFileName string `json:"rfilename"`
}

type Repo

type Repo struct {
	Id       string
	Type     string
	Revision string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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