model

package
v0.11.5 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 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 model is the domain layer for the Model entity — a container for a family of dated checkpoints (Snapshots). Meta.Name is the admin / catalog slug; customers address the model by sending a Snapshot.Name in the request body. Snapshot.Pointer names the default snapshot displayed in /v1/models.

Host serving info (which Hosts can serve this Model) lives in standalone HostBinding entities (app/binding), not embedded in the Model spec.

Pricing and RateLimit attachments are deferred until those packages land.

Index

Constants

This section is empty.

Variables

View Source
var ReasoningEffortLevels = []string{"none", "minimal", "low", "medium", "high", "xhigh", "max"}

ReasoningEffortLevels is the canonical effort set, ordered low→high.

Functions

func AliasPattern added in v0.3.0

func AliasPattern(alias string) (prefix, suffix string, ok bool)

AliasPattern reports whether alias is a wildcard pattern and, when it is, returns the slug-normalized literal prefix and suffix used for boundary-accurate matching against From-normalized lookup keys.

Types

type Capabilities

type Capabilities struct {
	// UnsupportedParams lists request parameters (canonical sampling names:
	// "temperature", "top_p", "top_k") the upstream rejects for this model.
	// Inverted so the zero value means "everything supported" — only flagged
	// models carry it. The pipeline strips listed params pre-upstream and
	// surfaces the drop; unknown names are inert, so catalog data may flag
	// params an older relay doesn't yet gate.
	UnsupportedParams []string `json:"unsupportedParams,omitempty" yaml:"unsupportedParams,omitempty"`
	Chat              bool     `json:"chat,omitempty"              yaml:"chat,omitempty"`
	Embeddings        bool     `json:"embeddings,omitempty"        yaml:"embeddings,omitempty"`
	Streaming         bool     `json:"streaming,omitempty"         yaml:"streaming,omitempty"`
	Tools             bool     `json:"tools,omitempty"             yaml:"tools,omitempty"`
	ParallelTools     bool     `json:"parallelTools,omitempty"     yaml:"parallelTools,omitempty"`
	Vision            bool     `json:"vision,omitempty"            yaml:"vision,omitempty"`
	Audio             bool     `json:"audio,omitempty"             yaml:"audio,omitempty"`
	PromptCache       bool     `json:"promptCache,omitempty"       yaml:"promptCache,omitempty"`
	Reasoning         bool     `json:"reasoning,omitempty"         yaml:"reasoning,omitempty"`
	JSONMode          bool     `json:"jsonMode,omitempty"          yaml:"jsonMode,omitempty"`
	StructuredOutputs bool     `json:"structuredOutputs,omitempty" yaml:"structuredOutputs,omitempty"`
	Batch             bool     `json:"batch,omitempty"             yaml:"batch,omitempty"`
	ComputerUse       bool     `json:"computerUse,omitempty"       yaml:"computerUse,omitempty"`
	WebSearch         bool     `json:"webSearch,omitempty"         yaml:"webSearch,omitempty"`
	FileInput         bool     `json:"fileInput,omitempty"         yaml:"fileInput,omitempty"`
	AudioInput        bool     `json:"audioInput,omitempty"        yaml:"audioInput,omitempty"`
	AudioOutput       bool     `json:"audioOutput,omitempty"       yaml:"audioOutput,omitempty"`
	SystemMessages    bool     `json:"systemMessages,omitempty"    yaml:"systemMessages,omitempty"`
	AssistantPrefill  bool     `json:"assistantPrefill,omitempty"  yaml:"assistantPrefill,omitempty"`

	// ReasoningEfforts lists the effort levels the model accepts, ordered
	// low→high, from ReasoningEffortLevels. Empty means the model has no
	// effort control. Both fields require Reasoning.
	ReasoningEfforts       []string `json:"reasoningEfforts,omitempty"       yaml:"reasoningEfforts,omitempty"`
	DefaultReasoningEffort string   `json:"defaultReasoningEffort,omitempty" yaml:"defaultReasoningEffort,omitempty"`
}

Capabilities is the bag-of-bools feature flags every model declares. Open-ended over time; new flags can be added without a migration since the whole struct lives in JSONB.

type Deprecation

type Deprecation struct {
	Status      DeprecationStatus `json:"status,omitempty"      yaml:"status,omitempty"      validate:"omitempty,oneof=active deprecated sunset"`
	SunsetDate  string            `json:"sunsetDate,omitempty"  yaml:"sunsetDate,omitempty"`
	Replacement string            `json:"replacement,omitempty" yaml:"replacement,omitempty" validate:"omitempty,uuid"`
}

Deprecation describes the lifecycle state of a Model.

type DeprecationStatus

type DeprecationStatus string

DeprecationStatus enumerates the lifecycle states.

const (
	DeprecationActive     DeprecationStatus = "active"
	DeprecationDeprecated DeprecationStatus = "deprecated"
	DeprecationSunset     DeprecationStatus = "sunset"
)

type Modalities

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

Modalities lists input/output media types ("text", "image", "audio", ...).

type Model

type Model struct {
	Meta meta.Metadata `json:"metadata" yaml:"metadata"`
	Spec Spec          `json:"spec"     yaml:"spec"`
}

Model is the published model definition.

func (*Model) IsEnabled

func (m *Model) IsEnabled() bool

IsEnabled returns true when Enabled is unset or explicitly true.

func (*Model) PointerSnapshot added in v0.3.0

func (m *Model) PointerSnapshot() *Snapshot

PointerSnapshot returns the snapshot Pointer names, nil when none matches (can't happen post-Validate; callers stay defensive).

func (*Model) PointerUpstream added in v0.2.0

func (m *Model) PointerUpstream() string

PointerUpstream returns the upstream wire name of the snapshot the bare model name resolves to (Pointer → snapshot → Upstream()). Falls back to Pointer itself if no snapshot matches (shouldn't happen post-Validate).

func (*Model) Validate

func (m *Model) Validate() error

Validate runs intra-row rules via the shared meta.Validator and enforces the Model-specific invariants:

  • Owner is required and must be provider-kind with a non-empty ID. Models always belong to a Provider.
  • Snapshot names are unique within the model and Pointer must name one of them.
  • Reasoning effort levels are known, unique, ordered low→high, and only set on reasoning models; the default is one of them.

Cross-entity checks (Owner.ID resolves to a real Provider; Deprecation. Replacement resolves to a real Model; snapshot-name uniqueness across the catalog) live in the composition layer.

type Snapshot

type Snapshot struct {
	Name         string `json:"name"                   yaml:"name"                   validate:"required,hostname_rfc1123"`
	ReleasedAt   string `json:"releasedAt,omitempty"   yaml:"releasedAt,omitempty"`
	OriginalName string `json:"originalName,omitempty" yaml:"originalName,omitempty"`
}

Snapshot is a dated checkpoint of a Model. Name is the customer-facing identifier (DNS-1123 slug; matches what the SDK sends in the `model` field). OriginalName is the upstream wire name; when omitted it defaults to Name — the common case where the slug-safe name already matches what the provider expects.

func (Snapshot) Upstream

func (s Snapshot) Upstream() string

Upstream returns the wire name to send to the provider — OriginalName when set, otherwise Name.

type Spec

type Spec struct {
	Family string `json:"family,omitempty" yaml:"family,omitempty"`
	// ProductLine is the vendor's named tier or variant inside Family (opus, flash-lite); never a version or size. Allowed values are checked by the catalog validator, not here.
	ProductLine string `json:"productLine,omitempty" yaml:"productLine,omitempty"`
	Version     string `json:"version,omitempty"     yaml:"version,omitempty"`

	Capabilities Capabilities `json:"capabilities,omitempty" yaml:"capabilities,omitempty"`
	Modalities   Modalities   `json:"modalities,omitempty"   yaml:"modalities,omitempty"`

	// Context window split. ContextWindowTotal is canonical; the Input/Output
	// pair is informational for models that publish a soft cap.
	ContextWindowInput  int `json:"contextWindowInput,omitempty"  yaml:"contextWindowInput,omitempty"  validate:"omitempty,gte=0"`
	ContextWindowOutput int `json:"contextWindowOutput,omitempty" yaml:"contextWindowOutput,omitempty" validate:"omitempty,gte=0"`
	ContextWindowTotal  int `json:"contextWindowTotal,omitempty"  yaml:"contextWindowTotal,omitempty"  validate:"omitempty,gte=0"`
	MaxOutputTokens     int `json:"maxOutputTokens,omitempty"     yaml:"maxOutputTokens,omitempty"     validate:"omitempty,gte=0"`

	KnowledgeCutoff string       `json:"knowledgeCutoff,omitempty" yaml:"knowledgeCutoff,omitempty"`
	ReleaseDate     string       `json:"releaseDate,omitempty"     yaml:"releaseDate,omitempty"`
	DeprecationDate string       `json:"deprecationDate,omitempty" yaml:"deprecationDate,omitempty"`
	Deprecation     *Deprecation `json:"deprecation,omitempty"     yaml:"deprecation,omitempty"`

	Tags                 []string `json:"tags,omitempty"                 yaml:"tags,omitempty"`
	Documentation        string   `json:"documentation,omitempty"        yaml:"documentation,omitempty"`
	License              string   `json:"license,omitempty"              yaml:"license,omitempty"`
	ProviderModelPageURL string   `json:"providerModelPageURL,omitempty" yaml:"providerModelPageURL,omitempty" validate:"omitempty,http_url"`

	Enabled *bool `json:"enabled,omitempty" yaml:"enabled,omitempty"` // nil = true

	// Snapshots are the dated checkpoints this Model exposes. Every Model has
	// at least one. Pointer names the snapshot the bare Model name resolves
	// to at request time.
	Snapshots []Snapshot `json:"snapshots" yaml:"snapshots" validate:"required,min=1,dive"`
	Pointer   string     `json:"pointer"   yaml:"pointer"   validate:"required"`

	// Aliases are resolution-only, last-priority matchers. A request whose
	// model string matches no catalog name (snapshot names + their
	// synthesized provider/host forms) is checked against declared aliases:
	// exact forms first, then patterns — the ONLY place wildcards are
	// allowed (exactly one '*', with a literal prefix). A match resolves to
	// this Model's Pointer snapshot and the caller's string goes upstream
	// VERBATIM. Aliases are lookup keys, never identity: they never appear
	// in policy grants, modelref, admin URLs, or the usage `model` slug.
	// Matching runs on the slug-normalized form ("claude-fable-5[1m]" ≡
	// "claude-fable-5-1m").
	Aliases []string `json:"aliases,omitempty" yaml:"aliases,omitempty"`
}

Spec is the body. Cross-refs are stored as ids. The owning Provider (vendor) id lives on Meta.Owner.ID (Owner.Kind is always "provider"); there is no separate spec.providerId field.

Per-Host serving info (which Hosts can serve this Model) lives in standalone HostBinding entities (app/binding), not in Spec.

type Store

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

Store is the Model data-access type.

func NewStore

func NewStore(q *gen.Queries) *Store

NewStore constructs a Store from an existing sqlc Queries handle.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, id string) error

Delete removes a Model by id.

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (*Model, error)

Get returns the Model with the given id, or (nil, nil) if not found.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]*Model, error)

List returns every Model row.

func (*Store) Upsert

func (s *Store) Upsert(ctx context.Context, m *Model) error

Upsert writes m. Caller is responsible for stamping Meta.ID.

Jump to

Keyboard shortcuts

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