model

package
v0.2.21 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Finder

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

func New

func New(options ...Option) *Finder

func (*Finder) AddConfig

func (d *Finder) AddConfig(name string, cfg *provider.Config)

AddConfig injects or overwrites a model configuration and bumps version.

func (*Finder) Best

func (d *Finder) Best(p *llm.ModelPreferences) string

func (*Finder) Candidates

func (d *Finder) Candidates() []matcher.Candidate

Candidates returns lightweight view used by matcher.

func (*Finder) DropModel

func (d *Finder) DropModel(name string)

DropModel removes an already instantiated llm.Model instance but keeps its configuration. Next Find() will create a fresh model using the existing config. Useful after model implementation reload without deleting YAML.

func (*Finder) Find

func (d *Finder) Find(ctx context.Context, id string) (llm.Model, error)

func (*Finder) Matcher

func (d *Finder) Matcher() *matcher.Matcher

Matcher builds a matcher instance from current configs.

func (*Finder) Remove

func (d *Finder) Remove(name string)

Remove deletes a model configuration and any instantiated model from the finder caches. It bumps the internal version so hot-swap watchers can detect the change.

func (*Finder) TokenPrices added in v0.2.9

func (d *Finder) TokenPrices(id string) (in float64, out float64, cached float64, ok bool)

TokenPrices returns per-1k token prices for the specified model ID when available in the model configuration. Returns ok=false when no config exists or prices are not set.

func (*Finder) Version

func (d *Finder) Version() int64

Version returns monotonically increasing value changed on Add/Remove.

type Option

type Option func(dao *Finder)

Option defines a functional option for Finder

func WithConfigLoader

func WithConfigLoader(loader modelprovider.ConfigLoader) Option

WithConfigLoader sets a custom configuration loader for the Finder instance.

func WithInitial

func WithInitial(configs ...*modelprovider.Config) Option

WithInitial adds model configurations to the Finder instance.

Jump to

Keyboard shortcuts

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