Documentation
¶
Index ¶
- Variables
- type AliasTarget
- type Config
- type Factory
- type Provider
- func (p *Provider) CountTokens(ctx context.Context, req tokencount.TokenCountRequest) (*tokencount.TokenCount, error)
- func (p *Provider) CreateStream(ctx context.Context, opts llm.Request) (llm.Stream, error)
- func (p *Provider) Models() llm.Models
- func (p *Provider) Name() string
- func (p *Provider) Resolve(modelID string) (llm.Model, error)
- type ProviderInstanceConfig
Constants ¶
This section is empty.
Variables ¶
var ( // 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") // ErrUnknownModel and ErrNoProviders are re-exported from the llm package // for backwards compatibility with callers that import from this package. ErrUnknownModel = llm.ErrUnknownModel ErrNoProviders = llm.ErrNoProviders )
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 // Router provider name (defaults to "router")
Providers []ProviderInstanceConfig // Named provider instances
Aliases map[string][]AliasTarget // Global alias -> ordered targets
}
Config is the complete aggregate configuration.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is an aggregate provider that routes requests to configured providers.
func New ¶
New creates an aggregate provider from configuration. factories maps provider type keys to constructor functions.
func (*Provider) CountTokens ¶ added in v0.24.0
func (p *Provider) CountTokens(ctx context.Context, req tokencount.TokenCountRequest) (*tokencount.TokenCount, error)
CountTokens implements llm.TokenCounter by delegating to the first resolved target provider for the given model alias or ToolCallID.
The model alias is resolved using the same alias map as CreateStream, and the underlying provider's native model ToolCallID is used for encoding selection. If the resolved provider does not implement llm.TokenCounter, an error is returned.
func (*Provider) CreateStream ¶
CreateStream creates a stream by routing to the appropriate provider. It tries each target in order until one succeeds or all fail.
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.