view

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package view owns the console- and API-facing projections of one routable catalog snapshot. It assembles model, provider, and endpoint DTOs from Starmap facts; transports serialize these shapes without re-deriving catalog data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logo(snapshot *runtimecatalog.RoutableSnapshot, kind LogoKind, id string) (svg []byte, ok bool)

Logo projects the catalog-carried SVG brand mark for one provider or author. ok reports whether the snapshot's catalog carries bytes for this kind and ID; callers fall back to their own asset set when it is false.

Types

type AuthorInfo

type AuthorInfo struct {
	ID           string   `json:"id"`
	Name         string   `json:"name"`
	Description  string   `json:"description,omitempty"`
	Headquarters string   `json:"headquarters,omitempty"`
	IconURL      string   `json:"icon_url,omitempty"`
	Website      string   `json:"website,omitempty"`
	GitHub       string   `json:"github,omitempty"`
	HuggingFace  string   `json:"huggingface,omitempty"`
	Twitter      string   `json:"twitter,omitempty"`
	Models       []string `json:"models"`
}

AuthorInfo represents one catalog author or organization.

func AuthorByID

func AuthorByID(snapshot *runtimecatalog.RoutableSnapshot, id string) (AuthorInfo, bool)

AuthorByID projects one catalog author. The second result reports whether the author exists.

func Authors

func Authors(snapshot *runtimecatalog.RoutableSnapshot) []AuthorInfo

Authors projects every catalog author sorted by ID. A nil snapshot projects to nil.

type CredentialFieldInfo

type CredentialFieldInfo struct {
	ID          string `json:"id"`
	Kind        string `json:"kind"`
	Required    bool   `json:"required"`
	Default     string `json:"default,omitempty"`
	Description string `json:"description,omitempty"`
}

CredentialFieldInfo is the catalog-declared inference credential field a caller supplies for BYOK. It carries no secret values.

type EndpointInfo

type EndpointInfo struct {
	Provider   string `json:"provider"`
	Endpoint   string `json:"endpoint"`
	Available  bool   `json:"available"`
	Latency    *int   `json:"latency_ms,omitempty"`
	CostPrompt string `json:"cost_prompt,omitempty"`
	CostOutput string `json:"cost_output,omitempty"`
}

EndpointInfo represents an endpoint that can serve a model

func Endpoints

func Endpoints(
	snapshot *runtimecatalog.RoutableSnapshot,
	modelID string,
) []EndpointInfo

Endpoints projects every chat-completions endpoint that can serve the model, matched by route id or definition id. The result is empty, not nil, when nothing matches, so the wire shape keeps its array.

type LogoKind

type LogoKind string

LogoKind selects the catalog namespace a logo belongs to.

const (
	// LogoKindProviders selects provider marks.
	LogoKindProviders LogoKind = "providers"
	// LogoKindAuthors selects author marks.
	LogoKindAuthors LogoKind = "authors"
)

type ModelArchitecture

type ModelArchitecture struct {
	InputModalities  []string `json:"input_modalities"`
	OutputModalities []string `json:"output_modalities"`
	Tokenizer        string   `json:"tokenizer"`
	InstructType     *string  `json:"instruct_type"`
}

ModelArchitecture describes protocol-facing model capabilities.

type ModelAuthorInfo

type ModelAuthorInfo struct {
	ID   string `json:"id"`
	Name string `json:"name,omitempty"`
}

ModelAuthorInfo names one catalog author of a model.

type ModelInfo

type ModelInfo struct {
	ID            string `json:"id"`
	CanonicalSlug string `json:"canonical_slug,omitempty"`
	Name          string `json:"name,omitempty"`
	Object        string `json:"object"`
	Created       int64  `json:"created"`
	OwnedBy       string `json:"owned_by"`

	// Extended metadata for OpenRouter compatibility
	Pricing             *ModelPricing      `json:"pricing,omitempty"`
	Context             *int               `json:"context_length,omitempty"`
	Type                string             `json:"type,omitempty"`
	Description         string             `json:"description,omitempty"`
	Architecture        *ModelArchitecture `json:"architecture,omitempty"`
	TopProvider         *TopProviderInfo   `json:"top_provider,omitempty"`
	SupportedParameters []string           `json:"supported_parameters,omitempty"`

	// Definition-level catalog facts
	Authors         []ModelAuthorInfo `json:"authors,omitempty"`
	Tags            []string          `json:"tags,omitempty"`
	Lineage         *ModelLineageInfo `json:"lineage,omitempty"`
	KnowledgeCutoff string            `json:"knowledge_cutoff,omitempty"`
	OpenWeights     *bool             `json:"open_weights,omitempty"`

	// Offerings lists every routable provider offering for this model.
	Offerings []ModelOfferingInfo `json:"offerings,omitempty"`
}

ModelInfo represents model information

func Models

func Models(snapshot *runtimecatalog.RoutableSnapshot) []ModelInfo

Models projects every routable model definition in the snapshot. A nil snapshot projects to nil.

type ModelLineageInfo

type ModelLineageInfo struct {
	Family string `json:"family,omitempty"`
	Root   string `json:"root,omitempty"`
	Parent string `json:"parent,omitempty"`
}

ModelLineageInfo describes canonical model-family relationships.

type ModelOfferingInfo

type ModelOfferingInfo struct {
	Provider            string               `json:"provider"`
	ProviderName        string               `json:"provider_name,omitempty"`
	ProviderModelID     string               `json:"provider_model_id"`
	ContextLength       *int                 `json:"context_length,omitempty"`
	MaxCompletionTokens *int                 `json:"max_completion_tokens,omitempty"`
	Availability        string               `json:"availability,omitempty"`
	Lifecycle           string               `json:"lifecycle,omitempty"`
	Pricing             *OfferingPricingInfo `json:"pricing,omitempty"`
	// MaxDocuments is the longest document list this offering ranks in one
	// request. A rerank caller that sends more gets a refusal, so the bound
	// belongs beside the context window rather than inside the pricing block.
	MaxDocuments *int `json:"max_documents,omitempty"`
	// Operations names what this offering serves, in the catalog's own
	// spelling. A media model reaches a different path than a chat model, so
	// a reader who cannot see the operations cannot tell which path to call.
	Operations []string `json:"operations,omitempty"`
}

ModelOfferingInfo is one provider's routable offering of a model.

type ModelPricing

type ModelPricing struct {
	Prompt     string `json:"prompt"`
	Completion string `json:"completion"`
	Currency   string `json:"currency"`
}

ModelPricing represents model pricing information

type OfferingPricingInfo

type OfferingPricingInfo struct {
	Prompt     string `json:"prompt,omitempty"`
	Completion string `json:"completion,omitempty"`
	Reasoning  string `json:"reasoning,omitempty"`
	CacheRead  string `json:"cache_read,omitempty"`
	CacheWrite string `json:"cache_write,omitempty"`
	// Audio tokens bill at their own rate wherever a provider meters them,
	// so an audio turn cannot be priced from Prompt and Completion alone.
	AudioInput  string `json:"audio_input,omitempty"`
	AudioOutput string `json:"audio_output,omitempty"`
	// PageInput is what one document page costs at this offering. No token
	// price converts into it, so an offering that reads documents and
	// publishes no page price is one a caller cannot price at all.
	PageInput string `json:"page_input,omitempty"`
	// SearchUnit is what one rerank search unit costs at this offering, which
	// is one query against a bounded document count. A rerank provider bills
	// either this or the tokens it reads, so an offering that publishes it
	// may publish no token price at all.
	SearchUnit string `json:"search_unit,omitempty"`
	Currency   string `json:"currency,omitempty"`
}

OfferingPricingInfo carries the published prices of one offering as decimal strings. The token dimensions price one token each. PageInput prices one document page.

type ProviderInfo

type ProviderInfo struct {
	ID               string                `json:"id"`
	Name             string                `json:"name"`
	Description      string                `json:"description,omitempty"`
	DocsURL          string                `json:"docs_url,omitempty"`
	URL              string                `json:"url,omitempty"`
	StatusPageURL    string                `json:"status_page_url,omitempty"`
	Models           []string              `json:"models"`
	Capabilities     []string              `json:"capabilities,omitempty"`
	RequiresAuth     bool                  `json:"requires_auth"`
	AuthDescription  string                `json:"auth_description,omitempty"`
	CredentialFields []CredentialFieldInfo `json:"credential_fields,omitempty"`
	Headquarters     string                `json:"headquarters,omitempty"`
	Policies         *ProviderPolicyInfo   `json:"policies,omitempty"`
}

ProviderInfo represents provider metadata

func Providers

func Providers(
	snapshot *runtimecatalog.RoutableSnapshot,
	requiresAuth func(providerID string) bool,
) []ProviderInfo

Providers projects every provider with a routable offering in the snapshot. requiresAuth reports the gateway's credential requirement for a provider id; it is injected so this package stays free of runtime registry types. A nil snapshot projects to nil.

type ProviderPolicyInfo

type ProviderPolicyInfo struct {
	PrivacyPolicyURL  string `json:"privacy_policy_url,omitempty"`
	TermsOfServiceURL string `json:"terms_of_service_url,omitempty"`
	RetainsData       *bool  `json:"retains_data,omitempty"`
	TrainsOnData      *bool  `json:"trains_on_data,omitempty"`
	Retention         string `json:"retention,omitempty"`
	Moderated         *bool  `json:"moderated,omitempty"`
}

ProviderPolicyInfo summarizes the provider's published data policies.

type TopProviderInfo

type TopProviderInfo struct {
	ContextLength       int `json:"context_length"`
	MaxCompletionTokens int `json:"max_completion_tokens"`
}

TopProviderInfo describes the selected representative offering limits.

Jump to

Keyboard shortcuts

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