Documentation
¶
Index ¶
- Constants
- func Abilities(facts provider.Facts) string
- func Accepted(cfg *config.Config, route provider.Route) bool
- func ChatIDs(rows []provider.Facts) []string
- func ContextLimit(message string) (int, bool)
- func CostLabel(amount *big.Rat) string
- func Dev(id string, entry map[string]any) provider.Facts
- func Fetch(ctx context.Context, cfg *config.Config, route provider.Route, ...) ([]any, bool)
- func Find(rows []provider.Facts, id string) (provider.Facts, bool)
- func Free(price *provider.Price) bool
- func GetJSON(ctx context.Context, cfg *config.Config, target string, timeout time.Duration, ...) (any, error)
- func Identity(key string) string
- func LMStudioRoot(base string) string
- func Listed(item map[string]any) (provider.Facts, bool)
- func Local(base string) bool
- func LowerContextLimit(message string, current int) (int, bool)
- 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 Rows(items []any, read func(item map[string]any, facts *provider.Facts)) []provider.Facts
- func Scalar(v any) string
- func StaleUsage(reading *provider.AccountUsage) bool
- func Status(err error) int
- func Tokens(n int64) string
- type Catalog
- type CatalogRow
- type Cost
- type Env
- type Floor
- 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 Lister
- type Listing
- type Models
- func (m *Models) Allow(cfg *config.Config, g Guarded) error
- func (m *Models) Answered(g Guarded, answer string)
- func (m *Models) CachedUsage(cfg *config.Config, route provider.Route) *provider.AccountUsage
- func (m *Models) Catalog(ctx context.Context, cfg *config.Config, route provider.Route, refresh bool) Catalog
- 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) DefaultModel(cfg *config.Config, instance provider.Instance) string
- func (m *Models) Endpoint(ctx context.Context, cfg *config.Config, route provider.Route) ([]provider.Facts, bool)
- func (m *Models) Facts(ctx context.Context, cfg *config.Config, route provider.Route) provider.Facts
- func (m *Models) ForgetWindow(cfg *config.Config, route provider.Route)
- func (m *Models) Guards(ctx context.Context, cfg *config.Config, pick Pick) Guarded
- func (m *Models) HasUsage(route provider.Route) bool
- func (m *Models) HelperModel(ctx context.Context, cfg *config.Config, route provider.Route, set string) string
- func (m *Models) Kind(base string) string
- func (m *Models) Largest(ctx context.Context, cfg *config.Config, route provider.Route) int
- func (m *Models) Learn(cfg *config.Config, route provider.Route, change func(learned *provider.Facts))
- func (m *Models) LearnRefusal(cfg *config.Config, route provider.Route, field, remedy string)
- func (m *Models) LearnWindow(cfg *config.Config, route provider.Route, window int)
- func (m *Models) Learned(cfg *config.Config, route provider.Route) provider.Facts
- func (m *Models) Listing(ctx context.Context, cfg *config.Config, route provider.Route, refresh bool) ([]provider.Facts, bool)
- func (m *Models) Observe(cfg *config.Config, route provider.Route, firstEvent, silence time.Duration)
- func (m *Models) OfKind(ctx context.Context, cfg *config.Config, route provider.Route, kind string) []provider.Facts
- func (m *Models) OllamaShow(ctx context.Context, cfg *config.Config, route provider.Route) (provider.Facts, bool)
- func (m *Models) Picked(cfg *config.Config) []Picked
- func (m *Models) RefreshDev(cfg *config.Config) error
- func (m *Models) RefreshUsage(ctx context.Context, cfg *config.Config, routes []provider.Route)
- func (m *Models) Refusals(cfg *config.Config, route provider.Route) map[string]string
- func (m *Models) Register(registrant Registrant)
- func (m *Models) Registered(cfg *config.Config, route provider.Route, network bool) []provider.Facts
- func (m *Models) RouteDefault(ctx context.Context, cfg *config.Config, route provider.Route) string
- func (m *Models) Served(ctx context.Context, cfg *config.Config, route provider.Route) (provider.Facts, bool)
- func (m *Models) ServerType(ctx context.Context, cfg *config.Config, base, key string) string
- func (m *Models) ShownPrice(cfg *config.Config, route provider.Route) (provider.Price, bool)
- func (m *Models) Spec(route provider.Route) provider.Spec
- func (m *Models) Tallies() (map[string]int, map[[2]string]int)
- func (m *Models) TierPrice(cfg *config.Config, route provider.Route, tier string) (provider.Price, bool)
- func (m *Models) TimeoutFloor(cfg *config.Config, route provider.Route) Floor
- func (m *Models) Unattended(ctx context.Context, cfg *config.Config, route provider.Route, from string) error
- func (m *Models) Usable(ctx context.Context, cfg *config.Config, route provider.Route) int
- 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 Pace
- type Pick
- type Picked
- type Reads
- type Registrant
- type Registry
- type StatusError
- type Unlisted
- type Verdict
- type Warning
Constants ¶
const ( // DefaultContext is the window assumed when no source states a window for the model. DefaultContext = 256_000 // MinimumContext is the least window a session, a model switch or a job accepts. MinimumContext = 64_000 )
const ( // Expensive is a model priced past the limits of Model safeguards. Expensive = "expensive" // Deprecated is a model its provider's listing or the models.dev registry marks as deprecated. Deprecated = "deprecated" // Switch is a switch of a session's model while the session has 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 user 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 user gave the guards, as Answered counts them
const ( // FromProvider is a price the provider's own listing states. FromProvider = "provider_models_api" // FromEndpoint is a price the models listing at an address no plugin lists for states. A guard does not trust it. FromEndpoint = "endpoint_models_api" // FromDev is a price the models.dev registry states. FromDev = "models.dev" // FromNowhere is the source of a price no source states. FromNowhere = "none" )
The sources a price comes from.
const IncludedNote = "subscription-included, no provider invoice for usage"
IncludedNote is the note of a cost a subscription covers.
Variables ¶
This section is empty.
Functions ¶
func Abilities ¶
Abilities returns what a model can do, as a list a user reads, or "text only" when no source states an ability of note.
func Accepted ¶
Accepted reports whether the user had the guards stop asking about the route's model: Approved models lists it with its provider, or without a provider.
func ChatIDs ¶
ChatIDs returns the ids of the rows that answer in text and are not hidden, in the listing's order.
func ContextLimit ¶
Context window a provider's error quotes, none for an error about output alone
func Fetch ¶
func Fetch(ctx context.Context, cfg *config.Config, route provider.Route, modelsURL string) ([]any, bool)
Fetch reads the items of a models reply at the address, or at the models path of the route's base URL, through the profile's network settings. It accepts a bare array and an object that has the items under data or models.
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 LMStudioRoot ¶
LMStudioRoot returns the root of an LM Studio server for its own API, with its /api/v1, /api or /v1 path removed.
func Listed ¶
Listed returns the facts that one item of a models reply states, under any field name that a provider's listing is known to use. ok is false for an item without an id.
func Local ¶
Local reports 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 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 Rows ¶
Rows returns the facts of every listed item that has an id. read, when set, adds the facts that only one kind's reply states.
func Scalar ¶
Scalar returns the text of a decoded JSON scalar, with a number written out in full. It is empty for anything else.
func StaleUsage ¶
func StaleUsage(reading *provider.AccountUsage) bool
Whether a reading is too old, or from the future, to show as live
Types ¶
type Catalog ¶
type Catalog struct {
// IDs has every row's id, in the rows' order.
IDs []string
Rows []CatalogRow
// StandIn is true when the provider could not be asked, and the rows are the models.dev registry's models for the route's kind.
StandIn bool
// Unlisted is the reason the provider did not give its own list. It is nil when the provider gave a list now or earlier.
Unlisted *Unlisted
}
Catalog lists the chat models a route's provider offers, in the provider's own order, with the picker's details for each model.
type CatalogRow ¶
CatalogRow is one model in a catalog: every fact known without asking the provider again, and a short note that sets the model apart, such as free, the provider's default, or deprecated.
type Cost ¶
type Cost struct {
// USD is nil when the cost is not known.
USD *big.Rat
// Parts has the USD of each part the price prices: input, output, cache_read, cache_write and request. It is nil when not known.
Parts map[string]*big.Rat
// Status is estimated, included or unknown.
Status string
Source string
Label string
Version string
Fetched time.Time
Notes []string
}
Cost is what a request cost, or the reason that is not known.
type Env ¶
type Env struct {
Host *Models
Config *config.Config
Route provider.Route
// Refresh asks the registrant to read the provider again now, regardless of what is cached.
Refresh bool
}
Env is what a registrant is asked about: the route, the settings of its profile, and the host that reaches everything else known.
type Floor ¶
Floor is the minimum time a transport waits for a model on a route: for a reply's first event, and between two events. A part is 0 when no successful reply was observed, and the transport then uses its kind-wide default.
type Former ¶
Former is a Lister that answers for the routes of one request format before the Listers of their kinds, such as a program that serves the models of its own sign-in regardless of the provider's kind. It is not asked about a 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 user 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 Lister ¶
Lister is a registrant that reads the provider's own listing: every model the route's provider lists, with every fact the listing states. ok is false when the registrant does not answer for the route.
type Listing ¶
type Listing struct {
Provider string
URL string
Public bool
Read func(item map[string]any, facts *provider.Facts)
}
Listing is the Lister for a kind with an OpenAI-style models reply, at URL or at the models path of the route's base URL. A public listing is read without the route's key. Read, when set, takes the facts that only this kind's reply states from one listed item.
type Models ¶
type Models struct {
Registry
// contains filtered or unexported fields
}
Models is the host's knowledge of the models of every provider: their listings and facts, the models.dev registry, the windows and prices providers state, what replies and refusals taught, what requests cost and what accounts may still spend. Each profile keeps its own caches in its folder.
func (*Models) Allow ¶
Allow saves that the user had the guards stop asking about the pick's model, by adding it to Approved models with its provider.
func (*Models) CachedUsage ¶
Reading remembered for the route, nil when none landed
func (*Models) Catalog ¶
func (m *Models) Catalog(ctx context.Context, cfg *config.Config, route provider.Route, refresh bool) Catalog
Catalog returns the route provider's chat models: the listing rows that answer in text and are not hidden, in the provider's order. When the provider can't be asked, the rows are the models.dev registry's chat models for the route's kind, marked as a stand-in. When the kind has no models.dev id either, the catalog is empty and Unlisted gives the reason. refresh reads the provider now.
func (*Models) ContextLength ¶
ContextLength returns the tokens the route's model takes in at once: the window the profile's overrides set, otherwise the window the provider's listing states, then a window a refusal of the provider taught, then the models.dev registry's window, then the window a server on this machine reports, otherwise DefaultContext. A window a refusal taught is also the most the listing's or the registry's window can give. The window found is used for five minutes, or until a window is learned or forgotten.
func (*Models) Cost ¶
func (m *Models) Cost(ctx context.Context, cfg *config.Config, route provider.Route, usage provider.Usage) Cost
Cost returns the cost of one request on the route: its tokens at the model's prices, at the serving tier's prices when the tier has its own, and at the higher prices past the price's threshold. A part without a stated price makes the cost unknown.
func (*Models) DefaultModel ¶
DefaultModel returns the provider's default model, the rule every screen and every route follows: the provider's default model setting, otherwise the model the selection rules pick from its newest cached listing, otherwise from the models.dev registry's models for its kind. Nothing is fetched, so it is empty for a provider that was never listed and that models.dev does not describe. RouteDefault reads the listing when no listing is cached.
func (*Models) Endpoint ¶
func (m *Models) Endpoint(ctx context.Context, cfg *config.Config, route provider.Route) ([]provider.Facts, bool)
Endpoint reads the models listing at the route's address as an OpenAI-style server answers it, at the base and its v1 twin, and maps every row to facts. On a server on this machine, LM Studio's own listing and the windows llama.cpp allocated are read as well. It is the listing of a route whose kind no plugin lists for, and a plugin for a kind that serves such a listing can return it from its List. Every address it logs is shown as the settings write it.
func (*Models) Facts ¶
func (m *Models) Facts(ctx context.Context, cfg *config.Config, route provider.Route) provider.Facts
Facts returns everything known about the route's model. Each fact comes from the first source that states it: the profile's overrides for the model and then for every model of its provider, the provider's listing, what the provider's replies and refusals taught on this profile, the models.dev registry (and its row for the model's canonical id), then a server on this machine or at an address no kind claims that reports on its models. A window a refusal stated is the model's limit unless an override sets a window. The overrides for every provider fill in only for a model that no source knows and that its provider's overrides do not mention.
func (*Models) ForgetWindow ¶
ForgetWindow forgets the window learned for the route's model and the facts a server on this machine reported, so the next request finds the window again.
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) HelperModel ¶
func (m *Models) HelperModel(ctx context.Context, cfg *config.Config, route provider.Route, set string) string
HelperModel returns the side jobs' model at the route's provider: the model in the job's setting, otherwise the cheapest priced chat model that calls tools and accepts at least MinimumContext tokens, otherwise the route's own model, which is the session's main model when the side job runs on the session's provider. It is empty when no such model is known.
func (*Models) Kind ¶
Kind returns the kind of provider an address belongs to: the kind claiming its host, otherwise the kind whose base URL has that host. It is empty when no kind claims the address.
func (*Models) Largest ¶
Largest returns the window the route's provider accepts for the model when a request asks for a window above ContextLength. It is 0 when no source states a larger window.
func (*Models) Learn ¶
func (m *Models) Learn(cfg *config.Config, route provider.Route, change func(learned *provider.Facts))
Learn records facts that a reply or a refusal of the route's provider taught about the route's model. change gets the facts learned so far and edits them. The facts are saved for the provider's address and account, so another account learns for itself.
func (*Models) LearnRefusal ¶
LearnRefusal records that the route's provider refused a request field for the route's model, and the remedy the refusal gave, such as the value it takes or "omit". Facts.Refused reads it back.
func (*Models) LearnWindow ¶
LearnWindow records the context window that the route's provider stated in a refusal of a request that was too long. From then on the window is the limit for ContextLength, unless an override sets a window.
func (*Models) Learned ¶
Learned returns the facts that the provider's replies and refusals taught about the route's model on this profile.
func (*Models) Listing ¶
func (m *Models) Listing(ctx context.Context, cfg *config.Config, route provider.Route, refresh bool) ([]provider.Facts, bool)
Listing returns every model the route's provider lists with the facts its listing states, and whether a listing was read now or earlier. A fresh cached copy is returned directly. An old copy is returned while a new read runs in the background, and a copy older than a week is replaced by a new read and stays in use when that read fails. refresh reads the provider now. When no plugin lists the route's kind, the models path at its base URL is read.
func (*Models) Observe ¶
func (m *Models) Observe(cfg *config.Config, route provider.Route, firstEvent, silence time.Duration)
Observe records one successful reply's pace for the route's model: the time to its first event and the longest silence between two events.
func (*Models) OfKind ¶
func (m *Models) OfKind(ctx context.Context, cfg *config.Config, route provider.Route, kind string) []provider.Facts
OfKind returns the route provider's models of one kind, such as speech, transcription, image or embedding, with every known fact, in the provider's order. Without a listing they are the models.dev registry's models of that kind.
func (*Models) OllamaShow ¶
func (m *Models) OllamaShow(ctx context.Context, cfg *config.Config, route provider.Route) (provider.Facts, bool)
OllamaShow returns the facts a server that answers Ollama's show request states for the route's model: its window, and whether it calls tools, thinks and sees images. A plugin for a provider that serves Ollama's API reads its models through it. ok is false when the server does not 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. Approved models lists models but uses none of them.
func (*Models) RefreshDev ¶
RefreshDev fetches the models.dev registry now, asking only for a change when one is held, and keeps it. It returns the reason the registry can't be read. It is nil when the registry answers, or when Fetch details is off.
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) Refusals ¶
Refusals returns the request fields the route's provider refused for the route's model on this profile, each with the remedy the refusal gave.
func (*Models) Register ¶
func (m *Models) Register(registrant Registrant)
Register adds a registrant. A registry registered into the host reaches it through Host.
func (*Models) Registered ¶
func (m *Models) Registered(cfg *config.Config, route provider.Route, network bool) []provider.Facts
Registered returns the facts of every model in the registry block of the route's provider, newest first, then by id. The registry is fetched when network allows it and none is held. It is empty when the route's kind has no models.dev id.
func (*Models) RouteDefault ¶
RouteDefault returns the route provider's default model by the DefaultModel rules, and reads the route's listing when no listing is cached.
func (*Models) Served ¶
func (m *Models) Served(ctx context.Context, cfg *config.Config, route provider.Route) (provider.Facts, bool)
Served returns the facts the server at the route's address states for the route's model, for a server on this machine or at an address that no provider kind claims: Ollama's show reply, otherwise the model's row in the server's models listing, read in the server's own format. ok is false for any other route and when the server does not state any fact.
func (*Models) ServerType ¶
ServerType returns the kind of server at an address that no provider kind claims, found by the endpoints only that kind answers: lm-studio, ollama, llamacpp or vllm. It is empty for a claimed address and when no server answers.
func (*Models) ShownPrice ¶
ShownPrice returns the route model's price for showing beside it, at this moment, the same price Cost bills at the standard tier. Nothing is fetched. ok is false when no source states a price.
func (*Models) Spec ¶
Spec returns the route's kind as its provider has it, its settings resolved, or the kind as its plugin registers it for a route of no provider.
func (*Models) Tallies ¶
Warnings the guards gave and the answers they had in this process, by kind, and by kind and answer
func (*Models) TierPrice ¶
func (m *Models) TierPrice(cfg *config.Config, route provider.Route, tier string) (provider.Price, bool)
TierPrice returns the price Cost bills for a request that the tier served on the route, at this moment, for showing beside the tier. Nothing is fetched. The empty tier, and the standard tier's names (default, standard, auto, on_demand), give the standard price.
func (*Models) TimeoutFloor ¶
TimeoutFloor returns the minimum time a transport waits for the route's model, from the recent successful replies observed on this profile: twice the slowest reply's time, for the first event and for a silence.
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) Usable ¶
Usable returns the tokens a request on the route may fill: the share of the window the provider lets a request use, when its listing states one, otherwise the whole window.
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 ¶
Validate checks the model that a switch to the route requests, without rewriting its id. It refuses an empty id, an id with spaces, which vendor catalogs never use, a model the provider's listing states does not answer in text, or a model missing from the provider's listing. It accepts the model with a note when the models.dev registry's models replace the listing, when no list could be read, or when the listing can omit models. For a model that is not listed, it suggests up to three close matches.
func (*Models) VisionModel ¶
func (m *Models) VisionModel(ctx context.Context, cfg *config.Config, route provider.Route) (string, bool)
VisionModel returns the image side jobs' model at the route's provider: the route's own model when it accepts images, otherwise the cheapest listed chat model that accepts images, otherwise the first such model listed. ok is false when no model on the provider is known to accept images.
type Pace ¶
type Pace struct {
At time.Time `json:"at"`
FirstEvent time.Duration `json:"first_event"`
Silence time.Duration `json:"silence"`
}
Pace records one successful reply's pace: the time from sending the request to the reply's first event, and the longest silence between two of its events.
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 user 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, otherwise what the read under way gives, otherwise 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 any
Registrant is what a plugin registers with the host: a Lister that reads a provider's listing, a Guard that judges a pick, or both. A registry registered into the host's own hands its registrants over.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds the registrants of the host.
func (*Registry) Host ¶
Host returns the host the registry belongs to, through which plugins reach the listings, facts and prices of models.
func (*Registry) Register ¶
func (r *Registry) Register(registrant Registrant)
Register adds a registrant to the host's one list. A registry registered into another hands over its registrants once, then registers into the host and answers as the host does, so no list is nested in another.
type StatusError ¶
Non success status of a request
func (*StatusError) Error ¶
func (e *StatusError) Error() string
type Unlisted ¶
type Unlisted struct {
URL string
Status int
Err error
Shape bool
// None is true when no plugin lists the models of the route's kind and the route has no address to ask.
None 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
type Verdict ¶
Verdict is the outcome of checking the model a switch requests: whether the switch goes ahead, and the message the user gets about 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
// Lasting is true when the user may stop being asked about the model, which adds it to Approved models.
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 user confirms before the pick takes effect
func Costly ¶
func Costly(model string, price provider.Price, priced bool, source string, input, output float64) (Warning, bool)
Costly returns the warning of a model whose known price is strictly past either limit, in dollars for a million tokens. A price at the limit is not past it, and a price that is not known never warns.
func Retiring ¶
Retiring returns the warning of a model whose facts mark it as deprecated. It does not warn for a model no source marks.
func Switching ¶
Switching returns the warning of a switch of a session's model to another while the session has at least the threshold of tokens, which the new model reads again uncached. It does not warn for an unmeasured session, a threshold of 0, an empty model, or the model the session already runs on.