Documentation
¶
Overview ¶
Package model provides a unified model registry for centralized endpoint configuration, capability-based routing, and tool capability metadata.
Index ¶
- type CapabilityConfig
- type DefaultsConfig
- type EndpointConfig
- type Registry
- func (r *Registry) GetDefault() string
- func (r *Registry) GetEndpoint(name string) *EndpointConfig
- func (r *Registry) GetFallbackChain(capability string) []string
- func (r *Registry) GetMaxTokens(name string) int
- func (r *Registry) ListCapabilities() []string
- func (r *Registry) ListEndpoints() []string
- func (r *Registry) Resolve(capability string) string
- func (r *Registry) Validate() error
- type RegistryReader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CapabilityConfig ¶
type CapabilityConfig struct {
// Description explains what this capability is for.
Description string `json:"description,omitempty"`
// Preferred lists endpoint names in order of preference.
Preferred []string `json:"preferred"`
// Fallback lists backup endpoint names if all preferred are unavailable.
Fallback []string `json:"fallback,omitempty"`
// RequiresTools filters the chain to only tool-capable endpoints.
RequiresTools bool `json:"requires_tools,omitempty"`
}
CapabilityConfig defines model preferences for a capability.
type DefaultsConfig ¶
type DefaultsConfig struct {
// Model is the default endpoint name when no capability matches.
Model string `json:"model"`
// Capability is the default capability when none specified.
Capability string `json:"capability,omitempty"`
}
DefaultsConfig holds default model settings.
type EndpointConfig ¶
type EndpointConfig struct {
// Provider identifies the API type: "anthropic", "ollama", "openai", "openrouter".
Provider string `json:"provider"`
// URL is the API endpoint. Required for ollama/openai/openrouter, optional for anthropic.
URL string `json:"url,omitempty"`
// Model is the model identifier sent to the provider.
Model string `json:"model"`
// MaxTokens is the context window size in tokens.
MaxTokens int `json:"max_tokens"`
// SupportsTools indicates whether this endpoint supports function/tool calling.
SupportsTools bool `json:"supports_tools,omitempty"`
// ToolFormat specifies the tool calling format: "anthropic" or "openai".
// Empty means auto-detect from provider.
ToolFormat string `json:"tool_format,omitempty"`
// APIKeyEnv is the environment variable containing the API key.
// Required for anthropic/openai/openrouter, ignored for ollama.
APIKeyEnv string `json:"api_key_env,omitempty"`
// Options holds provider-specific template parameters passed to the API.
// For vLLM/ollama with thinking models, set "enable_thinking" and
// "thinking_budget" here — they are forwarded as chat_template_kwargs.
// Do not use for inference parameters (temperature, top_k, etc.) which
// have dedicated fields in AgentRequest.
Options map[string]any `json:"options,omitempty"`
}
EndpointConfig defines an available model endpoint.
type Registry ¶
type Registry struct {
Capabilities map[string]*CapabilityConfig `json:"capabilities,omitempty"`
Endpoints map[string]*EndpointConfig `json:"endpoints"`
Defaults DefaultsConfig `json:"defaults"`
}
Registry holds all model endpoint definitions and capability routing. It is JSON-serializable for config loading and implements RegistryReader.
func (*Registry) GetDefault ¶
GetDefault returns the default endpoint name.
func (*Registry) GetEndpoint ¶
func (r *Registry) GetEndpoint(name string) *EndpointConfig
GetEndpoint returns the endpoint configuration for a name, or nil if not found.
func (*Registry) GetFallbackChain ¶
GetFallbackChain returns all endpoint names for a capability in preference order.
func (*Registry) GetMaxTokens ¶
GetMaxTokens returns the context window size for an endpoint name.
func (*Registry) ListCapabilities ¶
ListCapabilities returns all configured capability names sorted alphabetically.
func (*Registry) ListEndpoints ¶
ListEndpoints returns all configured endpoint names sorted alphabetically.
type RegistryReader ¶
type RegistryReader interface {
// Resolve returns the preferred endpoint name for a capability.
// Returns the first endpoint in the preferred list.
// If RequiresTools is set, filters to tool-capable endpoints.
Resolve(capability string) string
// GetFallbackChain returns all endpoint names for a capability in preference order.
// Includes both preferred and fallback endpoints.
GetFallbackChain(capability string) []string
// GetEndpoint returns the full endpoint configuration for an endpoint name.
// Returns nil if the endpoint is not configured.
GetEndpoint(name string) *EndpointConfig
// GetMaxTokens returns the context window size for an endpoint name.
// Returns 0 if the endpoint is not configured.
GetMaxTokens(name string) int
// GetDefault returns the default endpoint name.
GetDefault() string
// ListCapabilities returns all configured capability names sorted alphabetically.
ListCapabilities() []string
// ListEndpoints returns all configured endpoint names sorted alphabetically.
ListEndpoints() []string
}
RegistryReader provides read-only access to the model registry. Components receive this interface via Dependencies.