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 ¶
- Variables
- func Compose(docs []manifest.Document, generatedAt time.Time) (*sdkcatalog.Catalog, error)
- func Flatten(snap Source, at time.Time, keep func(*model.Model, *binding.Binding) bool) *sdkcatalog.Catalog
- func MarshalJSON(c *sdkcatalog.Catalog) ([]byte, error)
- func ValidateAdapters(c *sdkcatalog.Catalog) error
- type Index
- func (x *Index) BindingsForModel(modelID string) []*binding.Binding
- func (x *Index) EnabledHosts() []*host.Host
- func (x *Index) EnabledModels() []*model.Model
- func (x *Index) PricingForBinding(b *binding.Binding) (*pricing.Pricing, bool)
- func (x *Index) Provider(id string) (*provider.Provider, bool)
- func (x *Index) ProviderSlug(providerID string) (string, bool)
- type Source
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
BindingsForModel returns the model's kept bindings sorted by name.
func (*Index) EnabledHosts ¶
EnabledHosts returns enabled hosts sorted by Meta.Name.
func (*Index) EnabledModels ¶
EnabledModels returns enabled models sorted by Meta.Name.
func (*Index) PricingForBinding ¶
PricingForBinding returns the binding's explicit pricing when it was kept, else the pricing covering the binding's (model, host) pair.
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.