config

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	LogToStdoutProxy    = "proxy"
	LogToStdoutUpstream = "upstream"
	LogToStdoutBoth     = "both"
	LogToStdoutNone     = "none"
)
View Source
const DEFAULT_GROUP_ID = "(default)"

Variables

View Source
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 SanitizeCommand(cmdStr string) ([]string, error)

func StripComments

func StripComments(cmdStr string) string

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

func AddDefaultGroupToConfig(config Config) Config

rewrites the yaml to include a default group with any orphaned models

func LoadConfig

func LoadConfig(path string) (Config, error)

func LoadConfigFromReader

func LoadConfigFromReader(r io.Reader) (Config, error)

func (*Config) FindConfig

func (c *Config) FindConfig(modelName string) (ModelConfig, string, bool)

func (*Config) RealModelName

func (c *Config) RealModelName(search string) (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

func (f Filters) SanitizedSetParams() (map[string]any, []string)

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

func (f Filters) SanitizedStripParams() []string

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 MacroEntry struct {
	Name  string
	Value any
}

type MacroList

type MacroList []MacroEntry

func (MacroList) Get

func (ml MacroList) Get(name string) (any, bool)

Get retrieves a macro value by name

func (MacroList) ToMap

func (ml MacroList) ToMap() map[string]any

ToMap converts MacroList to a map (for backward compatibility if needed)

func (*MacroList) UnmarshalYAML

func (ml *MacroList) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements custom YAML unmarshaling that preserves macro definition order

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

type SleepMode

type SleepMode string

SleepMode represents the sleep/wake behavior mode

const (
	SleepModeEnable  SleepMode = SleepMode("enable")
	SleepModeDisable SleepMode = SleepMode("disable")
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL