Documentation
¶
Overview ¶
Named endpoint configurations and the credentials that turn them into providers
Index ¶
- Constants
- func AddCatalog(models ...Model)
- func ConfigDir() (string, error)
- func DoJSON(ctx context.Context, p *provider.Provider, call protocol.Call, v any) error
- func GetJSON(ctx context.Context, p *provider.Provider, path string, query url.Values, ...) error
- func Normalize(id string) string
- func Register(p Profile)
- func RegisterAuth(kind AuthKind, b AuthBuilder)
- func RegisterVendor(v Vendor)
- func UserPath() (string, error)
- func ValidName(name string) bool
- func Vendors() []string
- func WriteFile(path string, d Document) error
- type AuthBuilder
- type AuthKind
- type Capabilities
- type CredentialState
- type Document
- type Model
- type Pricing
- type Profile
- func (p Profile) Build(key string) (*provider.Provider, error)
- func (p Profile) Clone() Profile
- func (p Profile) Credential(ctx context.Context) (CredentialState, string, error)
- func (p Profile) Expand() (Profile, error)
- func (p Profile) ExpandsThinking() bool
- func (p Profile) ListModels(ctx context.Context, prov *provider.Provider) ([]Model, error)
- func (p Profile) Model() string
- func (p Profile) Open(ctx context.Context) (*provider.Provider, error)
- func (p Profile) Resolved() Profile
- func (p Profile) Validate() error
- type Source
- type SourceKind
- type Vendor
Constants ¶
const ConfigDirEnv = "ICEBATH_CONFIG_DIR"
Environment variable naming the directory every icebath configuration file lives in
const ExecTimeout = 15 * time.Second
Budget for an exec source
Variables ¶
This section is empty.
Functions ¶
func AddCatalog ¶
func AddCatalog(models ...Model)
Adds models whose metadata wins over the built in catalog for the same id
func ConfigDir ¶
Directory holding icebath configuration, the environment override, else icebath under the user configuration directory
func Register ¶
func Register(p Profile)
Makes a built in profile available to Lookup, panicking on an invalid or duplicate one
func RegisterAuth ¶
func RegisterAuth(kind AuthKind, b AuthBuilder)
Makes an auth kind buildable, panicking on a duplicate or a generic kind
func RegisterVendor ¶
func RegisterVendor(v Vendor)
Makes a vendor available to profiles naming it, panicking on a duplicate
Types ¶
type AuthBuilder ¶
Builds the credential carrier for an auth kind the generic layer does not know
type AuthKind ¶
type AuthKind string
How a credential travels on the request
const AuthSigV4 AuthKind = "aws-sigv4"
Auth kind signing requests with AWS credentials
type Capabilities ¶
type Capabilities struct {
Tools bool `json:"tools"`
Vision bool `json:"vision"`
Thinking bool `json:"thinking"`
Documents bool `json:"documents"`
}
What a model accepts on the request side
type CredentialState ¶
type CredentialState string
Where a profile credential stands
const ( CredentialUnneeded CredentialState = "none needed" CredentialSet CredentialState = "set" CredentialMissing CredentialState = "missing" )
type Document ¶
Profile list as written, with the name of the profile used when the configuration names none
func Read ¶
Reads a list of profiles, or an object holding the list under profiles beside the default name
func (*Document) Put ¶
Replaces the profile named old, or appends p when old is empty, keeping its place in the order
type Model ¶
type Model struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
Vendor string `json:"vendor,omitempty"`
Context int `json:"context,omitempty"`
MaxOutput int `json:"max_output,omitempty"`
// Unix seconds when the endpoint reports a creation time
Created int64 `json:"created,omitempty"`
Pricing *Pricing `json:"pricing,omitempty"`
Capabilities *Capabilities `json:"capabilities,omitempty"`
}
One model an endpoint serves, with zero for limits the endpoint does not report and nil for metadata it does not know
func Catalog ¶
func Catalog() []Model
Every model the built in catalog and any added lists describe, added entries first
func Describe ¶
Catalog entry for a model id in any vendor spelling, matching the longest known id the normalized form starts with
func Enrich ¶
Fills the context, output limit, pricing and capabilities a listing left blank from the catalog
func LoadCatalog ¶
Reads a catalog JSON file, a list or an object with a models list, and adds it
func LoadCatalogFile ¶
type Pricing ¶
type Pricing struct {
Input float64 `json:"input"`
Output float64 `json:"output"`
CacheRead float64 `json:"cache_read,omitempty"`
CacheWrite float64 `json:"cache_write,omitempty"`
}
Dollars per million tokens of each usage kind, zero where the endpoint charges nothing or the rate is unknown
type Profile ¶
type Profile struct {
Name string `json:"name"`
// Built in profile this one starts from, filling every field left empty
Template string `json:"template,omitempty"`
// Kept out of pickers and refused when chosen
Disabled bool `json:"disabled,omitempty"`
// Family of the endpoint, naming the registered vendor whose conventions apply
Vendor string `json:"vendor,omitempty"`
Protocol protocol.ID `json:"protocol,omitempty"`
BaseURL string `json:"base_url,omitempty"`
Auth AuthKind `json:"auth,omitempty"`
// Header or query parameter name carrying the credential
AuthName string `json:"auth_name,omitempty"`
// Where the credential comes from
Key Source `json:"key,omitzero"`
// Static headers the endpoint expects on every request
Header http.Header `json:"header,omitempty"`
// Static query parameters the endpoint expects on every request
Query url.Values `json:"query,omitempty"`
// Model ids the endpoint is known to serve, the first being the default
Models []string `json:"models,omitempty"`
// Environment variable whose value replaces the base URL when set
BaseURLEnv string `json:"base_url_env,omitempty"`
// Request fields merged into every turn sent through the endpoint
Extra map[string]json.RawMessage `json:"extra,omitempty"`
// Base prompt sent in place of the built in one, none sending no prompt at all
System Source `json:"system,omitzero"`
// Leaves the environment block about the machine and session out of the system prompt
NoContext bool `json:"no_context,omitempty"`
// Asks the endpoint to add no prompt or tools of its own
Bare bool `json:"bare,omitempty"`
// Keeps sessions off disk and asks the endpoint to keep nothing of them
Ghost bool `json:"ghost,omitempty"`
// Opens every thinking block in the transcript as it arrives, nil taking the template's
ExpandThinking *bool `json:"expand_thinking,omitempty"`
// Headers and body fields that ask the endpoint to keep nothing, nil taking the template's
GhostDirective *provider.Directive `json:"ghost_directive,omitempty"`
// Headers and body fields that ask the endpoint to add nothing of its own, nil taking the template's
BareDirective *provider.Directive `json:"bare_directive,omitempty"`
// Settings read by registered auth builders and vendors
Options map[string]string `json:"options,omitempty"`
}
Declarative description of one endpoint and where its credential comes from
func Defaults ¶
func Defaults() []Profile
Built in profiles sorted by name, each a copy that leaves the registry untouched
func (Profile) Build ¶
Builds a provider from the profile and a credential, resolving the protocol from the registry
func (Profile) Credential ¶
Checks that the profile can produce its credential without sending a request, naming the source rather than the key
func (Profile) Expand ¶
Profile with every empty field taken from its template, unchanged without one
func (Profile) ExpandsThinking ¶ added in v1.0.14
Reports whether thinking blocks open as they arrive, which they do only when the profile asks
func (Profile) ListModels ¶
Lists the models the endpoint serves through the vendor the profile names
func (Profile) Open ¶
Builds a provider with the credential read from the key source and the base URL override applied
type Source ¶
type Source struct {
Kind SourceKind `json:"kind,omitempty"`
Value string `json:"value,omitempty"`
}
One source of text, the zero value yielding none
func (*Source) UnmarshalJSON ¶
Accepts the object form or a string joining kind and value with a colon
type SourceKind ¶
type SourceKind string
Where a text such as a credential or a prompt comes from
const ( // Value names an environment variable SourceEnv SourceKind = "env" // Value is the text itself SourceStatic SourceKind = "static" // Value is a path whose trimmed contents are the text SourceFile SourceKind = "file" // Value is a shell command whose trimmed output is the text SourceExec SourceKind = "exec" // No text, kept over the source of a template SourceNone SourceKind = "none" )