metadata

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: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrResponseTooLarge = errors.New("response body exceeded maximum size")

ErrResponseTooLarge is returned by readBoundedBody when the response body exceeds the configured limit. Callers can branch on this to surface a distinct error or fall back to basic metadata, rather than mistaking truncated JSON for a parse failure.

Functions

func ExtractQuantization

func ExtractQuantization(filename string) string

ExtractQuantization extracts quantization info from filename (exported for scanner)

func ParseCivitAIModelID

func ParseCivitAIModelID(url string) (string, error)

ParseModelIDFromURL extracts the model ID from a CivitAI URL

func ParseCivitAIVersionID

func ParseCivitAIVersionID(url string) (int64, error)

GetModelVersionID extracts version ID from download URLs like /api/download/models/{versionId}

Types

type CivitAIFetcher

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

CivitAIFetcher fetches metadata from CivitAI

func NewCivitAIFetcher

func NewCivitAIFetcher(client *http.Client) *CivitAIFetcher

NewCivitAIFetcher creates a new CivitAI metadata fetcher

func (*CivitAIFetcher) CanHandle

func (f *CivitAIFetcher) CanHandle(url string) bool

func (*CivitAIFetcher) CheckConnectivity

func (f *CivitAIFetcher) CheckConnectivity(ctx context.Context) error

CheckConnectivity tests if CivitAI is accessible (useful for VPN detection)

func (*CivitAIFetcher) FetchMetadata

func (f *CivitAIFetcher) FetchMetadata(ctx context.Context, url string) (*state.ModelMetadata, error)

func (*CivitAIFetcher) SetAPIKey

func (f *CivitAIFetcher) SetAPIKey(key string)

SetAPIKey sets the CivitAI API key for authenticated requests

func (*CivitAIFetcher) Source

func (f *CivitAIFetcher) Source() string

func (*CivitAIFetcher) ValidateAPIKey

func (f *CivitAIFetcher) ValidateAPIKey(ctx context.Context, apiKey string) error

ValidateAPIKey checks if the provided API key is valid

type Fetcher

type Fetcher interface {
	// CanHandle returns true if this fetcher can handle the given URL
	CanHandle(url string) bool

	// FetchMetadata retrieves metadata for the given URL
	FetchMetadata(ctx context.Context, url string) (*state.ModelMetadata, error)

	// Source returns the name of this metadata source
	Source() string
}

Fetcher is the interface for fetching model metadata from various sources

type HuggingFaceFetcher

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

HuggingFaceFetcher fetches metadata from HuggingFace

func NewHuggingFaceFetcher

func NewHuggingFaceFetcher(client *http.Client) *HuggingFaceFetcher

NewHuggingFaceFetcher creates a new HuggingFace metadata fetcher

func (*HuggingFaceFetcher) CanHandle

func (f *HuggingFaceFetcher) CanHandle(url string) bool

func (*HuggingFaceFetcher) FetchMetadata

func (f *HuggingFaceFetcher) FetchMetadata(ctx context.Context, url string) (*state.ModelMetadata, error)

func (*HuggingFaceFetcher) Source

func (f *HuggingFaceFetcher) Source() string

type ModelScopeFetcher added in v0.7.1

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

func NewModelScopeFetcher added in v0.7.1

func NewModelScopeFetcher(client *http.Client) *ModelScopeFetcher

func (*ModelScopeFetcher) CanHandle added in v0.7.1

func (f *ModelScopeFetcher) CanHandle(rawURL string) bool

func (*ModelScopeFetcher) FetchMetadata added in v0.7.1

func (f *ModelScopeFetcher) FetchMetadata(ctx context.Context, rawURL string) (*state.ModelMetadata, error)

func (*ModelScopeFetcher) Source added in v0.7.1

func (f *ModelScopeFetcher) Source() string

type OllamaFetcher added in v0.7.1

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

func NewOllamaFetcher added in v0.7.1

func NewOllamaFetcher(client *http.Client) *OllamaFetcher

func (*OllamaFetcher) CanHandle added in v0.7.1

func (f *OllamaFetcher) CanHandle(rawURL string) bool

func (*OllamaFetcher) FetchMetadata added in v0.7.1

func (f *OllamaFetcher) FetchMetadata(ctx context.Context, rawURL string) (*state.ModelMetadata, error)

func (*OllamaFetcher) Source added in v0.7.1

func (f *OllamaFetcher) Source() string

type Registry

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

Registry holds all available metadata fetchers

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new fetcher registry with default fetchers

func (*Registry) CanHandle

func (r *Registry) CanHandle(url string) bool

CanHandle returns true if any registered fetcher can handle the given URL

func (*Registry) FetchMetadata

func (r *Registry) FetchMetadata(ctx context.Context, url string) (*state.ModelMetadata, error)

FetchMetadata attempts to fetch metadata using the appropriate fetcher

func (*Registry) Register

func (r *Registry) Register(f Fetcher)

Register adds a fetcher to the registry

Jump to

Keyboard shortcuts

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