aggregate

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownModel is returned when a model ID or alias is not found.
	ErrUnknownModel = errors.New("unknown model")
	// ErrNoProviders is returned when no providers are configured.
	ErrNoProviders = errors.New("no providers configured")
	// ErrProviderNotFound is returned when a referenced provider is not found.
	ErrProviderNotFound = errors.New("provider not found")
	// ErrAmbiguousModel is returned when a short model ID matches multiple providers.
	ErrAmbiguousModel = errors.New("ambiguous model ID")
)

Functions

This section is empty.

Types

type AliasTarget

type AliasTarget struct {
	Provider string // Provider instance name
	Model    string // Model ID or local alias for that provider
}

AliasTarget points to a provider instance and model.

type Config

type Config struct {
	Name      string                   // Aggregate provider name (defaults to "aggregate")
	Providers []ProviderInstanceConfig // Named provider instances
	Aliases   map[string][]AliasTarget // Global alias -> ordered targets
}

Config is the complete aggregate configuration.

type Factory

type Factory func(opts ...llm.Option) llm.Provider

Factory creates a provider instance from options.

type Provider

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

Provider is an aggregate provider that routes requests to configured providers.

func New

func New(cfg Config, factories map[string]Factory) (*Provider, error)

New creates an aggregate provider from configuration. factories maps provider type keys to constructor functions.

func (*Provider) CreateStream

func (p *Provider) CreateStream(ctx context.Context, opts llm.StreamOptions) (<-chan llm.StreamEvent, error)

CreateStream creates a stream by routing to the appropriate provider. It tries each target in order until one succeeds or all fail.

func (*Provider) Models

func (p *Provider) Models() []llm.Model

Models returns all models with their aliases.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the aggregate provider name.

func (*Provider) Resolve

func (p *Provider) Resolve(modelID string) (llm.Model, error)

Resolve implements llm.Resolver.

type ProviderInstanceConfig

type ProviderInstanceConfig struct {
	Name         string            // Unique instance name
	Type         string            // Provider type key (passed to factory)
	Options      []llm.Option      // Options passed to factory
	ModelAliases map[string]string // Local aliases: "sonnet" -> "claude-sonnet-4-5"
}

ProviderInstanceConfig configures a single provider instance.

Jump to

Keyboard shortcuts

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