config

package
v0.183.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

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"`
	LogRequests        bool                   `yaml:"logRequests"`
	LogLevel           string                 `yaml:"logLevel"`
	LogTimeFormat      string                 `yaml:"logTimeFormat"`
	LogToStdout        string                 `yaml:"logToStdout"`
	MetricsMaxInMemory int                    `yaml:"metricsMaxInMemory"`
	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 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 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) MarshalYAML

func (ml MacroList) MarshalYAML() (any, error)

MarshalYAML cannot guarantee the order because it returns map[string]any

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"`

	// #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 {
	StripParams string `yaml:"stripParams"`
}

ModelFilters see issue #174

func (ModelFilters) SanitizedStripParams

func (f ModelFilters) SanitizedStripParams() ([]string, error)

func (*ModelFilters) UnmarshalYAML

func (m *ModelFilters) UnmarshalYAML(unmarshal func(interface{}) error) error

type PeerConfig

type PeerConfig struct {
	Proxy    string   `yaml:"proxy"`
	ProxyURL *url.URL `yaml:"-"`
	ApiKey   string   `yaml:"apiKey"`
	Models   []string `yaml:"models"`
}

func (*PeerConfig) UnmarshalYAML

func (c *PeerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

type PeerDictionaryConfig

type PeerDictionaryConfig map[string]PeerConfig

Jump to

Keyboard shortcuts

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