Documentation
¶
Overview ¶
Package admin 提供管理端接口:状态与事件流、账号、模型、请求、日志、用量与设置
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConfigUpdate ¶
type ConfigUpdate struct {
ProxyAPIKey *string `json:"proxy_api_key"`
Proxy *string `json:"proxy"`
SaveHistory *bool `json:"save_history"`
ModelMapping *string `json:"model_mapping"`
AccountCooldown *string `json:"account_cooldown"`
SessionTTL *string `json:"session_ttl"`
InitTimeout *string `json:"init_timeout"`
LogLevel *string `json:"log_level"`
RequestBodyLog *bool `json:"request_body_log"`
LogFile *bool `json:"log_file"`
LogMaxTotalMB *int `json:"log_max_total_mb"`
Concurrency *int `json:"per_account_concurrency"`
RoutingStrategy *string `json:"routing_strategy"`
AdminAuthEnabled *bool `json:"admin_auth_enabled"`
AdminUsername *string `json:"admin_username"`
AdminPassword *string `json:"admin_password"`
ListenAddr *string `json:"listen_addr"`
AuthStates *string `json:"auth_states"`
LogFormat *string `json:"log_format"`
APIKeyAccounts *string `json:"api_key_accounts"`
FirstEventHedge *string `json:"first_event_hedge"`
HedgeModels *string `json:"first_event_hedge_models"`
}
ConfigUpdate 是设置页提交的修改,nil 表示不修改
type Deps ¶
type Deps struct {
Pool *balancer.AccountPool
Accounts *accounts.Manager
Store *requestdb.Store
Settings *Settings
Version string
StartedAt time.Time
ListenAddr string
// ReservedListen 是被 Windows 保留而改用 ListenAddr 的配置地址,没有改用时为空
ReservedListen string
Desktop bool
DataDir string
Updates UpdateService
// Stopping 在服务开始停机时关闭,已打开的事件流随之结束
Stopping <-chan struct{}
}
Deps 是管理端使用的运行期组件与进程信息
type ServiceConfig ¶
type ServiceConfig struct {
ProxyAPIKey string `json:"proxy_api_key"`
Proxy string `json:"proxy"`
SaveHistory bool `json:"save_history"`
ModelMapping string `json:"model_mapping"`
AccountCooldown string `json:"account_cooldown"`
SessionTTL string `json:"session_ttl"`
InitTimeout string `json:"init_timeout"`
LogLevel string `json:"log_level"`
RequestBodyLog bool `json:"request_body_log"`
LogFile bool `json:"log_file"`
LogMaxTotalMB int `json:"log_max_total_mb"`
Concurrency int `json:"per_account_concurrency"`
RoutingStrategy string `json:"routing_strategy"`
AdminAuthEnabled bool `json:"admin_auth_enabled"`
AdminUsername string `json:"admin_username"`
AdminPasswordSet bool `json:"admin_password_set"`
ListenAddr string `json:"listen_addr"`
AuthStates string `json:"auth_states"`
LogFormat string `json:"log_format"`
ActiveListenAddr string `json:"active_listen_addr"`
RestartRequired bool `json:"restart_required"`
RestartFields []string `json:"restart_fields"`
APIKeyAccounts string `json:"api_key_accounts"`
FirstEventHedge string `json:"first_event_hedge"`
FirstEventHedgeModels string `json:"first_event_hedge_models"`
// Invalid 是启动时取值无效、按默认值运行的 .env 项
Invalid []config.InvalidValue `json:"invalid"`
// Locked 是由进程环境变量或启动参数决定的配置项,键为 .env 名,值为 env 或 flag
Locked map[string]string `json:"locked"`
}
ServiceConfig 是管理端设置页的配置视图
type Settings ¶
type Settings struct {
// contains filtered or unexported fields
}
Settings 保存管理端可修改的配置,保存时写回 .env 并即时应用可热更新的项
func NewSettings ¶
NewSettings 以启动时生效的配置创建设置,apply 应用可热更新的项
func (*Settings) Update ¶
func (s *Settings) Update(update ConfigUpdate) error
Update 校验修改,写回 .env 并应用可热更新的项
type UpdateConflict ¶ added in v0.1.6
type UpdateConflict string
UpdateConflict 表示当前状态不能安装更新
func (UpdateConflict) Error ¶ added in v0.1.6
func (err UpdateConflict) Error() string
type UpdateProgress ¶ added in v0.1.7
type UpdateProgress struct {
Stage string `json:"stage"`
Downloaded int64 `json:"downloaded"`
Total int64 `json:"total"`
}
UpdateProgress 是在线更新的阶段(download、verify、install、restart)与发行包的已下载和总字节数,总字节数未知时为 0
type UpdateService ¶ added in v0.1.6
type UpdateService interface {
UpdateStatus(ctx context.Context, refresh bool) (UpdateStatus, error)
ApplyUpdate(ctx context.Context) (UpdateStatus, error)
}
UpdateService 检查并安装 GitHub 上的新发行版本
type UpdateStatus ¶ added in v0.1.6
type UpdateStatus struct {
Current string `json:"current"`
Latest string `json:"latest,omitempty"`
Available bool `json:"available"`
Mode string `json:"mode"`
Notes string `json:"notes,omitempty"`
URL string `json:"url,omitempty"`
PublishedAt time.Time `json:"published_at,omitzero"`
CheckedAt time.Time `json:"checked_at,omitzero"`
Error string `json:"error,omitempty"`
Updating bool `json:"updating"`
// Progress 是进行中的在线更新的阶段与下载字节数
Progress *UpdateProgress `json:"progress,omitempty"`
}
UpdateStatus 是当前版本与 GitHub 最新发行版本,Mode 为 binary(可原地更新)、container(随镜像更新)或 development(源码构建)