config

package
v0.3.16 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 11 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 AccountSwitchIntervalOff = "off"

AccountSwitchIntervalOff 表示换号前不等待最短间隔

View Source
const DefaultContinuationPrompt = "Continue the assistant response after the following prefix. Return only the continuation, without repeating the prefix."

DefaultContinuationPrompt 是 CONTINUATION_PROMPT 未设置时改写末尾 assistant 轮所用的续写提示词

View Source
const DefaultFirstEventHedgeModels = "gemini-4-argon"

DefaultFirstEventHedgeModels 是 FIRST_EVENT_HEDGE_MODELS 的默认值

View Source
const DefaultMaxAccountSwitches = 3

DefaultMaxAccountSwitches 是 MAX_ACCOUNT_SWITCHES 的默认值

View Source
const FirstEventHedgeAuto = "auto"

FirstEventHedgeAuto 表示按模型与通道近期原请求首事件等待的 p95 发起备用请求

View Source
const FirstEventHedgeOff = "off"

FirstEventHedgeOff 表示首事件超时不发起备用请求

View Source
const FirstEventTimeoutOff = "off"

FirstEventTimeoutOff 表示不限制单次尝试等待首个事件的时间

View Source
const LogFileMB = 10

LogFileMB 是单个日志文件的轮转大小

View Source
const MaxQuotaSwitchesOff = "off"

MaxQuotaSwitchesOff 表示额度失败换号次数不限制

View Source
const MediaOutputInline = "inline"

MediaOutputInline 表示 Chat 与 Messages 正文以 data URI 内联生成的媒体

View Source
const MediaOutputURL = "url"

MediaOutputURL 表示生成的媒体保存到本地,Chat 与 Messages 正文以 URL 引用

View Source
const UserMessageRewriteMartian = "martian"

UserMessageRewriteMartian 表示发送前将用户消息中的中文转为火星文

View Source
const UserMessageRewriteOff = "off"

UserMessageRewriteOff 表示不改写用户消息文字

View Source
const UserMessageRewriteTraditional = "traditional"

UserMessageRewriteTraditional 表示发送前将用户消息中的简体中文转为繁体

View Source
const WAABackendCamoufox = "camoufox"

WAABackendCamoufox 表示由 Camoufox 页面承担 WAA 生命周期

View Source
const WAABackendSpiderMonkey = "spidermonkey"

WAABackendSpiderMonkey 表示由进程内的 SpiderMonkey 承担 WAA 生命周期

View Source
const WAAInterpreterCacheName = ".waa-interpreters"

WAAInterpreterCacheName 是账户状态目录中 SpiderMonkey 后端缓存 WAA 解释器的子目录名

Variables

This section is empty.

Functions

func APIKeys added in v0.2.19

func APIKeys(value string) []string

APIKeys 返回 PROXY_API_KEY 中逗号分隔、去掉空白的各个 key

func AccountList added in v0.3.16

func AccountList(value string) []string

AccountList 返回逗号分隔、去掉空白与重复的账户 ID

func ModelList added in v0.2.19

func ModelList(value string) []string

ModelList 解析逗号分隔的模型 ID 列表

func ParseAPIKeyAccounts added in v0.2.19

func ParseAPIKeyAccounts(value string, apiKeys string) (map[string][]string, error)

ParseAPIKeyAccounts 解析逗号分隔的 API key:账户|账户,以最后一个冒号分隔,跳过不在 apiKeys 中的 key

func ParseAccountSwitchInterval added in v0.3.15

func ParseAccountSwitchInterval(value string) (time.Duration, error)

ParseAccountSwitchInterval 解析 ACCOUNT_SWITCH_INTERVAL,返回同一请求内换号前的最短等待间隔,off 时为零值

func ParseFirstEventHedge added in v0.2.17

func ParseFirstEventHedge(value string) (bool, time.Duration, error)

ParseFirstEventHedge 解析 FIRST_EVENT_HEDGE,返回是否按近期 p95 自适应与自定义的等待时长,off 时都为零值

func ParseFirstEventTimeout added in v0.3.14

func ParseFirstEventTimeout(value string) (time.Duration, error)

ParseFirstEventTimeout 解析 FIRST_EVENT_TIMEOUT,返回单次尝试等待首个事件的最长时间,off 时为零值

func ParseMaxQuotaSwitches added in v0.3.15

func ParseMaxQuotaSwitches(value string) (int, bool, error)

ParseMaxQuotaSwitches 解析 MAX_QUOTA_SWITCHES,返回额度失败时的换号次数上限与是否启用上限,off 时不限制

func ParseModelAccounts added in v0.3.3

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

ParseModelAccounts 解析逗号分隔的 模型 ID:账户|账户,以最后一个冒号分隔,返回每个模型可用的账户 ID

func ParseModelChannels added in v0.2.14

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

ParseModelChannels 解析逗号分隔的 模型 ID:通道,返回每个模型限定使用的通道

func ProxyList added in v0.2.12

func ProxyList(value string) []string

ProxyList 返回 PROXY 中以逗号分隔的代理 URL

func ScopedAPIKeys added in v0.3.16

func ScopedAPIKeys(value string, apiKeys string) []string

ScopedAPIKeys 返回 value 中逗号分隔、出现在 apiKeys 里的 key

func ValidateProxy

func ValidateProxy(value string) error

ValidateProxy 校验账户或全局代理 URL

Types

type Config

type Config struct {
	AutoStart              bool
	HideDockIcon           bool
	RequestBodyLog         bool
	LogFile                bool
	LogMaxTotalMB          int
	AdminAuthEnabled       bool
	AdminUsername          string
	AdminPassword          string
	BuildNativeNonstream   bool
	NonstreamKeepalive     bool
	FakeStream             bool
	YouTubeLinks           bool
	StripThoughtSignatures bool
	SearchModelAliases     bool
	DiscoverHiddenModels   bool
	GoogleSearch           bool
	FirstEventHedge        string
	FirstEventHedgeModels  string
	FirstEventTimeout      string
	ContinuationRewrite    bool
	ContinuationPrompt     string
	ReplyTool              bool
	UserMessageRewrite     string
	ThinkingGuard          bool
	AuthStates             string
	ListenAddr             string
	PreviewListenAddr      string
	ProxyAPIKey            string
	APIKeyAccounts         string
	Proxy                  string
	InitTimeout            time.Duration
	RequestTimeout         time.Duration
	WarmWorkerLimit        int
	MaxActiveWorkers       int
	WarmStartupConcurrency int
	PerAccountConcurrency  int
	RoutingStrategy        string
	AccountOrder           string
	MaxAccountSwitches     int
	AccountSwitchInterval  string
	MaxQuotaSwitches       string
	UpstreamChannels       []string
	ModelMapping           string
	ModelChannels          string
	ModelAccounts          string
	WAABackend             string
	MediaOutput            string
	MediaBaseURL           string
	// Invalid 是加载时取值无效、改用默认值的配置项
	Invalid []InvalidValue
	// Environment 是取自进程环境变量、覆盖 .env 的配置键
	Environment []string
	// BuildChatModels 让公开 API 提供并接受 Build 对话模型(-build)
	BuildChatModels bool
	// HideModels 是不在公开 API 中提供的目录模型 ID,逗号分隔
	HideModels string
	// GenerateContentAccounts 是被迁移到任务接口的模型改走 GenerateContent 的账户 ID,逗号分隔
	GenerateContentAccounts string
	// SillyTavernAPIKeys 是 For SillyTavern 各项生效的 API key,逗号分隔,其中没有一个在 PROXY_API_KEY 中时对全部 key 生效
	SillyTavernAPIKeys string
}

Config 保存服务的全局配置

func Default

func Default() Config

Default 返回可直接启动的默认配置

func Load

func Load(path string) (Config, error)

Load 从指定 env 文件和进程环境加载配置,取值无效的项改用默认值并记入 Invalid,没写的常驻预热账户数与启动并发取默认值且不超过活动 Worker 上限

func (Config) KeepEnvironment added in v0.2.19

func (c Config) KeepEnvironment(saved Config) Config

KeepEnvironment 返回把进程环境变量决定的项及其无效记录取 saved 中的值后的配置

func (Config) Save

func (c Config) Save(path string) error

Save 将与默认值不同的配置原子写入指定 env 文件,进程环境变量决定的项保留文件中原有的值;文件中没有的常驻预热账户数与活动 Worker 上限仍等于原后端的默认值时不写入,随后端取默认值

func (Config) Validate

func (c Config) Validate() error

Validate 校验配置值是否能用于服务启动

type InvalidValue added in v0.2.19

type InvalidValue struct {
	Key    string
	Value  string
	Reason string
}

InvalidValue 是加载时取值无效、改用默认值的配置项

type ModelAlias added in v0.2.11

type ModelAlias struct {
	Alias string
	Model string
}

ModelAlias 表示客户端模型名到目录模型 ID 的一项映射

func ParseModelMapping added in v0.2.11

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

ParseModelMapping 解析逗号分隔的 别名:模型 ID,别名可含冒号,以最后一个冒号分隔

Jump to

Keyboard shortcuts

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