Documentation
¶
Overview ¶
Package modelcatalog reads provider model directories without inference or configuration writes.
Index ¶
- Constants
- Variables
- func DefaultConfigPath() (string, error)
- func ModelURL(base string) (string, error)
- func SafeURL(raw string) string
- func ValidateReasoning(m Model) error
- type Catalog
- type Client
- type Credential
- type Endpoint
- type Model
- type Provider
- type Reasoning
- type Source
- type TokenReference
Constants ¶
const MaxBytes = 1 << 20
Variables ¶
var ErrRunning = errors.New("a probe is already running")
Functions ¶
func DefaultConfigPath ¶
func ValidateReasoning ¶
ValidateReasoning checks shape, not a particular client's fixed vocabulary. A gateway may add values which an individual client must subsequently filter. Duplicate efforts and a default missing from the list are not fatal: callers drop or disable them. Empty or control-character tokens still fail the body.
Types ¶
type Client ¶
type Credential ¶
type Credential struct {
Name string `json:"name,omitempty"`
Selected bool `json:"selected,omitempty"`
Home string `json:"home,omitempty"`
// MaxInFlight caps how many requests this credential serves at once.
// Nil or 0 means unlimited.
MaxInFlight *int `json:"maxInFlight,omitempty"`
// Enabled parks a credential without deleting it. Nil means enabled.
Enabled *bool `json:"enabled,omitempty"`
AuthFile string `json:"authFile,omitempty"`
BaseURL string `json:"baseUrl,omitempty"`
Token string `json:"token,omitempty"`
TokenFile string `json:"tokenFile,omitempty"`
DummyToken string `json:"dummyToken,omitempty"`
}
Credential and Provider are the configuration schema shared with the config UI. They contain secrets: do not use them as an HTTP response or session record.
type Model ¶
type Model struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
DisplayName string `json:"display_name,omitempty"`
ContextWindow int `json:"context_window,omitempty"`
ContextLength int `json:"context_length,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
ReasoningEfforts []string `json:"reasoning_efforts,omitempty"`
DefaultReasoningEffort string `json:"default_reasoning_effort,omitempty"`
}
Model preserves the upstream id verbatim; display names and vendor aliases are not routing ids.
type Provider ¶
type Provider struct {
Name string `json:"name"`
Kind string `json:"kind"`
// LoadBalance routes across this provider's credentials instead of using
// only the selected one. Nil means "on when more than one credential".
LoadBalance *bool `json:"loadBalance,omitempty"`
// RefreshInterval overrides the quota poll interval, e.g. "1m".
RefreshInterval string `json:"refreshInterval,omitempty"`
Subscription bool `json:"subscription,omitempty"`
Home string `json:"home,omitempty"`
AuthFile string `json:"authFile,omitempty"`
Version string `json:"version,omitempty"`
BaseURL string `json:"baseUrl,omitempty"`
Protocol string `json:"protocol,omitempty"`
ModelListMode string `json:"modelListMode,omitempty"`
// SessionHeader is the upstream header that should carry a conversation
// id (for example OpenCode Go's x-opencode-session). When set, the proxy
// copies the first nonempty incoming header from SessionHeaderSources,
// or from SessionHeader itself, onto that name. It does not invent an id.
SessionHeader string `json:"sessionHeader,omitempty"`
SessionHeaderSources []string `json:"sessionHeaderSources,omitempty"`
Token string `json:"token,omitempty"`
TokenFile string `json:"tokenFile,omitempty"`
DummyToken string `json:"dummyToken,omitempty"`
Credentials []Credential `json:"credentials,omitempty"`
}
func (*Provider) ApplySelected ¶
func (p *Provider) ApplySelected()
func (Provider) SelectedCredentialIndex ¶
SelectedCredentialIndex preserves the config UI's first-selected, else first policy.
type Reasoning ¶
type Reasoning struct {
State string `json:"state"`
Source string `json:"source"`
Efforts []string `json:"efforts,omitempty"`
Default string `json:"default,omitempty"`
}
Reasoning is advertised or explicitly configured metadata, never an inference result. Unknown is distinct from unsupported. A disabled generated proxy route alone is not evidence that the upstream cannot reason.
type Source ¶
type Source struct {
Path string `json:"-"`
Name string `json:"name"`
BaseURL string `json:"base_url"`
Protocol string `json:"protocol"`
Reference TokenReference `json:"credential_reference"`
// contains filtered or unexported fields
}
Source is a backend-only snapshot. JSON and diagnostic formatting do not expose credentials.
func ReadSource ¶
ReadSource reads only the named provider and relevant explicit model declarations. Invalid unrelated routes do not prevent discovery; no configuration is changed.
type TokenReference ¶
type TokenReference struct {
File string `json:"file,omitempty"`
JSONPointer string `json:"json_pointer,omitempty"`
Guards map[string]string `json:"guards,omitempty"`
PublicToken string `json:"public_token,omitempty"`
}
TokenReference describes an existing credential without copying its secret. JSON guards keep a reordered or retargeted config from silently changing identity.