enhancer

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2025 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package enhancer provides functionality to enrich model data with metadata from external sources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainEnhancer

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

ChainEnhancer allows chaining multiple enhancers with custom logic.

func NewChainEnhancer

func NewChainEnhancer(priority int, enhancers ...Enhancer) *ChainEnhancer

NewChainEnhancer creates a new chain enhancer.

func (*ChainEnhancer) Batch

func (e *ChainEnhancer) Batch(ctx context.Context, models []*catalogs.Model) ([]*catalogs.Model, error)

Batch enhances multiple models.

func (*ChainEnhancer) CanEnhance

func (e *ChainEnhancer) CanEnhance(model *catalogs.Model) bool

CanEnhance checks if any enhancer in the chain can enhance.

func (*ChainEnhancer) Enhance

func (e *ChainEnhancer) Enhance(ctx context.Context, model *catalogs.Model) (*catalogs.Model, error)

Enhance applies all enhancers in sequence.

func (*ChainEnhancer) Name

func (e *ChainEnhancer) Name() string

Name returns the enhancer name.

func (*ChainEnhancer) Priority

func (e *ChainEnhancer) Priority() int

Priority returns the priority.

type Enhancer

type Enhancer interface {
	// Name returns the enhancer name
	Name() string

	// Enhance enhances a single model with additional data
	Enhance(ctx context.Context, model *catalogs.Model) (*catalogs.Model, error)

	// EnhanceBatch enhances multiple models efficiently
	EnhanceBatch(ctx context.Context, models []*catalogs.Model) ([]*catalogs.Model, error)

	// CanEnhance checks if this enhancer can enhance a specific model
	CanEnhance(model *catalogs.Model) bool

	// Priority returns the priority of this enhancer (higher = applied first)
	Priority() int
}

Enhancer defines the interface for model enrichment.

type MetadataEnhancer

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

MetadataEnhancer adds metadata from various sources.

func NewMetadataEnhancer

func NewMetadataEnhancer(priority int) *MetadataEnhancer

NewMetadataEnhancer creates a new metadata enhancer.

func (*MetadataEnhancer) CanEnhance

func (e *MetadataEnhancer) CanEnhance(model catalogs.Model) bool

CanEnhance checks if this enhancer can enhance a model.

func (*MetadataEnhancer) Enhance

Enhance enhances a single model.

func (*MetadataEnhancer) EnhanceBatch

func (e *MetadataEnhancer) EnhanceBatch(ctx context.Context, models []catalogs.Model) ([]catalogs.Model, error)

EnhanceBatch enhances multiple models.

func (*MetadataEnhancer) Name

func (e *MetadataEnhancer) Name() string

Name returns the enhancer name.

func (*MetadataEnhancer) Priority

func (e *MetadataEnhancer) Priority() int

Priority returns the priority.

type ModelsDevEnhancer

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

ModelsDevEnhancer enhances models with models.dev data.

func NewModelsDevEnhancer

func NewModelsDevEnhancer(priority int) *ModelsDevEnhancer

NewModelsDevEnhancer creates a new models.dev enhancer.

func (*ModelsDevEnhancer) CanEnhance

func (e *ModelsDevEnhancer) CanEnhance(model catalogs.Model) bool

CanEnhance checks if this enhancer can enhance a model.

func (*ModelsDevEnhancer) Enhance

Enhance enhances a single model.

func (*ModelsDevEnhancer) EnhanceBatch

func (e *ModelsDevEnhancer) EnhanceBatch(ctx context.Context, models []catalogs.Model) ([]catalogs.Model, error)

EnhanceBatch enhances multiple models.

func (*ModelsDevEnhancer) Name

func (e *ModelsDevEnhancer) Name() string

Name returns the enhancer name.

func (*ModelsDevEnhancer) Priority

func (e *ModelsDevEnhancer) Priority() int

Priority returns the priority.

type Pipeline

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

Pipeline manages a chain of enhancers.

func NewPipeline

func NewPipeline(enhancers ...Enhancer) *Pipeline

NewPipeline creates a new enhancer pipeline.

func (*Pipeline) Batch

func (p *Pipeline) Batch(ctx context.Context, models []*catalogs.Model) ([]*catalogs.Model, error)

Batch applies all enhancers to multiple models.

func (*Pipeline) Enhance

func (p *Pipeline) Enhance(ctx context.Context, model *catalogs.Model) (*catalogs.Model, error)

Enhance applies all enhancers to a single model.

func (*Pipeline) WithProvenance

func (p *Pipeline) WithProvenance(tracker provenance.Tracker) *Pipeline

WithProvenance enables provenance tracking for enhancements.

Jump to

Keyboard shortcuts

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