embed

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 13 Imported by: 1 module, 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 embed flattens catalog kinds into the SDK catalog document (sdk/catalog): from a parsed catalog tree (Compose) or from any Source, such as relay's live snapshot (Flatten). It imports nothing from app/ or internal/, so the catalog tools build without the relay server.

Index

Constants

This section is empty.

Variables

View Source
var SDKAdapters = map[string]struct{}{
	"openai":           {},
	"openai_responses": {},
	"anthropic":        {},
	"gemini":           {},
}

SDKAdapters is the adapter-name set the public SDK client supports today.

Functions

func Compose

func Compose(docs []manifest.Document, generatedAt time.Time) (*sdkcatalog.Catalog, error)

Compose translates manifest documents to catalog kinds and flattens them to the SDK embed schema. Cross-refs resolve via minted ids (no Postgres).

func Flatten

func Flatten(snap Source, at time.Time, keep func(*model.Model, *binding.Binding) bool) *sdkcatalog.Catalog

Flatten projects snap into the SDK catalog schema, keeping only the enabled bindings keep accepts; nil keep keeps all. Hosts left without a binding and sidecars for unserved slugs drop out, so a scoped document never names what keep refused.

func MarshalJSON

func MarshalJSON(c *sdkcatalog.Catalog) ([]byte, error)

MarshalJSON encodes c deterministically (sorted hosts and bindings).

func ValidateAdapters

func ValidateAdapters(c *sdkcatalog.Catalog) error

ValidateAdapters returns an error if any binding uses an adapter name outside SDKAdapters.

Types

type Index

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

Index is a Source over plain kind slices. It keeps the rows relay's snapshot build keeps for these kinds, so a tree flattens the same way whether relay seeded it or not: a model whose provider is absent, a pricing whose host is absent or that targets no kept model, and a binding whose model or host is absent all drop out. Disabled rows stay; Flatten skips them.

func NewIndex

func NewIndex(provs []*provider.Provider, hosts []*host.Host, models []*model.Model, pricings []*pricing.Pricing, bindings []*binding.Binding) *Index

NewIndex indexes the rows; a later row wins an id or a (model, host) pricing slot an earlier one also claims. The rows are read, never copied or changed.

func (*Index) BindingsForModel

func (x *Index) BindingsForModel(modelID string) []*binding.Binding

BindingsForModel returns the model's kept bindings sorted by name.

func (*Index) EnabledHosts

func (x *Index) EnabledHosts() []*host.Host

EnabledHosts returns enabled hosts sorted by Meta.Name.

func (*Index) EnabledModels

func (x *Index) EnabledModels() []*model.Model

EnabledModels returns enabled models sorted by Meta.Name.

func (*Index) PricingForBinding

func (x *Index) PricingForBinding(b *binding.Binding) (*pricing.Pricing, bool)

PricingForBinding returns the binding's explicit pricing when it was kept, else the pricing covering the binding's (model, host) pair.

func (*Index) Provider

func (x *Index) Provider(id string) (*provider.Provider, bool)

func (*Index) ProviderSlug

func (x *Index) ProviderSlug(providerID string) (string, bool)

type Source

type Source interface {
	// EnabledHosts and EnabledModels are sorted by Meta.Name.
	EnabledHosts() []*host.Host
	EnabledModels() []*model.Model
	Provider(id string) (*provider.Provider, bool)
	ProviderSlug(providerID string) (string, bool)
	// BindingsForModel is sorted by binding name.
	BindingsForModel(modelID string) []*binding.Binding
	PricingForBinding(b *binding.Binding) (*pricing.Pricing, bool)
}

Source is the catalog read surface Flatten needs. Relay's runtime snapshot implements it; Index builds one from plain kind slices.

Jump to

Keyboard shortcuts

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