config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHost     = "127.0.0.1"
	DefaultPort     = 8080
	DefaultLocation = "global"
	DefaultUIMode   = "auto"
)

Variables

View Source
var ErrUsage = errors.New("usage error")

Functions

func IsLoopbackHost

func IsLoopbackHost(host string) bool

Types

type AuthConfig added in v0.2.0

type AuthConfig struct {
	Type               string   `yaml:"type"` // none, bearer, google_adc, oauth_client_credentials
	Token              string   `yaml:"token"`
	TokenURL           string   `yaml:"token_url"`
	ClientID           string   `yaml:"client_id"`
	ClientSecret       string   `yaml:"client_secret"`
	Scopes             []string `yaml:"scopes"`
	InsecureSkipVerify bool     `yaml:"insecure_skip_verify"`
}

AuthConfig describes how to authenticate against a backend.

type BackendConfig added in v0.2.0

type BackendConfig struct {
	Name               string        `yaml:"name"`
	Type               string        `yaml:"type"` // gcp_openai or openai_compatible
	BaseURL            string        `yaml:"base_url"`
	Project            string        `yaml:"project"`
	Location           string        `yaml:"location"`
	InsecureSkipVerify bool          `yaml:"insecure_skip_verify"`
	Auth               AuthConfig    `yaml:"auth"`
	Models             BackendModels `yaml:"models"`
}

BackendConfig describes one upstream backend.

func (*BackendConfig) UpstreamModelID added in v0.2.0

func (bc *BackendConfig) UpstreamModelID(id string) string

UpstreamModelID returns the upstream model ID that should be sent to the backend for the given local model ID.

func (*BackendConfig) VertexBaseURL added in v0.2.0

func (bc *BackendConfig) VertexBaseURL() string

VertexBaseURL computes the Vertex AI OpenAI-compatible base URL for a gcp_openai backend.

type BackendModels added in v0.2.0

type BackendModels struct {
	All    bool
	Models []Model
}

BackendModels holds either "all" (pass-through) or an explicit list of models.

func (*BackendModels) UnmarshalYAML added in v0.2.0

func (bm *BackendModels) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML supports both `models: all` and `models: [{id: ...}]`.

type Config

type Config struct {
	Server     ServerConfig    `yaml:"server"`
	Backends   []BackendConfig `yaml:"backends"`
	UI         UIConfig        `yaml:"ui"`
	Verbose    bool            `yaml:"verbose"`
	SourcePath string          `yaml:"-"`
}

func Load

func Load(flags Flags) (*Config, error)

func (*Config) Address

func (c *Config) Address() string

func (*Config) AllModels added in v0.2.0

func (c *Config) AllModels() []Model

AllModels returns all explicitly-listed models across all backends (excludes "models: all" backends).

func (*Config) BackendForModel added in v0.2.0

func (c *Config) BackendForModel(id string) *BackendConfig

BackendForModel returns the first backend that serves the given model ID. Exact-listed models take priority over "models: all" pass-through backends.

func (*Config) LocalModelID

func (c *Config) LocalModelID(upstreamID string) string

LocalModelID translates an upstream model ID back to the local model ID.

func (*Config) Validate

func (c *Config) Validate() error

type Flags

type Flags struct {
	ConfigPath string
	Host       string
	Port       int
	UIMode     string
	Verbose    bool
}

type Model

type Model struct {
	ID         string `yaml:"id"`
	UpstreamID string `yaml:"upstream_id"`
}

type ServerConfig

type ServerConfig struct {
	Host string `yaml:"host"`
	Port int    `yaml:"port"`
}

type UIConfig

type UIConfig struct {
	Mode string `yaml:"mode"`
}

Jump to

Keyboard shortcuts

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