config

package
v0.0.0-...-e9a2108 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	LogPath          string   `yaml:"log-path" json:"log-path,omitempty"`
	Debug            bool     `yaml:"debug" json:"debug,omitempty"`
	Verbose          bool     `yaml:"verbose" json:"verbose,omitempty"`
	Listen           string   `yaml:"listen" json:"listen,omitempty"`
	Socks5           string   `yaml:"socks5" json:"socks5,omitempty"`
	Keys             []string `yaml:"keys" json:"-"`
	Policy           string   `yaml:"policy" json:"policy,omitempty"`
	Rules            Rules    `yaml:"rules" json:"rules,omitempty"`
	ExtraModels      []string `yaml:"extra-models" json:"extra-models,omitempty"`
	EnablePrometheus bool     `yaml:"enable-prometheus" json:"enable-prometheus,omitempty"`
}

func LoadConfig

func LoadConfig(configFilePath string) (*Config, error)

func (*Config) JSON

func (conf *Config) JSON() string

func (*Config) Validate

func (conf *Config) Validate() error

type Expr

type Expr struct {
	// Match Expression to determine whether the model matches the current channel
	Match string `yaml:"match,omitempty" json:"match,omitempty"`
	// Replace Expression to replace the model name
	Replace string `yaml:"replace,omitempty" json:"replace,omitempty"`
}

type ModelKey

type ModelKey struct {
	Servers []string `json:"servers,omitempty"`
	Server  string   `json:"server,omitempty"`
	Model   string   `json:"model,omitempty"`
	Models  []string `json:"models,omitempty"`
	Key     string   `json:"key,omitempty"`
	Keys    []string `json:"keys,omitempty"`
}

type ModelRewrite

type ModelRewrite struct {
	Src string `yaml:"src" json:"src"`
	Dst string `yaml:"dst" json:"dst"`
}

type Rule

type Rule struct {
	Name            string           `yaml:"name" json:"name,omitempty"`
	Servers         []string         `yaml:"servers" json:"servers"`
	Keys            []string         `yaml:"keys" json:"-"`
	Models          []string         `yaml:"models" json:"models"`
	ModelKeys       []ModelKey       `yaml:"model-keys" json:"model-keys"`
	Proxy           bool             `yaml:"proxy,omitempty" json:"proxy,omitempty"`
	Type            base.ChannelType `yaml:"type,omitempty" json:"type,omitempty"`
	AzureAPIVersion string           `yaml:"azure-api-version,omitempty" json:"azure-api-version,omitempty"`
	Rewrite         []ModelRewrite   `yaml:"rewrite,omitempty" json:"rewrite,omitempty"`
	// Default Default rule
	Default bool `yaml:"default,omitempty" json:"default,omitempty"`
	// Backup Alternate rule, which is not used by default and is used only when an error occurs
	Backup bool `yaml:"backup,omitempty" json:"backup,omitempty"`
	// Weight, used for the weight policy. The default value is 1. A negative value indicates that the rule is not used
	Weight int `yaml:"weight,omitempty" json:"weight,omitempty"`

	// Advanced configuration
	Expr *Expr `yaml:"expr,omitempty" json:"expr,omitempty"`
}

func (Rule) GetModels

func (rule Rule) GetModels() []string

func (Rule) ModelReplacer

func (rule Rule) ModelReplacer(model string) string

type Rules

type Rules []Rule

Jump to

Keyboard shortcuts

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