alias

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package alias holds remora's model aliases and compiles them into a flat chain of provider targets.

Index

Constants

View Source
const DefaultMaxDepth = 5

DefaultMaxDepth is the nesting limit used when Compile is given maxDepth <= 0.

Variables

View Source
var (
	ErrCycle         = errors.New("alias: cycle")
	ErrDepth         = errors.New("alias: nesting too deep")
	ErrUnknownMember = errors.New("alias: unknown member")
	ErrEmpty         = errors.New("alias: no members")
)

Compile errors. Returned errors wrap one of these and name the alias path.

View Source
var ErrInvalidName = errors.New("alias: invalid name")

ErrInvalidName means an alias name does not match the allowed pattern.

Functions

func EngineModel added in v0.1.3

func EngineModel(name string) string

EngineModel is the model remora sends the front door for an alias. The front door reads "<provider>/<model>" as a direct provider model whenever the prefix names one of its providers, so "openai/fast" would never reach its routing rule; behind the prefix the whole alias stays one model name.

func ValidName

func ValidName(name string) error

ValidName reports whether name may be used as an alias name: ^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$. A name may look like a provider model ("openai/fast"): the front door only ever sees EngineModel(name).

Types

type Alias

type Alias struct {
	Name          string
	Kind          Kind
	Members       []Member
	Capabilities  []string // advertised supported_parameters, e.g. "structured_outputs", "tools"
	ContextWindow int      // 0 = unset
	Strategy      Strategy // how the alias's own compiled chain is used; a nested alias is flattened in order
}

Alias is a named, ordered list of members that clients call as a model.

type Kind

type Kind string

Kind is the kind of request an alias serves.

const (
	KindChat          Kind = "chat"
	KindEmbeddings    Kind = "embeddings"
	KindTranscription Kind = "transcription"
	KindDecisions     Kind = "decisions"
)

Alias kinds.

type Member

type Member struct{ Ref string }

Member is one entry of an alias: an alias name, or "<provider>/<model>".

type Strategy added in v0.2.0

type Strategy string

Strategy is how an alias picks the first member a request tries.

const (
	// StrategyFallback tries the members in order: the default, written as no strategy.
	StrategyFallback Strategy = ""
	// StrategyRoundRobin spreads requests over the members, each picked at random with equal weight, and falls back
	// through the members in order when the picked one fails.
	StrategyRoundRobin Strategy = "round-robin"
)

Alias strategies.

func (Strategy) Valid added in v0.2.0

func (s Strategy) Valid() bool

Valid reports whether s is one of the alias strategies.

type Target

type Target struct{ Provider, Model string }

Target is a provider model an alias resolves to.

func Compile

func Compile(all map[string]Alias, name string, maxDepth int) ([]Target, error)

Compile expands the alias name into a flat, ordered chain of provider targets. Nested aliases are expanded depth first in member order, and a target already in the chain is dropped. A member ref is an alias when all has that key, otherwise "<provider>/<model>" split at the first "/". The named alias is depth 1; maxDepth <= 0 means DefaultMaxDepth.

Jump to

Keyboard shortcuts

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