config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	Name        string             `yaml:"name" json:"name"`
	URL         string             `yaml:"url" json:"url"`
	Protocol    string             `yaml:"protocol" json:"protocol"`
	Headers     map[string]string  `yaml:"headers" json:"headers"`
	Models      []Model            `yaml:"models" json:"models"`
	PathPrefix  string             `yaml:"path_prefix" json:"path_prefix"`
	StripPrefix bool               `yaml:"strip_prefix" json:"strip_prefix"`
	Default     bool               `yaml:"default" json:"default"`
	Priority    int                `yaml:"priority" json:"priority"`
	Weight      int                `yaml:"weight" json:"weight"`
	Timeout     string             `yaml:"timeout" json:"timeout"`   // per-backend request timeout, e.g. "120s"; empty = use global default
	SSEOnly     bool               `yaml:"sse_only" json:"sse_only"` // when true, WS clients use HTTP SSE directly (skip WS dial)
	HealthCheck *HealthCheckConfig `yaml:"health_check" json:"health_check"`
}

type CircuitBreakerConfig

type CircuitBreakerConfig struct {
	FailThreshold       int    `yaml:"fail_threshold" json:"fail_threshold"`
	RecoveryTimeout     string `yaml:"recovery_timeout" json:"recovery_timeout"`
	HalfOpenMaxRequests int    `yaml:"half_open_max_requests" json:"half_open_max_requests"`
}

type Config

type Config struct {
	Listen                string                        `yaml:"listen"`
	Debug                 bool                          `yaml:"debug"`
	MaxConcurrentRequests int                           `yaml:"max_concurrent_requests"` // 0 = unlimited
	Backends              []Backend                     `yaml:"backends"`
	TokenLog              TokenLogConfig                `yaml:"token_log"`
	APIKeys               map[string]string             `yaml:"api_keys"`
	ModelDefaults         map[string]ModelDefaultConfig `yaml:"model_defaults"`
	SystemPrompt          string                        `yaml:"system_prompt"`
	CircuitBreaker        CircuitBreakerConfig          `yaml:"circuit_breaker"`
	Console               ConsoleConfig                 `yaml:"console"`
	TrustedProxies        []string                      `yaml:"trusted_proxies"` // IPs or CIDRs; empty = only use RemoteAddr
}

func LoadConfig

func LoadConfig(path string) (Config, error)

func NormalizeAndValidate

func NormalizeAndValidate(cfg Config) (Config, error)

type ConsoleConfig

type ConsoleConfig struct {
	Enabled  bool   `yaml:"enabled" json:"enabled"`
	Password string `yaml:"password" json:"password"`
}

type HealthCheckConfig

type HealthCheckConfig struct {
	Path     string `yaml:"path" json:"path"`
	Interval string `yaml:"interval" json:"interval"`
}

type Model

type Model struct {
	Name                          string   `yaml:"name" json:"name"`
	Aliases                       []string `yaml:"aliases" json:"aliases"`
	ReasoningDefaultEffort        string   `yaml:"reasoning_default_effort" json:"reasoning_default_effort"`
	SystemPrompt                  string   `yaml:"system_prompt" json:"system_prompt"`
	DefaultMaxTokens              int      `yaml:"default_max_tokens" json:"default_max_tokens"`
	NormalizeXHighReasoningEffort bool     `yaml:"normalize_xhigh_reasoning_effort" json:"normalize_xhigh_reasoning_effort"`
	DefaultTemperature            *float64 `yaml:"default_temperature,omitempty" json:"default_temperature,omitempty"`
}

type ModelDefaultConfig

type ModelDefaultConfig struct {
	ReasoningEffort               string   `yaml:"reasoning_effort" json:"reasoning_effort"`
	MaxTokens                     int      `yaml:"max_tokens" json:"max_tokens"`
	SystemPrompt                  string   `yaml:"system_prompt" json:"system_prompt"`
	NormalizeXHighReasoningEffort bool     `yaml:"normalize_xhigh_reasoning_effort" json:"normalize_xhigh_reasoning_effort"`
	DefaultTemperature            *float64 `yaml:"default_temperature,omitempty" json:"default_temperature,omitempty"`
}

type TokenLogConfig

type TokenLogConfig struct {
	Enabled       bool   `yaml:"enabled" json:"enabled"`
	File          string `yaml:"file" json:"file"`
	RetentionDays int    `yaml:"retention_days" json:"retention_days"` // 0 = no cleanup
}

Jump to

Keyboard shortcuts

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