config

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 12 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 LogFileMB = 10

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

View Source
const MediaOutputInline = "inline"

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

View Source
const MediaOutputURL = "url"

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

View Source
const WAABackendCamoufox = "camoufox"

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

View Source
const WAABackendGo = "go"

WAABackendGo 表示由纯 Go VM 承担 WAA 生命周期

Variables

This section is empty.

Functions

func ParseModelChannels added in v0.2.14

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

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

func ParseUpstreamChannels added in v0.2.0

func ParseUpstreamChannels(value string) []string

ParseUpstreamChannels 把逗号分隔的通道列表拆成去空白的小写名称

func ProxyList added in v0.2.12

func ProxyList(value string) []string

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

func ValidateProxy

func ValidateProxy(value string) error

ValidateProxy 校验账户或全局代理 URL

Types

type Config

type Config struct {
	AutoStart              bool          `json:"auto_start"`
	RequestBodyLog         bool          `json:"request_body_log"`
	LogFile                bool          `json:"log_file"`
	LogMaxTotalMB          int           `json:"log_max_total_mb"`
	AdminAuthEnabled       bool          `json:"admin_auth_enabled"`
	AdminUsername          string        `json:"admin_username"`
	AdminPassword          string        `json:"-"`
	BuildNativeNonstream   bool          `json:"build_native_nonstream"`
	NonstreamKeepalive     bool          `json:"nonstream_keepalive"`
	FakeStream             bool          `json:"fake_stream"`
	YouTubeLinks           bool          `json:"youtube_links"`
	AuthStates             string        `json:"auth_states"`
	ListenAddr             string        `json:"listen_addr"`
	PreviewListenAddr      string        `json:"preview_listen_addr"`
	ProxyAPIKey            string        `json:"proxy_api_key"`
	Proxy                  string        `json:"proxy"`
	InitTimeout            time.Duration `json:"-"`
	RequestTimeout         time.Duration `json:"-"`
	WarmWorkerLimit        int           `json:"warm_worker_limit"`
	MaxActiveWorkers       int           `json:"max_active_workers"`
	WarmStartupConcurrency int           `json:"warm_startup_concurrency"`
	PerAccountConcurrency  int           `json:"per_account_concurrency"`
	RoutingStrategy        string        `json:"routing_strategy"`
	UpstreamChannels       []string      `json:"upstream_channels"`
	ModelMapping           string        `json:"model_mapping"`
	ModelChannels          string        `json:"model_channels"`
	TemporaryChat          bool          `json:"temporary_chat"`
	WAABackend             string        `json:"waa_backend"`
	MediaOutput            string        `json:"media_output"`
	MediaBaseURL           string        `json:"media_base_url"`
}

Config 保存服务的全局配置

func Default

func Default() Config

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

func Load

func Load(path string) (Config, error)

Load 从指定 env 文件和进程环境加载配置

func (Config) MarshalJSON

func (c Config) MarshalJSON() ([]byte, error)

MarshalJSON 将时长输出为 env 使用的文本格式

func (Config) Save

func (c Config) Save(path string) error

Save 将配置原子写入指定 env 文件

func (*Config) UnmarshalJSON

func (c *Config) UnmarshalJSON(data []byte) error

UnmarshalJSON 从管理接口使用的文本时长解析配置

func (Config) Validate

func (c Config) Validate() error

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

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