config

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 10 Imported by: 0 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 MinLogTotalMB = 20

MinLogTotalMB 是日志目录总量上限的最小值,容纳当前文件与一个轮转文件

Variables

This section is empty.

Functions

func FormatModelMapping added in v0.1.3

func FormatModelMapping(mapping map[string]string) string

FormatModelMapping 按别名排序输出 MODEL_MAPPING 格式的映射

func MapModel

func MapModel(model string) string

MapModel 返回别名对应的真实模型标识

func ModelAliases added in v0.1.3

func ModelAliases() map[string]string

ModelAliases 返回当前模型别名映射的副本

func ParseModelMapping added in v0.1.3

func ParseModelMapping(value string) (map[string]string, error)

ParseModelMapping 解析逗号分隔的“别名:模型 ID”映射

func SetModelMapping

func SetModelMapping(mapping map[string]string)

SetModelMapping 替换当前模型别名映射

func SplitList added in v0.1.3

func SplitList(value string) []string

SplitList 按逗号拆分列表配置,去掉各项首尾空白与空项

func WriteEnv added in v0.1.3

func WriteEnv(path string, values map[string]string) error

WriteEnv 把键值写入 .env:已有键原位替换,新键追加到末尾,其余行与注释保持不变

Types

type Config

type Config struct {
	ListenAddress   string
	AuthStatePaths  []string
	ProxyAPIKey     string
	ProxyURL        string
	AccountCooldown time.Duration
	SessionTTL      time.Duration
	InitTimeout     time.Duration
	ModelMapping    map[string]string
	SaveHistory     bool
	LogLevel        string
	LogFormat       string
	RequestBodyLog  bool
	// LogFile 为 true 时日志同时写入数据目录的轮转文件,LogMaxTotalMB 是日志目录总量上限
	LogFile       bool
	LogMaxTotalMB int
	// PerAccountConcurrency 是每个账号同时进行的上游请求数
	PerAccountConcurrency int
	// RoutingStrategy 为 round-robin 或 fill-first
	RoutingStrategy string
	// AdminAuthEnabled 为 true 时管理端要求登录并接受远程访问
	AdminAuthEnabled bool
	AdminUsername    string
	AdminPassword    string
}

Config 保存服务启动所需的全部配置

func Load

func Load() (Config, error)

Load 从环境变量读取并校验配置

Jump to

Keyboard shortcuts

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