resolver

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 17 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 Register added in v0.6.2

func Register(r Resolver) func()

Register adds a resolver ahead of the built-in resolvers and returns an unregister function for tests or plugin lifecycle cleanup.

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)
}

type Starter added in v0.7.1

type Starter struct{}

Starter maps beginner-friendly starter:// IDs onto the normal resolver stack.

func (Starter) CanHandle added in v0.7.1

func (Starter) CanHandle(uri string) bool

func (Starter) Resolve added in v0.7.1

func (Starter) 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