resolver

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CivitaiBaseForTest

func CivitaiBaseForTest() string

CivitaiBaseForTest returns the current base for tests.

func ClearCache

func ClearCache(cfg *config.Config) error

ClearCache removes all resolver cache entries.

func SetCivitaiBaseForTest

func SetCivitaiBaseForTest(u string)

SetCivitaiBaseForTest overrides the base URL for CivitAI API (tests only).

Types

type CivitAI

type CivitAI struct{}

func (*CivitAI) CanHandle

func (c *CivitAI) CanHandle(u string) bool

func (*CivitAI) Resolve

func (c *CivitAI) Resolve(ctx context.Context, uri string, cfg *config.Config) (*Resolved, error)

civitai://model/{id}?version={versionId}&file={substring}

type HuggingFace

type HuggingFace struct{}

func (*HuggingFace) CanHandle

func (h *HuggingFace) CanHandle(u string) bool

Accepts URIs of the form:

hf://{owner}/{repo}/{path}?rev=main&quant={quantization}

If rev is omitted, defaults to "main". If quant is specified, selects that specific quantization variant. If path points to a directory or is omitted, will list and detect quantizations.

func (*HuggingFace) Resolve

func (h *HuggingFace) Resolve(ctx context.Context, uri string, cfg *config.Config) (*Resolved, error)

type Quantization added in v0.6.1

type Quantization struct {
	Name     string // Detected quantization (e.g., "Q4_K_M", "fp16", "Q5_0")
	FilePath string // Path in repository
	Size     int64  // File size in bytes
	FileType string // File extension type (e.g., "gguf", "safetensors", "bin")
}

Quantization represents a specific quantization variant of a model file.

type Resolved

type Resolved struct {
	URL     string
	Headers map[string]string
	// Optional metadata (primarily for CivitAI) — may be empty for other resolvers
	ModelName         string
	VersionName       string
	VersionID         string
	FileName          string
	FileType          string // Source-specific type (e.g., CivitAI file.type: Model|VAE|TextualInversion)
	SuggestedFilename string
	// Optional metadata for Hugging Face
	RepoOwner string
	RepoName  string
	RepoPath  string
	Rev       string
	// Quantization support (HuggingFace)
	AvailableQuantizations []Quantization // List of detected quantization variants
	SelectedQuantization   string         // Which quantization was selected (if any)
}

func Resolve

func Resolve(ctx context.Context, uri string, cfg *config.Config) (*Resolved, error)

type Resolver

type Resolver interface {
	CanHandle(uri string) bool
	Resolve(ctx context.Context, uri string, cfg *config.Config) (*Resolved, error)
}

Jump to

Keyboard shortcuts

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