Documentation
¶
Index ¶
- Constants
- func Accepted(cfg *config.Config, route provider.Route) bool
- func CatalogItemIsGeneration(item any) bool
- func ChatCatalogIDs(items any) []string
- func CheckCatalog(raw []byte) error
- func ContextLimit(message string) (int, bool)
- func CostLabel(amount *big.Rat) string
- func GetJSON(ctx context.Context, cfg *config.Config, target string, timeout time.Duration, ...) (any, error)
- func Identity(key string) string
- func IsKnownNonChatModel(model string) bool
- func LMStudioRoot(base string) string
- func List(ctx context.Context, cfg *config.Config, route provider.Route, ...) ([]string, bool)
- func Local(base string) bool
- func LowerContextLimit(message string, current int) (int, bool)
- func Merge(first, second []string) []string
- func ModelIDIsGeneration(modelID any) bool
- func NoteCatalogItem(item any) bool
- func NoteGenerationModel(modelID any)
- func OutputBudget(message string) (int, bool)
- func OutputCapError(message string) bool
- func PerMillion(price string) string
- func Request(ctx context.Context, cfg *config.Config, method, target string, ...) (map[string]any, error)
- func Routed(ctx context.Context, cfg *config.Config, route provider.Route) context.Context
- func Scalar(v any) string
- func Shipped() []byte
- func StaleUsage(reading *provider.AccountUsage) bool
- func Status(err error) int
- func Tokens(n int64) string
- func WithoutGenerationModels(models []string) []string
- type Capabilities
- type Catalog
- type CatalogSource
- type Cost
- type Curator
- type Directory
- type Env
- type Former
- type Guard
- type Guarded
- func (g Guarded) Confirmed(token string) bool
- func (g Guarded) Kinds() []string
- func (g Guarded) Lasting() bool
- func (g Guarded) Never() []Warning
- func (g Guarded) Picked() string
- func (g Guarded) Refusal(warnings []Warning, unattended bool) string
- func (g Guarded) Stopping() []Warning
- func (g Guarded) Text() string
- func (g Guarded) Title() string
- type Info
- type Listed
- type ManifestModel
- type Models
- func (m *Models) Agentic(cfg *config.Config, route provider.Route, network bool) []string
- func (m *Models) Allow(cfg *config.Config, g Guarded) error
- func (m *Models) Answered(g Guarded, answer string)
- func (m *Models) AskCatalog(ctx context.Context, cfg *config.Config, source CatalogSource) error
- func (m *Models) CachedContext(cfg *config.Config, model, base string) (int, bool)
- func (m *Models) CachedUsage(cfg *config.Config, route provider.Route) *provider.AccountUsage
- func (m *Models) Capabilities(cfg *config.Config, route provider.Route, network bool) (Capabilities, bool)
- func (m *Models) Catalog(ctx context.Context, cfg *config.Config, route provider.Route, refresh bool) Catalog
- func (m *Models) CatalogSources(cfg *config.Config) []CatalogSource
- func (m *Models) ContextLength(ctx context.Context, cfg *config.Config, route provider.Route) int
- func (m *Models) Cost(ctx context.Context, cfg *config.Config, route provider.Route, ...) Cost
- func (m *Models) Curated(cfg *config.Config, route provider.Route) Catalog
- func (m *Models) DefaultModel(cfg *config.Config, instance provider.Instance) string
- func (m *Models) DevIDs(cfg *config.Config, route provider.Route, network bool) []string
- func (m *Models) DevPrices(cfg *config.Config, route provider.Route) map[string]provider.Price
- func (m *Models) Endpoint(ctx context.Context, cfg *config.Config, base, key string, ...) map[string]Row
- func (m *Models) Families(cfg *config.Config) []string
- func (m *Models) ForgetContext(cfg *config.Config, model, base string)
- func (m *Models) Guards(ctx context.Context, cfg *config.Config, pick Pick) Guarded
- func (m *Models) HasUsage(route provider.Route) bool
- func (m *Models) Info(cfg *config.Config, route provider.Route) (Info, bool)
- func (m *Models) Kind(base string) string
- func (m *Models) KindList(cfg *config.Config, spec provider.Spec, refresh bool) []string
- func (m *Models) Manifest(cfg *config.Config, kind string, refresh bool) []ManifestModel
- func (m *Models) ManifestDefault(cfg *config.Config, kind string) string
- func (m *Models) OllamaThinks(ctx context.Context, cfg *config.Config, model, base, key string) (bool, bool)
- func (m *Models) OllamaVision(ctx context.Context, cfg *config.Config, route provider.Route) (bool, bool)
- func (m *Models) OllamaWindow(ctx context.Context, cfg *config.Config, model, base, key string) (int, bool)
- func (m *Models) Picked(cfg *config.Config) []Picked
- func (m *Models) Prices(ctx context.Context, cfg *config.Config, route provider.Route, refresh bool) map[string]provider.Price
- func (m *Models) RefreshCatalogs(cfg *config.Config) bool
- func (m *Models) RefreshInterval(cfg *config.Config) time.Duration
- func (m *Models) RefreshUsage(ctx context.Context, cfg *config.Config, routes []provider.Route)
- func (m *Models) Register(registrant Registrant)
- func (m *Models) SaveContext(cfg *config.Config, model, base string, n int, shown string)
- func (m *Models) ServerType(ctx context.Context, cfg *config.Config, base, key string) string
- func (m *Models) ShownPrice(cfg *config.Config, route provider.Route, catalog map[string]provider.Price) (provider.Price, bool)
- func (m *Models) Spec(route provider.Route) provider.Spec
- func (m *Models) Tagged(ctx context.Context, cfg *config.Config, route provider.Route, tag string) ([]map[string]any, bool)
- func (m *Models) TaggedIDs(ctx context.Context, cfg *config.Config, route provider.Route, tag string) []string
- func (m *Models) Tallies() (map[string]int, map[[2]string]int)
- func (m *Models) Thinking(ctx context.Context, cfg *config.Config, route provider.Route) (provider.Thinking, bool)
- func (m *Models) TierPrice(cfg *config.Config, route provider.Route, tier string) (provider.Price, bool)
- func (m *Models) Unattended(ctx context.Context, cfg *config.Config, route provider.Route, from string) error
- func (m *Models) Usage(ctx context.Context, cfg *config.Config, route provider.Route) *provider.AccountUsage
- func (m *Models) Validate(ctx context.Context, cfg *config.Config, route provider.Route) Verdict
- func (m *Models) VisionModel(ctx context.Context, cfg *config.Config, route provider.Route) (string, bool)
- func (m *Models) Warned(ctx context.Context, cfg *config.Config, pick Pick) []Warning
- func (m *Models) WindowSet(cfg *config.Config, route provider.Route) (int, bool)
- type Pick
- type Picked
- type Pricer
- type Reads
- type Registrant
- type Registry
- type Row
- type Seer
- type Sizer
- type StatusError
- type Tagger
- type Thinker
- type Unlisted
- type Verdict
- type Warning
Constants ¶
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 )
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
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
const ( FromPriceList = "official_docs_snapshot" FromProvider = "provider_models_api" FromNowhere = "none" )
Where a price came from
const IncludedNote = "subscription-included; no provider invoice for usage"
Note of a cost a subscription covers
Variables ¶
This section is empty.
Functions ¶
func Accepted ¶
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 ¶
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 ¶
Model ids of a models payload, its generation rows left out
func CheckCatalog ¶
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 ¶
Context window a provider's error quotes, none for an error about output alone
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 IsKnownNonChatModel ¶
Whether the shape of the name or an already parsed catalog item says the model is not one to chat with
func LMStudioRoot ¶
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 ¶
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 ¶
Window a provider's error quotes when it is below the one assumed, which then was too big
func Merge ¶
Ids of the first list as they are, then those of the second not already there, case aside
func ModelIDIsGeneration ¶
Whether the id names an image or video generation surface
func NoteCatalogItem ¶
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 ¶
Output tokens a refusal of too many says there may be
func OutputCapError ¶
Whether a refusal is of the output asked for being too big, not of the input
func PerMillion ¶
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 ¶
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 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 WithoutGenerationModels ¶
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
type Curator ¶
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 ¶
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
type Former ¶
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 ¶
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 ¶
Whether the token confirms the pick: given, and made for this very pick and its warnings
func (Guarded) Lasting ¶
Whether a person may have the guards stop asking about the model: some warning lasts, and none is refused whatever the answer
func (Guarded) Refusal ¶
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 ¶
Warnings that stop a run nobody can ask: every one but those the settings let such a run go ahead on
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
type Listed ¶
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
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 (*Models) Agentic ¶
Ids of the route's provider in the registry that call tools, without the hidden and noise ones
func (*Models) Allow ¶
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) AskCatalog ¶
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 ¶
Window kept for the model on the endpoint
func (*Models) CachedUsage ¶
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 ¶
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 ¶
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 ¶
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 ¶
Ids of the route's provider in the registry, without those the picker leaves out
func (*Models) DevPrices ¶
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 ¶
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 ¶
Forgets the window kept for the model on the endpoint, and what servers of this machine said of it lately
func (*Models) Guards ¶
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) Info ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
Fetches the online catalog again now, the addresses that failed asked again too; false while it is turned off
func (*Models) RefreshInterval ¶
RefreshInterval returns Keep lists for, at least a minute.
func (*Models) RefreshUsage ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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
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 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
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 ¶
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
type Seer ¶
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 ¶
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 ¶
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 ¶
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 ¶
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
type Verdict ¶
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