model

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 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 `` /* 247-byte string literal not displayed */
	Chat              bool     `json:"chat,omitempty"              yaml:"chat,omitempty"              doc:"Generates chat or text responses."`
	Embeddings        bool     `json:"embeddings,omitempty"        yaml:"embeddings,omitempty"        doc:"Produces embeddings."`
	Streaming         bool     `json:"streaming,omitempty"         yaml:"streaming,omitempty"         doc:"Streams responses."`
	Tools             bool     `json:"tools,omitempty"             yaml:"tools,omitempty"             doc:"Calls tools."`
	ParallelTools     bool     `json:"parallelTools,omitempty"     yaml:"parallelTools,omitempty"     doc:"Calls several tools in one turn."`
	Vision            bool     `json:"vision,omitempty"            yaml:"vision,omitempty"            doc:"Accepts image input."`
	Audio             bool     `json:"audio,omitempty"             yaml:"audio,omitempty"             doc:"Handles audio, in either direction."`
	PromptCache       bool     `json:"promptCache,omitempty"       yaml:"promptCache,omitempty"       doc:"Supports prompt caching."`
	Reasoning         bool     `json:"reasoning,omitempty"         yaml:"reasoning,omitempty"         doc:"Produces reasoning before answering."`
	JSONMode          bool     `json:"jsonMode,omitempty"          yaml:"jsonMode,omitempty"          doc:"Supports JSON output mode."`
	StructuredOutputs bool     `json:"structuredOutputs,omitempty" yaml:"structuredOutputs,omitempty" doc:"Follows a supplied JSON schema for its output."`
	Batch             bool     `json:"batch,omitempty"             yaml:"batch,omitempty"             doc:"Available through the provider's batch API."`
	ComputerUse       bool     `json:"computerUse,omitempty"       yaml:"computerUse,omitempty"       doc:"Supports computer-use tools."`
	WebSearch         bool     `json:"webSearch,omitempty"         yaml:"webSearch,omitempty"         doc:"Supports the provider's web search tool."`
	FileInput         bool     `json:"fileInput,omitempty"         yaml:"fileInput,omitempty"         doc:"Accepts file input, such as PDFs."`
	AudioInput        bool     `json:"audioInput,omitempty"        yaml:"audioInput,omitempty"        doc:"Accepts audio input."`
	AudioOutput       bool     `json:"audioOutput,omitempty"       yaml:"audioOutput,omitempty"       doc:"Produces audio output."`
	SystemMessages    bool     `json:"systemMessages,omitempty"    yaml:"systemMessages,omitempty"    doc:"Accepts system instructions."`
	AssistantPrefill  bool     `json:"assistantPrefill,omitempty"  yaml:"assistantPrefill,omitempty"  doc:"Continues from a prefilled assistant message."`

	// 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 `` /* 235-byte string literal not displayed */
	DefaultReasoningEffort string   `` /* 201-byte string literal not displayed */
}

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 `` /* 246-byte string literal not displayed */
	SunsetDate  string            `json:"sunsetDate,omitempty"  yaml:"sunsetDate,omitempty"  doc:"Date the vendor stops serving the model, YYYY-MM-DD."`
	Replacement string            `` /* 129-byte string literal not displayed */
}

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"  doc:"Media the model accepts, such as text, image, audio, video, pdf."`
	Output []string `json:"output,omitempty" yaml:"output,omitempty" doc:"Media the model produces."`
}

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 `` /* 153-byte string literal not displayed */
	ReleasedAt   string `json:"releasedAt,omitempty"   yaml:"releasedAt,omitempty"   doc:"Snapshot release date, YYYY-MM-DD."`
	OriginalName string `` /* 131-byte string literal not displayed */
}

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" doc:"Model family, such as claude or gpt."`
	// 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 `` /* 162-byte string literal not displayed */
	Version     string `json:"version,omitempty"     yaml:"version,omitempty"     doc:"Version label inside the product line."`

	Capabilities Capabilities `json:"capabilities,omitempty" yaml:"capabilities,omitempty" doc:"What the model supports."`
	Modalities   Modalities   `json:"modalities,omitempty"   yaml:"modalities,omitempty"   doc:"Input and output modalities."`

	// Context window split. ContextWindowTotal is canonical; the Input/Output
	// pair is informational for models that publish a soft cap.
	ContextWindowInput  int `` /* 178-byte string literal not displayed */
	ContextWindowOutput int `` /* 177-byte string literal not displayed */
	ContextWindowTotal  int `` /* 132-byte string literal not displayed */
	MaxOutputTokens     int `` /* 145-byte string literal not displayed */

	KnowledgeCutoff string       `json:"knowledgeCutoff,omitempty" yaml:"knowledgeCutoff,omitempty" doc:"Training-data cutoff, YYYY-MM or YYYY-MM-DD."`
	ReleaseDate     string       `json:"releaseDate,omitempty"     yaml:"releaseDate,omitempty"     doc:"Release date, YYYY-MM-DD."`
	DeprecationDate string       `json:"deprecationDate,omitempty" yaml:"deprecationDate,omitempty" doc:"Date the vendor deprecated the model, YYYY-MM-DD."`
	Deprecation     *Deprecation `json:"deprecation,omitempty"     yaml:"deprecation,omitempty"     doc:"Lifecycle state. Absent means active."`

	Tags                 []string `` /* 139-byte string literal not displayed */
	Documentation        string   `json:"documentation,omitempty"        yaml:"documentation,omitempty"        doc:"Link to the model's documentation."`
	License              string   `` /* 139-byte string literal not displayed */
	ProviderModelPageURL string   `` /* 146-byte string literal not displayed */

	Enabled *bool `` // nil = true
	/* 130-byte string literal not displayed */

	// 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" doc:"Dated checkpoints of the model; at least one."`
	Pointer   string     `json:"pointer"   yaml:"pointer"   validate:"required" doc:"Name of the snapshot the bare model name resolves to."`

	// 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 `` /* 297-byte string literal not displayed */
}

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