Documentation
¶
Index ¶
- Constants
- Variables
- func SanitizeCommand(cmdStr string) ([]string, error)
- func StripComments(cmdStr string) string
- type Config
- type Filters
- type GroupConfig
- type HTTPEndpoint
- type HookOnStartup
- type HooksConfig
- type MacroEntry
- type MacroList
- type ModelConfig
- type ModelFilters
- type PeerConfig
- type PeerDictionaryConfig
- type SleepMode
Constants ¶
const ( LogToStdoutProxy = "proxy" LogToStdoutUpstream = "upstream" LogToStdoutBoth = "both" LogToStdoutNone = "none" )
const DEFAULT_GROUP_ID = "(default)"
Variables ¶
var ProtectedParams = []string{"model"}
ProtectedParams is a list of parameters that cannot be set or stripped via filters These are protected to prevent breaking the proxy's ability to route requests correctly
Functions ¶
func SanitizeCommand ¶
func StripComments ¶
Types ¶
type Config ¶
type Config struct {
HealthCheckTimeout int `yaml:"healthCheckTimeout"`
SleepRequestTimeout int `yaml:"sleepRequestTimeout"`
WakeRequestTimeout int `yaml:"wakeRequestTimeout"`
LogRequests bool `yaml:"logRequests"`
LogLevel string `yaml:"logLevel"`
LogTimeFormat string `yaml:"logTimeFormat"`
LogToStdout string `yaml:"logToStdout"`
MetricsMaxInMemory int `yaml:"metricsMaxInMemory"`
CaptureBuffer int `yaml:"captureBuffer"`
Models map[string]ModelConfig `yaml:"models"` /* key is model ID */
Profiles map[string][]string `yaml:"profiles"`
Groups map[string]GroupConfig `yaml:"groups"` /* key is group ID */
// for key/value replacements in model's cmd, cmdStop, proxy, checkEndPoint
Macros MacroList `yaml:"macros"`
// automatic port assignments
StartPort int `yaml:"startPort"`
// hooks, see: #209
Hooks HooksConfig `yaml:"hooks"`
// send loading state in reasoning
SendLoadingState bool `yaml:"sendLoadingState"`
// present aliases to /v1/models OpenAI API listing
IncludeAliasesInList bool `yaml:"includeAliasesInList"`
// support API keys, see issue #433, #50, #251
RequiredAPIKeys []string `yaml:"apiKeys"`
// support remote peers, see issue #433, #296
Peers PeerDictionaryConfig `yaml:"peers"`
// contains filtered or unexported fields
}
func AddDefaultGroupToConfig ¶
rewrites the yaml to include a default group with any orphaned models
func LoadConfig ¶
func (*Config) FindConfig ¶
func (c *Config) FindConfig(modelName string) (ModelConfig, string, bool)
type Filters ¶ added in v0.0.4
type Filters struct {
// StripParams is a comma-separated list of parameters to remove from requests
// The "model" parameter can never be removed
StripParams string `yaml:"stripParams"`
// SetParams is a dictionary of parameters to set/override in requests
// Protected params (like "model") cannot be set
SetParams map[string]any `yaml:"setParams"`
}
Filters contains filter settings for modifying request parameters Used by both models and peers
func (Filters) SanitizedSetParams ¶ added in v0.0.4
SanitizedSetParams returns a copy of SetParams with protected params removed and keys sorted for consistent iteration order
func (Filters) SanitizedStripParams ¶ added in v0.0.4
SanitizedStripParams returns a sorted list of parameters to strip, with duplicates, empty strings, and protected params removed
type GroupConfig ¶
type GroupConfig struct {
Swap bool `yaml:"swap"`
Exclusive bool `yaml:"exclusive"`
Persistent bool `yaml:"persistent"`
Members []string `yaml:"members"`
}
func (*GroupConfig) UnmarshalYAML ¶
func (c *GroupConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
set default values for GroupConfig
type HTTPEndpoint ¶
type HTTPEndpoint struct {
Endpoint string `yaml:"endpoint"` // URL path (e.g., "/wake_up")
Method string `yaml:"method"` // HTTP method (GET, POST, PUT, PATCH)
Body string `yaml:"body"` // Optional request body (JSON string)
Timeout int `yaml:"timeout"` // Optional per-endpoint timeout (seconds)
}
HTTPEndpoint represents a single HTTP endpoint configuration
type HookOnStartup ¶
type HookOnStartup struct {
Preload []string `yaml:"preload"`
}
type HooksConfig ¶
type HooksConfig struct {
OnStartup HookOnStartup `yaml:"on_startup"`
}
type MacroEntry ¶
type MacroList ¶
type MacroList []MacroEntry
type ModelConfig ¶
type ModelConfig struct {
Cmd string `yaml:"cmd"`
CmdStop string `yaml:"cmdStop"`
Proxy string `yaml:"proxy"`
Aliases []string `yaml:"aliases"`
Env []string `yaml:"env"`
CheckEndpoint string `yaml:"checkEndpoint"`
UnloadAfter int `yaml:"ttl"`
Unlisted bool `yaml:"unlisted"`
UseModelName string `yaml:"useModelName"`
// SleepMode explicitly controls sleep/wake behavior
// Valid values: SleepModeEnable, SleepModeDisable
// Future values may include: "auto", "level1", "level2"
SleepMode SleepMode `yaml:"sleepMode"`
// Array-based sleep/wake configuration
SleepEndpoints []HTTPEndpoint `yaml:"sleepEndpoints"`
WakeEndpoints []HTTPEndpoint `yaml:"wakeEndpoints"`
// #179 for /v1/models
Name string `yaml:"name"`
Description string `yaml:"description"`
// Limit concurrency of HTTP requests to process
ConcurrencyLimit int `yaml:"concurrencyLimit"`
// Model filters see issue #174
Filters ModelFilters `yaml:"filters"`
// Macros: see #264
// Model level macros take precedence over the global macros
Macros MacroList `yaml:"macros"`
// Metadata: see #264
// Arbitrary metadata that can be exposed through the API
Metadata map[string]any `yaml:"metadata"`
// override global setting
SendLoadingState *bool `yaml:"sendLoadingState"`
}
func (*ModelConfig) SanitizedCommand ¶
func (m *ModelConfig) SanitizedCommand() ([]string, error)
func (*ModelConfig) UnmarshalYAML ¶
func (m *ModelConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
type ModelFilters ¶
type ModelFilters struct {
Filters `yaml:",inline"`
}
ModelFilters embeds Filters and adds legacy support for strip_params field See issue #174
func (ModelFilters) SanitizedStripParams ¶
func (f ModelFilters) SanitizedStripParams() ([]string, error)
SanitizedStripParams wraps Filters.SanitizedStripParams for backwards compatibility Returns ([]string, error) to match existing API
func (*ModelFilters) UnmarshalYAML ¶
func (m *ModelFilters) UnmarshalYAML(unmarshal func(interface{}) error) error
type PeerConfig ¶ added in v0.0.4
type PeerConfig struct {
Proxy string `yaml:"proxy"`
ProxyURL *url.URL `yaml:"-"`
ApiKey string `yaml:"apiKey"`
Models []string `yaml:"models"`
Filters Filters `yaml:"filters"`
}
func (*PeerConfig) UnmarshalYAML ¶ added in v0.0.4
func (c *PeerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
type PeerDictionaryConfig ¶ added in v0.0.4
type PeerDictionaryConfig map[string]PeerConfig