operation_setting

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QuotaDisplayTypeUSD    = "USD"
	QuotaDisplayTypeCNY    = "CNY"
	QuotaDisplayTypeTokens = "TOKENS"
	QuotaDisplayTypeCustom = "CUSTOM"
)

额度展示类型

View Source
const (
	// Web search
	WebSearchPriceHigh = 25.00
	WebSearchPrice     = 10.00
	// File search
	FileSearchPrice = 2.5
)
View Source
const (
	GPTImage1Low1024x1024    = 0.011
	GPTImage1Low1024x1536    = 0.016
	GPTImage1Low1536x1024    = 0.016
	GPTImage1Medium1024x1024 = 0.042
	GPTImage1Medium1024x1536 = 0.063
	GPTImage1Medium1536x1024 = 0.063
	GPTImage1High1024x1024   = 0.167
	GPTImage1High1024x1536   = 0.25
	GPTImage1High1536x1024   = 0.25
)
View Source
const (
	// Gemini Audio Input Price
	Gemini25FlashPreviewInputAudioPrice     = 1.00
	Gemini25FlashProductionInputAudioPrice  = 1.00 // for `gemini-2.5-flash`
	Gemini25FlashLitePreviewInputAudioPrice = 0.50
	Gemini25FlashNativeAudioInputAudioPrice = 3.00
	Gemini20FlashInputAudioPrice            = 0.70
	GeminiRoboticsER15InputAudioPrice       = 1.00
)
View Source
const (
	// Claude Web search
	ClaudeWebSearchPrice = 10.00
)

Variables

View Source
var AutomaticDisableKeywords = []string{
	"Your credit balance is too low",
	"This organization has been disabled.",
	"You exceeded your current quota",
	"Permission denied",
	"The security token included in the request is invalid",
	"Operation not allowed",
	"Your account is not authorized",
}
View Source
var AutomaticDisableStatusCodeRanges = []StatusCodeRange{{Start: 401, End: 401}}
View Source
var AutomaticRetryStatusCodeRanges = []StatusCodeRange{
	{Start: 100, End: 199},
	{Start: 300, End: 399},
	{Start: 401, End: 407},
	{Start: 409, End: 499},
	{Start: 500, End: 503},
	{Start: 505, End: 523},
	{Start: 525, End: 599},
}

Default behavior matches legacy hardcoded retry rules in controller/relay.go shouldRetry: retry for 1xx, 3xx, 4xx(except 400/408), 5xx(except 504/524), and no retry for 2xx.

View Source
var CustomCallbackAddress = ""
View Source
var DemoSiteEnabled = false
View Source
var EpayId = ""
View Source
var EpayKey = ""
View Source
var MinTopUp = 1
View Source
var PayAddress = ""
View Source
var PayMethods = []map[string]string{
	{
		"name":  "支付宝",
		"color": "rgba(var(--semi-blue-5), 1)",
		"type":  "alipay",
	},
	{
		"name":  "微信",
		"color": "rgba(var(--semi-green-5), 1)",
		"type":  "wxpay",
	},
	{
		"name":      "自定义1",
		"color":     "black",
		"type":      "custom1",
		"min_topup": "50",
	},
}
View Source
var Price = 7.3
View Source
var SelfUseModeEnabled = false
View Source
var USDExchangeRate = 7.3

Functions

func AutomaticDisableKeywordsFromString

func AutomaticDisableKeywordsFromString(s string)

func AutomaticDisableKeywordsToString

func AutomaticDisableKeywordsToString() string

func AutomaticDisableStatusCodesFromString

func AutomaticDisableStatusCodesFromString(s string) error

func AutomaticDisableStatusCodesToString

func AutomaticDisableStatusCodesToString() string

func AutomaticRetryStatusCodesFromString

func AutomaticRetryStatusCodesFromString(s string) error

func AutomaticRetryStatusCodesToString

func AutomaticRetryStatusCodesToString() string

func ContainsPayMethod

func ContainsPayMethod(method string) bool

func GetAuctionBidIncrement

func GetAuctionBidIncrement() float64

func GetCheckinQuotaRange

func GetCheckinQuotaRange() (min, max int)

GetCheckinQuotaRange 获取签到额度范围

func GetClaudeWebSearchPricePerThousand

func GetClaudeWebSearchPricePerThousand() float64

func GetCleanBoost

func GetCleanBoost() int

func GetCleanDailyLimit

func GetCleanDailyLimit() int

func GetCleanExp

func GetCleanExp() int

func GetCleanlinessDecayPerHour

func GetCleanlinessDecayPerHour() int

func GetCurrencySymbol

func GetCurrencySymbol() string

GetCurrencySymbol 返回当前展示类型对应符号

func GetEvolutionStage1Level

func GetEvolutionStage1Level() int

func GetEvolutionStage2Level

func GetEvolutionStage2Level() int

func GetFeedExp

func GetFeedExp() int

func GetFileSearchPricePerThousand

func GetFileSearchPricePerThousand() float64

func GetFusionBaseCost

func GetFusionBaseCost() int

func GetGPTImage1PriceOnceCall

func GetGPTImage1PriceOnceCall(quality string, size string) float64

func GetGeminiInputAudioPricePerMillionTokens

func GetGeminiInputAudioPricePerMillionTokens(modelName string) float64

func GetHatchDurationMinutes

func GetHatchDurationMinutes() int

func GetHungerDecayPerHour

func GetHungerDecayPerHour() int

func GetLevelExpMultiplier

func GetLevelExpMultiplier() int

func GetMarketFeeRate

func GetMarketFeeRate() float64

func GetMaxLevel

func GetMaxLevel() int

func GetMaxPetsPerUser

func GetMaxPetsPerUser() int

GetMaxPetsPerUser 获取每用户最大宠物数

func GetMaxPostLength

func GetMaxPostLength() int

GetMaxPostLength 获取帖子最大字数

func GetMaxStar

func GetMaxStar() int

func GetMaxUserTokens

func GetMaxUserTokens() int

GetMaxUserTokens 获取每用户最大令牌数量

func GetMoodDecayPerHour

func GetMoodDecayPerHour() int

func GetPlayCooldownMinutes

func GetPlayCooldownMinutes() int

func GetPlayExp

func GetPlayExp() int

func GetPlayMoodBoost

func GetPlayMoodBoost() int

func GetQuotaDisplayType

func GetQuotaDisplayType() string

GetQuotaDisplayType 返回额度展示类型

func GetUsdToCurrencyRate

func GetUsdToCurrencyRate(usdToCny float64) float64

GetUsdToCurrencyRate 返回 1 USD = X <currency> 的 X(TOKENS 不适用)

func GetWebSearchPricePerThousand

func GetWebSearchPricePerThousand(modelName string, contextSize string) float64

func IsAlwaysSkipRetryCode

func IsAlwaysSkipRetryCode(errorCode types.ErrorCode) bool

func IsAlwaysSkipRetryStatusCode

func IsAlwaysSkipRetryStatusCode(code int) bool

func IsCNYDisplay

func IsCNYDisplay() bool

IsCNYDisplay 是否以人民币展示

func IsCheckinEnabled

func IsCheckinEnabled() bool

IsCheckinEnabled 是否启用签到功能

func IsCurrencyDisplay

func IsCurrencyDisplay() bool

IsCurrencyDisplay 是否以货币形式展示(美元或人民币)

func IsPetEnabled

func IsPetEnabled() bool

IsPetEnabled 是否启用宠物系统

func IsSocialEnabled

func IsSocialEnabled() bool

IsSocialEnabled 是否启用社区功能

func PayMethods2JsonString

func PayMethods2JsonString() string

func ShouldDisableByStatusCode

func ShouldDisableByStatusCode(code int) bool

func ShouldRetryByStatusCode

func ShouldRetryByStatusCode(code int) bool

func UpdatePayMethodsByJsonString

func UpdatePayMethodsByJsonString(jsonString string) error

Types

type ChannelAffinityKeySource

type ChannelAffinityKeySource struct {
	Type string `json:"type"` // context_int, context_string, gjson
	Key  string `json:"key,omitempty"`
	Path string `json:"path,omitempty"`
}

type ChannelAffinityRule

type ChannelAffinityRule struct {
	Name             string                     `json:"name"`
	ModelRegex       []string                   `json:"model_regex"`
	PathRegex        []string                   `json:"path_regex"`
	UserAgentInclude []string                   `json:"user_agent_include,omitempty"`
	KeySources       []ChannelAffinityKeySource `json:"key_sources"`

	ValueRegex string `json:"value_regex"`
	TTLSeconds int    `json:"ttl_seconds"`

	ParamOverrideTemplate map[string]interface{} `json:"param_override_template,omitempty"`

	SkipRetryOnFailure bool `json:"skip_retry_on_failure,omitempty"`

	IncludeUsingGroup bool `json:"include_using_group"`
	IncludeRuleName   bool `json:"include_rule_name"`
}

type ChannelAffinitySetting

type ChannelAffinitySetting struct {
	Enabled           bool                  `json:"enabled"`
	SwitchOnSuccess   bool                  `json:"switch_on_success"`
	MaxEntries        int                   `json:"max_entries"`
	DefaultTTLSeconds int                   `json:"default_ttl_seconds"`
	Rules             []ChannelAffinityRule `json:"rules"`
}

func GetChannelAffinitySetting

func GetChannelAffinitySetting() *ChannelAffinitySetting

type CheckinSetting

type CheckinSetting struct {
	Enabled  bool `json:"enabled"`   // 是否启用签到功能
	MinQuota int  `json:"min_quota"` // 签到最小额度奖励
	MaxQuota int  `json:"max_quota"` // 签到最大额度奖励
}

CheckinSetting 签到功能配置

func GetCheckinSetting

func GetCheckinSetting() *CheckinSetting

GetCheckinSetting 获取签到配置

type GeneralSetting

type GeneralSetting struct {
	DocsLink            string `json:"docs_link"`
	PingIntervalEnabled bool   `json:"ping_interval_enabled"`
	PingIntervalSeconds int    `json:"ping_interval_seconds"`
	// 当前站点额度展示类型:USD / CNY / TOKENS
	QuotaDisplayType string `json:"quota_display_type"`
	// 自定义货币符号,用于 CUSTOM 展示类型
	CustomCurrencySymbol string `json:"custom_currency_symbol"`
	// 自定义货币与美元汇率(1 USD = X Custom)
	CustomCurrencyExchangeRate float64 `json:"custom_currency_exchange_rate"`
}

func GetGeneralSetting

func GetGeneralSetting() *GeneralSetting

type MonitorSetting

type MonitorSetting struct {
	AutoTestChannelEnabled bool    `json:"auto_test_channel_enabled"`
	AutoTestChannelMinutes float64 `json:"auto_test_channel_minutes"`
}

func GetMonitorSetting

func GetMonitorSetting() *MonitorSetting

type PaymentSetting

type PaymentSetting struct {
	AmountOptions  []int           `json:"amount_options"`
	AmountDiscount map[int]float64 `json:"amount_discount"` // 充值金额对应的折扣,例如 100 元 0.9 表示 100 元充值享受 9 折优惠
}

func GetPaymentSetting

func GetPaymentSetting() *PaymentSetting

type PetSetting

type PetSetting struct {
	Enabled        bool `json:"enabled"`           // 是否启用宠物系统
	MaxPetsPerUser int  `json:"max_pets_per_user"` // 每个用户最多拥有的宠物数

	// 互动参数
	PlayCooldownMinutes int `json:"play_cooldown_minutes"` // 玩耍冷却分钟数
	CleanDailyLimit     int `json:"clean_daily_limit"`     // 每日清洁次数上限
	CleanBoost          int `json:"clean_boost"`           // 清洁增量
	PlayMoodBoost       int `json:"play_mood_boost"`       // 玩耍心情增量

	// EXP 奖励
	FeedExp  int `json:"feed_exp"`  // 喂食获得 EXP
	PlayExp  int `json:"play_exp"`  // 玩耍获得 EXP
	CleanExp int `json:"clean_exp"` // 清洁获得 EXP

	// 状态衰减(每小时)
	HungerDecayPerHour      int `json:"hunger_decay_per_hour"`      // 饥饿衰减/h
	MoodDecayPerHour        int `json:"mood_decay_per_hour"`        // 心情衰减/h
	CleanlinessDecayPerHour int `json:"cleanliness_decay_per_hour"` // 洁净衰减/h

	// 升级进化
	LevelExpMultiplier   int `json:"level_exp_multiplier"`   // 升级公式倍数
	EvolutionStage1Level int `json:"evolution_stage1_level"` // 一阶进化等级
	EvolutionStage2Level int `json:"evolution_stage2_level"` // 二阶进化等级
	MaxLevel             int `json:"max_level"`              // 最大等级

	// 孵化
	HatchDurationMinutes int `json:"hatch_duration_minutes"` // 孵化时长(分钟)

	// 融合
	FusionBaseCost int `json:"fusion_base_cost"` // 融合基础费用
	MaxStar        int `json:"max_star"`         // 最大星级

	// 市场
	MarketFeeRate       float64 `json:"market_fee_rate"`       // 手续费率 (0.05 = 5%)
	AuctionBidIncrement float64 `json:"auction_bid_increment"` // 竞拍最低加价率 (0.05 = 5%)
}

PetSetting 宠物系统配置

func GetPetSetting

func GetPetSetting() *PetSetting

GetPetSetting 获取宠物配置

type QuotaSetting

type QuotaSetting struct {
	EnableFreeModelPreConsume bool `json:"enable_free_model_pre_consume"` // 是否对免费模型启用预消耗
}

func GetQuotaSetting

func GetQuotaSetting() *QuotaSetting

type SocialSetting

type SocialSetting struct {
	Enabled       bool `json:"enabled"`         // 是否启用社区功能
	MaxPostLength int  `json:"max_post_length"` // 帖子最大字数
}

SocialSetting 社区功能配置

func GetSocialSetting

func GetSocialSetting() *SocialSetting

GetSocialSetting 获取社区配置

type StatusCodeRange

type StatusCodeRange struct {
	Start int
	End   int
}

func ParseHTTPStatusCodeRanges

func ParseHTTPStatusCodeRanges(input string) ([]StatusCodeRange, error)

type TokenSetting

type TokenSetting struct {
	MaxUserTokens int `json:"max_user_tokens"` // 每用户最大令牌数量
}

TokenSetting 令牌相关配置

func GetTokenSetting

func GetTokenSetting() *TokenSetting

GetTokenSetting 获取令牌配置

Jump to

Keyboard shortcuts

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