graph

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package graph is the SDK's internal catalog-discovery graph: a denormalized, cross-linked view of the embedded catalog (models, the hosts that serve them, and the providers that author them) built once from sdk/catalog.

It is internal on purpose. Consumers reach it only through the public sdk/model, sdk/host, and sdk/provider packages, which re-export these types by alias and expose a Resolve entry point each. Keeping the graph here lets the three public packages cross-link (Model→Host, Host→Model, Model→Provider) without importing each other — which would be a cycle.

JSON note: a Model nests its Author and Hosts one level deep, but every back-reference (Provider.Models, Host.Models) is a slug string, never a pointer — so any node marshals to JSON without a cycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capabilities

type Capabilities struct {
	Chat              bool `json:"chat,omitempty"`
	Embeddings        bool `json:"embeddings,omitempty"`
	Streaming         bool `json:"streaming,omitempty"`
	Tools             bool `json:"tools,omitempty"`
	ParallelTools     bool `json:"parallelTools,omitempty"`
	Vision            bool `json:"vision,omitempty"`
	Audio             bool `json:"audio,omitempty"`
	PromptCache       bool `json:"promptCache,omitempty"`
	Reasoning         bool `json:"reasoning,omitempty"`
	JSONMode          bool `json:"jsonMode,omitempty"`
	StructuredOutputs bool `json:"structuredOutputs,omitempty"`
	Batch             bool `json:"batch,omitempty"`
	ComputerUse       bool `json:"computerUse,omitempty"`
	WebSearch         bool `json:"webSearch,omitempty"`
	FileInput         bool `json:"fileInput,omitempty"`
	AudioInput        bool `json:"audioInput,omitempty"`
	AudioOutput       bool `json:"audioOutput,omitempty"`
	SystemMessages    bool `json:"systemMessages,omitempty"`
	AssistantPrefill  bool `json:"assistantPrefill,omitempty"`
}

Capabilities mirrors catalog.Capabilities field-for-field (convertible).

type ContextWindow

type ContextWindow struct {
	Input  int `json:"input,omitempty"`
	Output int `json:"output,omitempty"`
	Total  int `json:"total,omitempty"`
}

ContextWindow is the model's token-window split.

type Graph

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

Graph is the built, cross-linked catalog. Resolution reuses the catalog engine (ic) for ref matching, then maps the matched slug to its node.

func Build

func Build(ic *catalog.IndexedCatalog) *Graph

Build constructs the graph from a loaded catalog.

func Load

func Load() (*Graph, error)

Load builds (once) the graph from the embedded catalog and caches it.

func (*Graph) ResolveHost

func (g *Graph) ResolveHost(ref string) (*Host, error)

ResolveHost returns the host node by name.

func (*Graph) ResolveModel

func (g *Graph) ResolveModel(ref string) (*Model, error)

ResolveModel returns the model node for a ref, aggregating every host that serves it. Ref forms match the catalog engine (bare slug, provider/model, wire name, alias). Cross-host matches are not ambiguous — they are one model.

func (*Graph) ResolveProvider

func (g *Graph) ResolveProvider(ref string) (*Provider, error)

ResolveProvider returns the provider (author) node by name.

type Host

type Host struct {
	Name          string   `json:"name"`
	DisplayName   string   `json:"displayName,omitempty"`
	Description   string   `json:"description,omitempty"`
	BaseURL       string   `json:"baseURL"`
	HomepageURL   string   `json:"homepageURL,omitempty"`
	DocsURL       string   `json:"docsURL,omitempty"`
	ConsoleURL    string   `json:"consoleURL,omitempty"`
	StatusPageURL string   `json:"statusPageURL,omitempty"`
	Icon          string   `json:"icon,omitempty"`
	Models        []string `json:"models,omitempty"`
}

Host is a serving endpoint. Models lists the slugs it serves.

func ResolveHost

func ResolveHost(ref string) (*Host, error)

type Modalities

type Modalities struct {
	Input  []string `json:"input,omitempty"`
	Output []string `json:"output,omitempty"`
}

Modalities mirrors catalog.Modalities (convertible).

type Model

type Model struct {
	Name        string `json:"name"`
	Slug        string `json:"slug"`
	DisplayName string `json:"displayName,omitempty"`
	Description string `json:"description,omitempty"`
	Family      string `json:"family,omitempty"`
	Version     string `json:"version,omitempty"`

	Capabilities  Capabilities  `json:"capabilities,omitempty"`
	Modalities    Modalities    `json:"modalities,omitempty"`
	ContextWindow ContextWindow `json:"contextWindow,omitempty"`

	MaxOutputTokens int      `json:"maxOutputTokens,omitempty"`
	KnowledgeCutoff string   `json:"knowledgeCutoff,omitempty"`
	ReleaseDate     string   `json:"releaseDate,omitempty"`
	License         string   `json:"license,omitempty"`
	Tags            []string `json:"tags,omitempty"`
	Featured        bool     `json:"featured,omitempty"`
	Aliases         []string `json:"aliases,omitempty"`

	Author *Provider   `json:"author,omitempty"`
	Hosts  []ModelHost `json:"hosts,omitempty"`
}

Model is the discovery node: the model plus its author and the hosts serving it. Name is the real provider wire name; Slug is our catalog metadata name.

func ResolveModel

func ResolveModel(ref string) (*Model, error)

type ModelHost

type ModelHost struct {
	Host    *Host  `json:"host"`
	Adapter string `json:"adapter,omitempty"`
	Pricing []Rate `json:"pricing,omitempty"`
}

ModelHost is one place a model is served: the host node plus the per-host serving terms (wire adapter + pricing) that live on the (model, host) edge.

type Provider

type Provider struct {
	Name          string   `json:"name"`
	DisplayName   string   `json:"displayName,omitempty"`
	Description   string   `json:"description,omitempty"`
	HomepageURL   string   `json:"homepageURL,omitempty"`
	DocsURL       string   `json:"docsURL,omitempty"`
	StatusPageURL string   `json:"statusPageURL,omitempty"`
	Icon          string   `json:"icon,omitempty"`
	Models        []string `json:"models,omitempty"`
}

Provider is a model author (the vendor). Models lists the slugs it authors.

func ResolveProvider

func ResolveProvider(ref string) (*Provider, error)

type Rate

type Rate struct {
	Meter       string  `json:"meter"`
	Unit        string  `json:"unit"`
	Amount      float64 `json:"amount"`
	AboveTokens int     `json:"aboveTokens,omitempty"`
}

Rate is one priced meter (mirror of catalog.Rate; convertible field-for-field).

Jump to

Keyboard shortcuts

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