modelregistry

package
v0.14.30 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveSources

func ActiveSources(cfg *config.Config) []discoverycache.Source

ActiveSources returns the cache sources that are currently configured and should be preserved by cache garbage collection.

Types

type AssembleOptions

type AssembleOptions struct {
	Refresh RefreshMode
}

AssembleOptions controls snapshot assembly behavior.

type KnownModel

type KnownModel struct {
	Provider     string `json:"provider,omitempty"`
	ProviderType string `json:"provider_type,omitempty"`
	Harness      string `json:"harness,omitempty"`
	ID           string `json:"model,omitempty"`
	Configured   bool   `json:"configured,omitempty"`

	EndpointName     string                    `json:"endpoint_name,omitempty"`
	EndpointBaseURL  string                    `json:"endpoint_base_url,omitempty"`
	ServerInstance   string                    `json:"server_instance,omitempty"`
	Billing          modelcatalog.BillingModel `json:"billing,omitempty"`
	IncludeByDefault bool                      `json:"include_by_default,omitempty"`

	DiscoveredVia Source    `json:"model_discovery_freshness_source,omitempty"`
	DiscoveredAt  time.Time `json:"model_discovery_freshness_at,omitempty"`

	Family     string            `json:"family,omitempty"`
	Version    []int             `json:"version,omitempty"`
	Tier       modelcatalog.Tier `json:"tier,omitempty"`
	PreRelease bool              `json:"pre_release,omitempty"`

	Power            int           `json:"power,omitempty"`
	CostInputPerM    float64       `json:"cost_input_per_m,omitempty"`
	CostOutputPerM   float64       `json:"cost_output_per_m,omitempty"`
	ContextWindow    int           `json:"context_window,omitempty"`
	ReasoningLevels  []string      `json:"reasoning_levels,omitempty"`
	QuotaPool        string        `json:"quota_pool,omitempty"`
	QuotaRemaining   *int          `json:"quota_remaining,omitempty"`
	RecentP50Latency time.Duration `json:"recent_p50_latency_ns,omitempty"`

	Status                ModelStatus `json:"status,omitempty"`
	HealthFreshnessAt     time.Time   `json:"health_freshness_at,omitempty"`
	HealthFreshnessSource string      `json:"health_freshness_source,omitempty"`
	QuotaFreshnessAt      time.Time   `json:"quota_freshness_at,omitempty"`
	QuotaFreshnessSource  string      `json:"quota_freshness_source,omitempty"`
	ActualCashSpend       bool        `json:"actual_cash_spend"`
	EffectiveCost         float64     `json:"effective_cost"`
	EffectiveCostSource   string      `json:"effective_cost_source,omitempty"`
	SupportsTools         bool        `json:"supports_tools,omitempty"`
	DeploymentClass       string      `json:"deployment_class,omitempty"`

	AutoRoutable    bool   `json:"auto_routable,omitempty"`
	ExactPinOnly    bool   `json:"exact_pin_only,omitempty"`
	ExclusionReason string `json:"exclusion_reason,omitempty"`
}

KnownModel is one discovered provider/model identity enriched with catalog metadata when the catalog knows the model.

func EnrichModel

func EnrichModel(model KnownModel, includeByDefault bool, cat *modelcatalog.Catalog) KnownModel

type ModelSnapshot

type ModelSnapshot struct {
	Models  []KnownModel          `json:"models,omitempty"`
	AsOf    time.Time             `json:"as_of,omitempty"`
	Sources map[string]SourceMeta `json:"sources,omitempty"`
}

ModelSnapshot is the in-memory model registry view assembled from discovery cache entries and catalog metadata.

func Assemble

Assemble builds a ModelSnapshot from configured providers, cache-backed discovery, runtime status cache state, and model catalog metadata.

func AssembleWithOptions

func AssembleWithOptions(ctx context.Context, cfg *config.Config, cat *modelcatalog.Catalog, cache *discoverycache.Cache, opts AssembleOptions) (ModelSnapshot, error)

AssembleWithOptions builds a ModelSnapshot with explicit cache refresh behavior for CLI and routing consumers.

func RefreshModels added in v0.12.3

func RefreshModels(ctx context.Context, cfg *config.Config, cat *modelcatalog.Catalog, cache *discoverycache.Cache, scope RefreshScope) (ModelSnapshot, error)

RefreshModels synchronously rebuilds the snapshot after refreshing stale cache-backed fields through the coordinated refresh path.

func Warmup added in v0.12.3

Warmup is the public synchronous refresh entrypoint for callers that want to keep the assembled snapshot fresh from a heartbeat.

type ModelStatus

type ModelStatus string

ModelStatus records the provider runtime state relevant to routing.

const (
	StatusAvailable   ModelStatus = "available"
	StatusRateLimited ModelStatus = "rate_limited"
	StatusUnreachable ModelStatus = "unreachable"
	StatusUnknown     ModelStatus = "unknown"
)

type RefreshMode

type RefreshMode int

RefreshMode controls whether Assemble refreshes stale source cache data.

const (
	// RefreshBackground preserves the default stale-while-revalidate behavior:
	// return cached data immediately and refresh stale sources in the background.
	RefreshBackground RefreshMode = iota
	// RefreshNone returns cached data only.
	RefreshNone
	// RefreshForce refreshes sources synchronously before reading them.
	RefreshForce
	// RefreshIfStale refreshes ONLY stale sources synchronously; fresh sources
	// short-circuit on the cached entry. Reserve this for explicit refresh or
	// preflight surfaces; request routing uses RefreshBackground so stale
	// providers cannot block candidate scoring.
	RefreshIfStale
)

type RefreshScope added in v0.12.3

type RefreshScope string

RefreshScope names the synchronous snapshot refresh scopes exposed to long-running callers.

const (
	RefreshRouting RefreshScope = "routing"
	RefreshAll     RefreshScope = "all"
)

type Source

type Source string

Source records how a model ID was discovered.

const (
	SourceNativeAPI  Source = "native_api"
	SourceHarnessPTY Source = "harness_pty"
	SourcePropsAPI   Source = "props_api"
)

type SourceMeta

type SourceMeta struct {
	LastRefreshedAt time.Time `json:"last_refreshed_at,omitempty"`
	Stale           bool      `json:"stale,omitempty"`
	Error           string    `json:"error,omitempty"`
}

SourceMeta summarizes cache state for a discovery source.

Jump to

Keyboard shortcuts

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