routing

package
v1.13.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mode

type Mode string

Mode represents an operating mode that controls cost/quality trade-offs.

const (
	ModeQuick    Mode = "quick"
	ModeBalanced Mode = "balanced"
	ModeThorough Mode = "thorough"
)

func ParseMode

func ParseMode(s string) (Mode, bool)

ParseMode converts a string to a Mode, returning the mode and whether the string was a valid mode name.

type ProviderStats

type ProviderStats struct {
	ProviderID      string
	AvgLatencyMS    float64
	ErrorRate       float64
	TotalSuccessful int
	AcceptRate      float64 // user feedback: fraction of accepted tool calls
	FeedbackCount   int     // total feedback events
}

ProviderStats holds aggregated telemetry statistics for a single provider.

type Router

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

Router selects providers based on telemetry-derived heuristic scores.

func NewRouter

func NewRouter(telemetryPath string) *Router

NewRouter creates a Router that reads telemetry data from the given path.

func (*Router) LoadTelemetryStats

func (r *Router) LoadTelemetryStats() error

LoadTelemetryStats reads the telemetry JSONL file and aggregates per-provider statistics (average latency, error rate, total successful queries).

func (*Router) ScoreProvider

func (r *Router) ScoreProvider(stats ProviderStats) float64

ScoreProvider computes a heuristic score for a provider based on its stats. Higher scores indicate better providers. Providers with zero history receive a neutral score of 1.0. The score factors in latency, error rate, volume, and user acceptance rate from feedback signals.

func (*Router) SelectProviders

func (r *Router) SelectProviders(mode Mode, allHealthy []provider.Provider, primaryID string) []provider.Provider

SelectProviders returns all healthy providers regardless of mode. The mode now controls synthesis depth, not provider selection.

func (*Router) SelectProvidersWithReason added in v1.10.0

func (r *Router) SelectProvidersWithReason(mode Mode, allHealthy []provider.Provider, primaryID string) ([]provider.Provider, string)

SelectProvidersWithReason returns all healthy providers along with a human-readable explanation. All modes query all providers — the mode controls synthesis depth (quick=concise, balanced=structured, thorough=deep).

Jump to

Keyboard shortcuts

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