model

package
v0.2.68 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: Apache-2.0 Imports: 12 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) BestWithFilter added in v0.2.25

func (d *Finder) BestWithFilter(p *llm.ModelPreferences, allow func(id string) bool) string

BestWithFilter selects the best model after reducing candidates using allow. When the filter excludes all candidates, it falls back to the full set.

func (*Finder) Candidates

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

Candidates returns lightweight view used by matcher.

func (*Finder) ConfigByIDOrModel added in v0.2.28

func (d *Finder) ConfigByIDOrModel(id string) *provider.Config

ConfigByIDOrModel returns the provider config matching the given identifier. It first attempts a direct lookup by config ID. If not found, it scans all configs to find a match either by config ID or by the provider model name stored in Options.Model. Returns nil when no matching config exists.

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