models

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 43 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

Index

Constants

View Source
const (
	// Window assumed when nothing knows the model's
	DefaultContext = 256_000
	// Least window a session, a model switch or a job accepts
	MinimumContext = 64_000
)
View Source
const (
	// A model priced past the limits of Model guards
	Expensive = "expensive"
	// A model on a tier whose provider may train on what is sent
	Training = "training"
	// A switch of the model of a session that holds many tokens, which the new model reads again uncached
	Switch = "switch"
)

Kinds of the warnings the host's own guards give, which an answer and the settings name them by

View Source
const (
	// The pick went ahead once confirmed, this time
	AnsweredOnce = "once"
	// The pick went ahead, and the model is not asked about again
	AnsweredAlways = "always"
	// The person kept what they had
	AnsweredNo = "no"
	// Nobody could be asked, or the settings never allow it, so the pick was refused
	AnsweredRefused = "refused"
)

Answers a person gave the guards, as Answered counts them

View Source
const (
	FromPriceList = "official_docs_snapshot"
	FromProvider  = "provider_models_api"
	FromNowhere   = "none"
)

Where a price came from

View Source
const IncludedNote = "subscription-included; no provider invoice for usage"

Note of a cost a subscription covers

Variables

This section is empty.

Functions

func Accepted

func Accepted(cfg *config.Config, route provider.Route) bool

Whether a person had the guards stop asking about the route's model: Models not asked about names it with its provider, or alone

func CatalogItemIsGeneration

func CatalogItemIsGeneration(item any) bool

Whether a catalog row is of a generation model: false unless the row's own type or name proves it is generation only

func ChatCatalogIDs

func ChatCatalogIDs(items any) []string

Model ids of a models payload, its generation rows left out

func CheckCatalog

func CheckCatalog(raw []byte) error

Why a body is no catalog of models to publish, nil when it is one: what this build reads, every model listed once by its provider and at most one of them its default

func ContextLimit

func ContextLimit(message string) (int, bool)

Context window a provider's error quotes, none for an error about output alone

func CostLabel

func CostLabel(amount *big.Rat) string

Amount as $0.00 for nothing, at four places below a cent and two above

func GetJSON

func GetJSON(ctx context.Context, cfg *config.Config, target string, timeout time.Duration, headers map[string]string) (any, error)

JSON a GET of the address answers with, asked through the proxy and authorities of the profile's environment, an error for any status but success

func Identity

func Identity(key string) string

Stable non secret id of a credential, for telling accounts apart

func IsKnownNonChatModel

func IsKnownNonChatModel(model string) bool

Whether the shape of the name or an already parsed catalog item says the model is not one to chat with

func LMStudioRoot

func LMStudioRoot(base string) string

Root of an LM Studio server for its own API, its /api/v1, /api or /v1 taken off

func List

func List(ctx context.Context, cfg *config.Config, route provider.Route, modelsURL string) ([]string, bool)

Chat model ids of an OpenAI style models listing, at the address or at the models path of the route's base URL, asked through the proxy and authorities of the profile's environment

func Local

func Local(base string) bool

Whether the address is on this machine or its network: loopback, a container's or a .local name, a bare host name, a private, link local or Tailscale address

func LowerContextLimit

func LowerContextLimit(message string, current int) (int, bool)

Window a provider's error quotes when it is below the one assumed, which then was too big

func Merge

func Merge(first, second []string) []string

Ids of the first list as they are, then those of the second not already there, case aside

func ModelIDIsGeneration

func ModelIDIsGeneration(modelID any) bool

Whether the id names an image or video generation surface

func NoteCatalogItem

func NoteCatalogItem(item any) bool

Remembers a generation row, and whether it must leave the chat catalog

func NoteGenerationModel

func NoteGenerationModel(modelID any)

Remembers an id a live catalog row proved to be generation only

func OutputBudget

func OutputBudget(message string) (int, bool)

Output tokens a refusal of too many says there may be

func OutputCapError

func OutputCapError(message string) bool

Whether a refusal is of the output asked for being too big, not of the input

func PerMillion

func PerMillion(price string) string

PerMillion returns a price for a million tokens as dollars, empty when the price is no number.

func Request

func Request(ctx context.Context, cfg *config.Config, method, target string, headers map[string]string, body []byte, timeout time.Duration) (map[string]any,
	error)

JSON object one request is answered with, asked through the proxy and authorities of the profile's environment, empty for an empty body; a StatusError for any status but success. Redirects are followed, without the credentials when they lead to another origin

func Routed

func Routed(ctx context.Context, cfg *config.Config, route provider.Route) context.Context

Context whose requests to the route's own host carry the route's headers under their own and its Query parameters, the latter none for a route AWS signs; how the host asks every registrant about a route, so no listing, probe or usage reading of a provider goes without them

func Scalar

func Scalar(v any) string

Text of a decoded JSON scalar, a number written out in full; empty for anything else

func Shipped

func Shipped() []byte

Catalog as icebath ships it, the very file icebath.app publishes and the repository's mirror serves

func StaleUsage

func StaleUsage(reading *provider.AccountUsage) bool

Whether a reading is too old, or from the future, to show as live

func Status

func Status(err error) int

Status of an error a request failed with, 0 when it got no answer

func Tokens

func Tokens(n int64) string

Count of tokens in digits grouped in thousands, empty when not known

func WithoutGenerationModels

func WithoutGenerationModels(models []string) []string

Ids with the generation ones left out, the same slice when none were

Types

type Capabilities

type Capabilities struct {
	Tools     bool
	Vision    *bool
	Reasoning *bool
	Context   int
	MaxOutput int
	Family    string
}

Abilities of a model as the catalog and overrides know them; nil abilities are not known

type Catalog

type Catalog struct {
	IDs      []string
	Fallback bool
	// Such as recommended, free or default, by model id
	Notes map[string]string
	// Why the provider gave no list of its own, nil when it gave one or was not asked
	Unlisted *Unlisted
}

Models a provider offers: their ids, whether they stand in for a list it could not give, and words shown beside some

type CatalogSource

type CatalogSource struct {
	// Kind of provider whose own catalog it is, empty for the main catalog
	Provider string
	// Address asked, and the address as the settings write it, which is what a person is told
	Address, Shown string
	// The profile set the address rather than reading icebath's own
	Set bool
}

An address the profile reads a catalog of models from

type Cost

type Cost struct {
	// USD, nil when not known
	USD *big.Rat
	// USD of each part the price prices: input, output, cache_read, cache_write and request; nil when not known
	Parts map[string]*big.Rat
	// estimated, included or unknown
	Status  string
	Source  string
	Label   string
	Version string
	Fetched time.Time
	Notes   []string
}

What a request cost, or why that is not known

func (Cost) Amount

func (c Cost) Amount() float64

USD of the cost, 0 when not known

type Curator

type Curator interface {
	Catalog(ctx context.Context, env *Env) (Catalog, bool)
}

Registrant whose kind's catalog is its own work start to end, such as a live list cut down to the curated one: what it answers is offered as it is, without the curated models merged in

type Directory

type Directory interface {
	Lookup(ctx context.Context, env *Env, model string) (Row, bool)
}

Registrant keeping a public directory of models with their windows and prices, in which a route of any kind can look its model up

type Env

type Env struct {
	Host   *Models
	Config *config.Config
	Route  provider.Route
	// Read again now, whatever is kept
	Refresh bool
}

What a registrant is asked about: the route, the settings of its profile, and the host to reach what else is known through

func (*Env) Cache

func (e *Env) Cache(name string) string

File of the profile's caches with the name

type Former

type Former interface {
	Format() provider.APIMode
}

Registrant that answers for the routes of one request format before the registrants of their kinds, such as a program that serves the models of its own sign-in whatever the kind of the provider; it is asked for no route of another format

type Guard

type Guard interface {
	Guard(ctx context.Context, env *Env, pick Pick) []Warning
}

Registrant that says what is wrong with a model picked before the pick takes effect, nothing for a pick it has nothing against. A registrant that only guards answers Models with nothing

type Guarded

type Guarded struct {
	Pick     Pick
	Warnings []Warning
	// Made of the profile, the pick and the kinds warned of: a confirmation that carries it confirms this very pick alone; empty when
	// nothing was said
	Token string
}

What the guards say of one pick, and the token a confirmation of it carries

func (Guarded) Confirmed

func (g Guarded) Confirmed(token string) bool

Whether the token confirms the pick: given, and made for this very pick and its warnings

func (Guarded) Kinds

func (g Guarded) Kinds() []string

The kinds warned of, in the order said

func (Guarded) Lasting

func (g Guarded) Lasting() bool

Whether a person may have the guards stop asking about the model: some warning lasts, and none is refused whatever the answer

func (Guarded) Never

func (g Guarded) Never() []Warning

Warnings the settings never allow, which refuse the pick whoever answers

func (Guarded) Picked

func (g Guarded) Picked() string

The pick as a person reads it: the model, and the provider it runs on

func (Guarded) Refusal

func (g Guarded) Refusal(warnings []Warning, unattended bool) string

Why the pick does not take effect where nobody can confirm it, or where the settings never allow it, as one sentence or more a person reads; the warnings said after it

func (Guarded) Stopping

func (g Guarded) Stopping() []Warning

Warnings that stop a run nobody can ask: every one but those the settings let such a run go ahead on

func (Guarded) Text

func (g Guarded) Text() string

Words of every warning, one after another, each under its heading when there are several

func (Guarded) Title

func (g Guarded) Title() string

Heading of the confirmation: the warning's own when there is one, else one for them all

type Info

type Info struct {
	ID               string
	Name             string
	Family           string
	Provider         string
	Reasoning        bool
	Tools            bool
	Attachment       bool
	Temperature      bool
	StructuredOutput bool
	OpenWeights      bool
	Input            []string
	Output           []string
	Context          int
	MaxOutput        int
	MaxInput         int
	// USD for a million tokens; nil cache prices are not known
	CostInput      float64
	CostOutput     float64
	CostCacheRead  *float64
	CostCacheWrite *float64
	Knowledge      string
	Released       string
	Status         string
}

What models.dev keeps of a model, the overrides of the profile and the kind's own declarations applied

func (Info) Abilities

func (i Info) Abilities() string

Abilities of the model as a list, basic when it has none of note

func (Info) Priced

func (i Info) Priced() bool

Whether either price of a token is known

func (Info) Vision

func (i Info) Vision() bool

Whether the model takes images

type Listed

type Listed struct {
	Provider string
	URL      string
	Public   bool
}

Kind whose routes list their models at a fixed address, or at the models path of their base URL when none is given; a public list is asked for without the route's key

func (Listed) Models

func (l Listed) Models(ctx context.Context, cfg *config.Config, route provider.Route) ([]string, bool)

type ManifestModel

type ManifestModel struct {
	ID          string
	Description string
	// The model a route of the provider lands on when none is picked
	Default bool
}

One model of a provider's block of the online catalog

type Models

type Models struct {
	Registry
	// contains filtered or unexported fields
}

What is known of the models of every provider: their catalogs, the details models.dev keeps, the windows and prices providers state, what requests cost and what accounts may still spend. Each profile keeps its own caches in its folder

func New

func New(cfg *config.Config, providers *provider.Registry) *Models

func (*Models) Agentic

func (m *Models) Agentic(cfg *config.Config, route provider.Route, network bool) []string

Ids of the route's provider in the registry that call tools, without the hidden and noise ones

func (*Models) Allow

func (m *Models) Allow(cfg *config.Config, g Guarded) error

Keeps that a person had the guards stop asking about the model of the pick, adding it to Models not asked about with its provider

func (*Models) Answered

func (m *Models) Answered(g Guarded, answer string)

Counts an answer to what the guards said, by the kinds they warned of

func (*Models) AskCatalog

func (m *Models) AskCatalog(ctx context.Context, cfg *config.Config, source CatalogSource) error

Why the catalog at the source can't be read, asked now through the profile's network settings and kept nowhere; nil when it answers with a catalog this build reads

func (*Models) CachedContext

func (m *Models) CachedContext(cfg *config.Config, model, base string) (int, bool)

Window kept for the model on the endpoint

func (*Models) CachedUsage

func (m *Models) CachedUsage(cfg *config.Config, route provider.Route) *provider.AccountUsage

Reading remembered for the route, nil when none landed

func (*Models) Capabilities

func (m *Models) Capabilities(cfg *config.Config, route provider.Route, network bool) (Capabilities, bool)

Abilities of the route's model with overrides applied, the registry fetched when the network is allowed; false when nothing knows it

func (*Models) Catalog

func (m *Models) Catalog(ctx context.Context, cfg *config.Config, route provider.Route, refresh bool) Catalog

Models the route's provider offers, kept on disk for the credential it was read with: a fresh copy as it is, a stale one while a refresh runs in the background, else read now. Refresh reads it now whatever is kept. Two callers that read the same list at once read it once, and a read that gave no models stands a minute, so the callers after it in that minute do not ask the provider again

func (*Models) CatalogSources

func (m *Models) CatalogSources(cfg *config.Config) []CatalogSource

Addresses the profile reads catalogs of models from: the main one, then the own catalog of each kind of provider by kind; none while the online catalog is turned off

func (*Models) ContextLength

func (m *Models) ContextLength(ctx context.Context, cfg *config.Config, route provider.Route) int

Tokens the route's model takes in at once: what the profile says of it, what the route's kind or endpoint states, what was found before, what the models.dev registry and public directories list, what a server of this machine reports, the family's window, else the default. What was found is used for five minutes, or until a window is kept or forgotten

func (*Models) Cost

func (m *Models) Cost(ctx context.Context, cfg *config.Config, route provider.Route, usage provider.Usage) Cost

What one request on the route cost: its tokens at the model's prices, those of the tier that served it when it has its own, those past the price's threshold at the higher ones, a part the higher ones leave out not known

func (*Models) Curated

func (m *Models) Curated(cfg *config.Config, route provider.Route) Catalog

Models the route's kind offers without asking its provider: those its catalog curates, after those models.dev knows when the registry describes the kind better, a stand in for a list it could not give

func (*Models) DefaultModel

func (m *Models) DefaultModel(cfg *config.Config, instance provider.Instance) string

Model the provider uses when nothing names one, the one rule every screen and every route takes: the one its settings write, else the one its kind starts with, else the online catalog's default for its kind, else its kind's catalog default, else the first model its kind curates

func (*Models) DevIDs

func (m *Models) DevIDs(cfg *config.Config, route provider.Route, network bool) []string

Ids of the route's provider in the registry, without those the picker leaves out

func (*Models) DevPrices

func (m *Models) DevPrices(cfg *config.Config, route provider.Route) map[string]provider.Price

Prices of the models of the route's provider in the models.dev registry as held, by id

func (*Models) Endpoint

func (m *Models) Endpoint(ctx context.Context, cfg *config.Config, base, key string, address provider.Written) map[string]Row

Models an OpenAI style endpoint lists with what it says of each, read at the base and its v1 twin and kept five minutes for each address and key; LM Studio's own listing and llama.cpp's loaded windows are read on servers of this machine. Empty when nothing answers. Every address it logs is told as the settings it was read from write it, as address puts it back

func (*Models) Families

func (m *Models) Families(cfg *config.Config) []string

Families the models.dev registry held now sorts models into, in order of the alphabet; none when nothing of it is held. Made once for each registry held, a copy of the caller's own each time

func (*Models) ForgetContext

func (m *Models) ForgetContext(cfg *config.Config, model, base string)

Forgets the window kept for the model on the endpoint, and what servers of this machine said of it lately

func (*Models) Guards

func (m *Models) Guards(ctx context.Context, cfg *config.Config, pick Pick) Guarded

What every guard says of the pick on the profile of the settings, in the order they were registered; what a person had stop for the model left out. A guard that panics says nothing, with a line in the log, so a pick never breaks on one

func (*Models) HasUsage

func (m *Models) HasUsage(route provider.Route) bool

Whether the route's kind can say what its accounts may still spend

func (*Models) Info

func (m *Models) Info(cfg *config.Config, route provider.Route) (Info, bool)

Details of the route's model from the registry as already held, the profile's overrides applied; false when nothing knows the model

func (*Models) Kind

func (m *Models) Kind(base string) string

Kind of provider an address belongs to: the kind claiming its host, else the kind whose base URL has that host; empty for none

func (*Models) KindList

func (m *Models) KindList(cfg *config.Config, spec provider.Spec, refresh bool) []string

Models the kind's catalog curates, in its order: its own catalog's block first, else the online catalog's, else what its plugin curates; the list every kind's model list and default model start from

func (*Models) Manifest

func (m *Models) Manifest(cfg *config.Config, kind string, refresh bool) []ManifestModel

Models the online catalog lists for the kind, from the catalog its models.catalog.providers entry names first; nil when it lists none

func (*Models) ManifestDefault

func (m *Models) ManifestDefault(cfg *config.Config, kind string) string

Model the catalog labels the kind's default: its own catalog's block first, then the online catalog from what is held or kept, the shipped catalog else; nothing is fetched

func (*Models) OllamaThinks

func (m *Models) OllamaThinks(ctx context.Context, cfg *config.Config, model, base, key string) (bool, bool)

Whether a server answering Ollama's show reports thinking for the model, and whether it said: a model it lists without thinking is known not to think, and the answer is kept half a minute either way

func (*Models) OllamaVision

func (m *Models) OllamaVision(ctx context.Context, cfg *config.Config, route provider.Route) (bool, bool)

Whether an Ollama server's model sees images, and whether the server said: its capabilities, else a vision block in its weights

func (*Models) OllamaWindow

func (m *Models) OllamaWindow(ctx context.Context, cfg *config.Config, model, base, key string) (int, bool)

Window an Ollama server on this machine runs the model with, its Modelfile's num_ctx before its weights' most; false when the server is no Ollama or doesn't answer

func (*Models) Picked

func (m *Models) Picked(cfg *config.Config) []Picked

Models the settings of the profile pick, each with the route it lands on: every setting that declares it picks a model, one by one in a list of them, and every field of the entries of a table that declares it does. Models not asked about names models, and uses none

func (*Models) Prices

func (m *Models) Prices(ctx context.Context, cfg *config.Config, route provider.Route, refresh bool) map[string]provider.Price

Prices of every model of the route's provider for showing beside them, as its own catalog publishes them; empty when it publishes none

func (*Models) RefreshCatalogs

func (m *Models) RefreshCatalogs(cfg *config.Config) bool

Fetches the online catalog again now, the addresses that failed asked again too; false while it is turned off

func (*Models) RefreshInterval

func (m *Models) RefreshInterval(cfg *config.Config) time.Duration

RefreshInterval returns Keep lists for, at least a minute.

func (*Models) RefreshUsage

func (m *Models) RefreshUsage(ctx context.Context, cfg *config.Config, routes []provider.Route)

Refreshes the reading of each route in the background, unless one runs for it or was tried in the last two minutes

func (*Models) Register

func (m *Models) Register(registrant Registrant)

Adds a registrant; a registry registered into the host reaches it through Host

func (*Models) SaveContext

func (m *Models) SaveContext(cfg *config.Config, model, base string, n int, shown string)

Keeps a window found for the model on the endpoint, such as one a provider's refusal stated; shown is the endpoint as the settings it was read from write it, every ${NAME} kept, which is what is logged of it, empty for one read from none

func (*Models) ServerType

func (m *Models) ServerType(ctx context.Context, cfg *config.Config, base, key string) string

Kind of local server at the address, found by the endpoints only it answers: lm-studio, ollama, llamacpp or vllm; empty for a known provider's host or when none answers

func (*Models) ShownPrice

func (m *Models) ShownPrice(cfg *config.Config, route provider.Route, catalog map[string]provider.Price) (provider.Price, bool)

Price of one model for showing beside it: the provider's own catalog, else its kind's price list or the list prices models.dev keeps; nothing is fetched

func (*Models) Spec

func (m *Models) Spec(route provider.Route) provider.Spec

Kind of the route as its provider has it, its settings resolved, the kind as its plugin registers it for a route of no provider

func (*Models) Tagged

func (m *Models) Tagged(ctx context.Context, cfg *config.Config, route provider.Route, tag string) ([]map[string]any, bool)

Models the catalog of the route's kind tags with a surface, each an id and its metadata; none when the catalog can't be read, false when no plugin of the kind tags its models

func (*Models) TaggedIDs

func (m *Models) TaggedIDs(ctx context.Context, cfg *config.Config, route provider.Route, tag string) []string

Ids of the models the catalog of the route's kind tags with a surface, in its order

func (*Models) Tallies

func (m *Models) Tallies() (map[string]int, map[[2]string]int)

Warnings the guards gave and the answers they had in this process, by kind, and by kind and answer

func (*Models) Thinking

func (m *Models) Thinking(ctx context.Context, cfg *config.Config, route provider.Route) (provider.Thinking, bool)

What the provider's listings say of the reasoning of the route's model, from the plugin of its kind; false when none knows it

func (*Models) TierPrice

func (m *Models) TierPrice(cfg *config.Config, route provider.Route, tier string) (provider.Price, bool)

Price a request the tier served on the route bills at, as Cost prices it, at the moment, for showing beside the tier: nothing is fetched, so a price only the provider's own listing gives is not known here. The empty tier, and default or standard as an answer names the usual one, is the standard price

func (*Models) Unattended

func (m *Models) Unattended(ctx context.Context, cfg *config.Config, route provider.Route, from string) error

Why a route that settings or a task chose, where nobody is asked, may not be used: a warning the settings never allow, or one a run nobody watches may not go ahead on; nil when it may. Every door that picks a model from settings asks it: subagents, a mixture's acting model and advisers, helper models and the voice mode model

func (*Models) Usage

func (m *Models) Usage(ctx context.Context, cfg *config.Config, route provider.Route) *provider.AccountUsage

What the provider of the route says of the limits of its account, remembered for the route and its account; nil when the kind can't say, no account is signed in or the fetch failed

func (*Models) Validate

func (m *Models) Validate(ctx context.Context, cfg *config.Config, route provider.Route) Verdict

Checks the model a switch to the route names, its id never rewritten: refused when it is empty, a generation model, holds spaces no vendor catalog does, or the provider's live listing lacks it; taken with a note when only a curated list or no list could be read, or the endpoint's listing may leave models out; up to three close matches suggested for one not listed

func (*Models) VisionModel

func (m *Models) VisionModel(ctx context.Context, cfg *config.Config, route provider.Route) (string, bool)

Model of the route's kind that sees images, from its plugin when it names one, and whether it does: one that answers but finds none leaves the kind out of side jobs on images

func (*Models) Warned

func (m *Models) Warned(ctx context.Context, cfg *config.Config, pick Pick) []Warning

What every guard says of the pick, what a person had stop for the model among it: what the profile uses that a guard warns of, as the audit and the doctor read it

func (*Models) WindowSet

func (m *Models) WindowSet(cfg *config.Config, route provider.Route) (int, bool)

The context window a person set for the route's model, else for every model of its provider, the one place a window is set by hand; false for none

type Pick

type Pick struct {
	// Route the pick lands on: the provider of the profile, its kind, the model and its address
	Route provider.Route
	// Tokens the session the pick is for holds as its last request was measured; 0 for a pick of no session, or of one that holds none
	Held int
	// Model the session ran on before the pick, empty for none
	From string
}

One model picked, as the guards are asked about it before it takes effect

type Picked

type Picked struct {
	// Where it is set, as a person finds it: the setting and its section, with the entry of a table
	Where string
	// Key of the setting, with the name of the entry of a table after it
	Key string
	// Route of the model on the provider of the profile it names, the provider empty when the setting names none
	Route provider.Route
}

A model a setting of the profile picks, as the audit and the doctor weigh what the profile uses

type Pricer

type Pricer interface {
	Prices(ctx context.Context, env *Env) (map[string]provider.Price, bool)
}

Registrant that publishes the prices of the models of its kind, by model id

type Reads

type Reads[T any] struct {
	// contains filtered or unexported fields
}

What slow reads gave, such as a provider's listing asked over the network, kept by key for as long as each read says: one read of a key at a time, the callers that ask while it runs waiting for its answer rather than asking again

func (*Reads[T]) Get

func (r *Reads[T]) Get(ctx context.Context, key string, fresh bool, read func(ctx context.Context) (T, time.Duration)) T

Value of the key: what a read gave while it stands, else what the read under way gives, else what read gives now, kept as long as read says. Fresh reads now whatever stands, though a read under way is still waited for rather than made twice. A read runs in a context of its own that the caller ending does not end, so whoever waits for it gets its answer; a caller that ends while it waits takes what stood

func (*Reads[T]) Keep

func (r *Reads[T]) Keep(key string, value T, keep time.Duration)

Keeps a value read some other way for the key, standing as long as keep says, such as a listing read for the list of models that answers for its details too

type Registrant

type Registrant interface {
	Models(ctx context.Context, cfg *config.Config, route provider.Route) ([]string, bool)
}

Live model list of the routes of a kind of provider, asked in the environment of the profile the route was resolved for

type Registry

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

func (*Registry) Host

func (r *Registry) Host() *Models

Host the registry belongs to, through which plugins reach the catalogs, the details and the prices of models

func (*Registry) Models

func (r *Registry) Models(ctx context.Context, cfg *config.Config, route provider.Route) ([]string, bool)

Live model list of the route of the profile: from the registrant of its request format that answers, else from the first registrant that answers for its kind; their requests to the route's host carry what the provider adds

func (*Registry) Register

func (r *Registry) Register(registrant Registrant)

Adds a registrant to the host's one list. A registry registered into another hands over its registrants once, and from then on registers into the host and answers as the host does, so no list is nested in another

type Row

type Row struct {
	Name      string `json:"name"`
	Context   int    `json:"context_length,omitempty"`
	MaxOutput int    `json:"max_completion_tokens,omitempty"`
	// USD a token as the listing gives it, by prompt, completion, cache_read and cache_write, and USD a request
	Pricing map[string]string `json:"pricing,omitempty"`
	// Request fields the listing says the model takes, nil when it says nothing of them; the reasoning efforts it lists, and whether its
	// reasoning can't be turned off
	Parameters []string `json:"supported_parameters"`
	Efforts    []string `json:"supported_efforts,omitempty"`
	Mandatory  bool     `json:"mandatory,omitempty"`
}

What a models listing says of one model

func (Row) Price

func (r Row) Price() (provider.Price, bool)

Price of the row for a million tokens, false when its listing gives none

type Seer

type Seer interface {
	VisionModel(ctx context.Context, env *Env) (string, bool)
}

Registrant that names a model of its kind that sees images, for side jobs on one; answering with none leaves the kind out of them

type Sizer

type Sizer interface {
	ContextLength(ctx context.Context, env *Env) (int, bool)
}

Registrant that knows the context window of a model of its kind from what the provider says of it, such as its models listing

type StatusError

type StatusError struct {
	Status int
	URL    string
}

Non success status of a request

func (*StatusError) Error

func (e *StatusError) Error() string

type Tagger

type Tagger interface {
	Tagged(ctx context.Context, env *Env, tag string) ([]map[string]any, bool)
}

Registrant whose kind's catalog tags each model with the surfaces it serves, such as DeepInfra's chat, tts, stt and image-gen: the models of a surface with what the catalog says of them, as it lists them

type Thinker

type Thinker interface {
	Thinking(ctx context.Context, env *Env) (provider.Thinking, bool)
}

Registrant that knows from what the provider lists whether a model of its kind takes reasoning fields, at which efforts, and whether its reasoning can be turned off

type Unlisted

type Unlisted struct {
	URL    string
	Status int
	Err    error
	Shape  bool
}

Why a provider gave no list of models of its own, as the requests of its listing met it: the address asked last, and the error status it answered with, the failure to reach it or an answer that holds no list; an answer with no models when none of those

func (Unlisted) Reason

func (u Unlisted) Reason(name string) string

Why the provider with the name has no models of its own to pick, then what to do, in sentences a person reads

func (Unlisted) Refused

func (u Unlisted) Refused() bool

Refused reports whether the provider turned the listing's key away or could not be reached at all.

type Verdict

type Verdict struct {
	Accepted bool
	Message  string
}

What checking the model a switch names found: whether the switch goes ahead, and what the user is told of the model

type Warning

type Warning struct {
	// Guard that says it: one of the host's kinds, or a word of the plugin that brings the guard
	Kind string
	// Heading of the confirmation, such as Expensive model
	Title string
	// What is wrong with the pick, whole sentences, the prices and sizes in them
	Text string
	// A person may have it never asked of the model again, which Models not asked about keeps
	Lasting bool
	// The settings never allow it: refused whoever answers
	Never bool
	// A run nobody can ask goes ahead on it, as the settings allow
	Unasked bool
}

What a guard says of a pick, which a person confirms before the pick takes effect

func Costly

func Costly(model string, price provider.Price, priced bool, source string, input, output float64) (Warning, bool)

Warning of a model whose known price is past either limit, in dollars a million tokens, strictly past it: a price at the limit is no warning, nor one that is not known; the one model often picked by mistake warns whatever it costs. Alpha's rule

func Switching

func Switching(held, threshold int, from, to string) (Warning, bool)

Warning of the switch of a session's model to another while it holds at least the threshold of tokens, which the new model reads again uncached; none for no measure, a threshold of 0, no model named or the model the session runs on already. Alpha's rule

func Trains

func Trains(model string) (Warning, bool)

Warning of a model on a tier whose provider may train on what is sent, by the lower case id whatever the provider; a rule that panics counts as no match. Alpha's rule

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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