Documentation
¶
Index ¶
- Constants
- Variables
- func AutomaticDisableKeywordsFromString(s string)
- func AutomaticDisableKeywordsToString() string
- func AutomaticDisableStatusCodesFromString(s string) error
- func AutomaticDisableStatusCodesToString() string
- func AutomaticRetryStatusCodesFromString(s string) error
- func AutomaticRetryStatusCodesToString() string
- func GetCheckinQuotaRange() (min, max int)
- func GetCurrencySymbol() string
- func GetGPTImage1PriceOnceCall(quality string, size string) float64
- func GetGeminiInputAudioPricePerMillionTokens(modelName string) float64
- func GetMaxUserTokens() int
- func GetQuotaDisplayType() string
- func GetToolPrice(toolName string) float64
- func GetToolPriceForModel(toolName, modelName string) float64
- func GetUsdToCurrencyRate(usdToCny float64) float64
- func IsAlwaysSkipRetryCode(errorCode types.ErrorCode) bool
- func IsAlwaysSkipRetryStatusCode(code int) bool
- func IsCNYDisplay() bool
- func IsCheckinEnabled() bool
- func IsCurrencyDisplay() bool
- func IsPaymentComplianceConfirmed() bool
- func PayMethods2JsonString() string
- func RebuildToolPriceIndex()
- func ShouldDisableByStatusCode(code int) bool
- func ShouldRetryByStatusCode(code int) bool
- func UpdatePayMethodsByJsonString(jsonStr string) error
- type ChannelAffinityKeySource
- type ChannelAffinityRule
- type ChannelAffinitySetting
- type CheckinSetting
- type GeneralSetting
- type MonitorSetting
- type PayMethod
- type PaymentSetting
- type QuotaSetting
- type RechargeGiftSetting
- type RechargeGiftTier
- type ReferralRebateSetting
- type ReferralTier
- type StatusCodeRange
- type TokenSetting
- type ToolPriceSetting
Constants ¶
const ( QuotaDisplayTypeUSD = "USD" QuotaDisplayTypeCNY = "CNY" QuotaDisplayTypeTokens = "TOKENS" QuotaDisplayTypeCustom = "CUSTOM" )
额度展示类型
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 )
const ( Gemini25FlashPreviewInputAudioPrice = 1.00 Gemini25FlashProductionInputAudioPrice = 1.00 Gemini25FlashLitePreviewInputAudioPrice = 0.50 Gemini25FlashNativeAudioInputAudioPrice = 3.00 Gemini20FlashInputAudioPrice = 0.70 GeminiRoboticsER15InputAudioPrice = 1.00 )
const CurrentComplianceTermsVersion = "v1"
Variables ¶
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",
}
var AutomaticDisableStatusCodeRanges = []StatusCodeRange{{Start: 401, End: 401}}
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.
var CustomCallbackAddress string = "" // 自定义回调地址
var DemoSiteEnabled = false
var MinTopUp int = 1 // 最小充值金额(元),自定义输入最低1元
var PayAddress string = "" // 支付地址
var PayMethods []map[string]string = []map[string]string{} // 支付方式列表
var Price float64 = 1.0 // 价格(美元/单位)
支付相关全局变量
var SelfUseModeEnabled = false
var USDExchangeRate float64 = 1.0 // 只用人民币,汇率固定为 1 // CNY exchange rate (fixed at 1)
Functions ¶
func AutomaticDisableKeywordsFromString ¶
func AutomaticDisableKeywordsFromString(s string)
func AutomaticDisableKeywordsToString ¶
func AutomaticDisableKeywordsToString() string
func AutomaticDisableStatusCodesToString ¶
func AutomaticDisableStatusCodesToString() string
func AutomaticRetryStatusCodesToString ¶
func AutomaticRetryStatusCodesToString() string
func GetCheckinQuotaRange ¶
func GetCheckinQuotaRange() (min, max int)
GetCheckinQuotaRange 获取签到额度范围
func GetToolPrice ¶
GetToolPrice is a convenience wrapper when no model name is needed.
func GetToolPriceForModel ¶
GetToolPriceForModel returns the price ($/1K calls) for a tool given a model name. Lookup: longest prefix match → tool default → 0.
func GetUsdToCurrencyRate ¶
GetUsdToCurrencyRate 返回 1 USD = X <currency> 的 X(TOKENS 不适用)
func IsAlwaysSkipRetryCode ¶
func IsPaymentComplianceConfirmed ¶
func IsPaymentComplianceConfirmed() bool
func PayMethods2JsonString ¶
func PayMethods2JsonString() string
func RebuildToolPriceIndex ¶
func RebuildToolPriceIndex()
RebuildToolPriceIndex rebuilds the lookup index from the current config. Called on init and after config updates. Not on the billing hot path.
func ShouldRetryByStatusCode ¶
Types ¶
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"`
IncludeUsingGroup bool `json:"include_using_group"`
IncludeModelName bool `json:"include_model_name"`
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 签到功能配置
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"`
ComplianceConfirmed bool `json:"compliance_confirmed"`
ComplianceTermsVersion string `json:"compliance_terms_version"`
ComplianceConfirmedAt int64 `json:"compliance_confirmed_at"`
ComplianceConfirmedBy int `json:"compliance_confirmed_by"`
ComplianceConfirmedIP string `json:"compliance_confirmed_ip"`
}
func GetPaymentSetting ¶
func GetPaymentSetting() *PaymentSetting
type QuotaSetting ¶
type QuotaSetting struct {
EnableFreeModelPreConsume bool `json:"enable_free_model_pre_consume"` // 是否对免费模型启用预消耗
}
func GetQuotaSetting ¶
func GetQuotaSetting() *QuotaSetting
type RechargeGiftSetting ¶
type RechargeGiftSetting struct {
Enabled bool `json:"enabled"` // 是否启用充值赠送
Tiers []RechargeGiftTier `json:"tiers"` // 按金额档位送等值配额
}
RechargeGiftSetting 充值赠送设置(仅保留按金额档位赠送配额,不再赠送实物票/门票)。
func GetRechargeGiftSetting ¶
func GetRechargeGiftSetting() *RechargeGiftSetting
func (*RechargeGiftSetting) BonusQuotaForMoney ¶
func (s *RechargeGiftSetting) BonusQuotaForMoney(money float64) float64
BonusQuotaForMoney 返回应额外赠送的配额(元等价单位),未命中档位返回 0。 采用加法:赠送 = 充值金额 × bonus_rate,直接累加到到账配额上(而非对付款打折)。
func (*RechargeGiftSetting) BonusRateForMoney ¶
func (s *RechargeGiftSetting) BonusRateForMoney(money float64) float64
BonusRateForMoney 返回适用于给定充值金额(元)的赠送比例(0 表示无赠送)。 仅当金额精确命中某个档位时返回该档比例;自定义金额(未命中档位)返回 0,不享受赠送。
type RechargeGiftTier ¶
type RechargeGiftTier struct {
Amount int `json:"amount"` // 档位金额(元 / CNY),需精确命中
BonusRate float64 `json:"bonus_rate"` // 赠送比例,0.2 = 额外赠送 20% 等值配额
}
RechargeGiftTier 充值赠送档位:充值精确命中 amount(元)时,额外赠送 bonus_rate 比例的等值配额(加法,非乘法)。
type ReferralRebateSetting ¶
type ReferralRebateSetting struct {
Enabled bool `json:"enabled"` // 总开关
BaseRate float64 `json:"base_rate"` // 基础返利(兜底,无档位匹配时用)
MinRecharge int `json:"min_recharge"` // 触发返利的最小实付金额(元),防刷零额
BothSides bool `json:"both_sides"` // 双方各得模式
RefereeRate float64 `json:"referee_rate"` // 被推荐人额外奖励比例(both_sides=true 时生效)
Tiers []ReferralTier `json:"tiers"` // 阶梯档位(Threshold 升序)
}
ReferralRebateSetting 推荐返利配置(DB 可配置,从 options 表 JSON 加载)
func GetReferralRebateSetting ¶
func GetReferralRebateSetting() *ReferralRebateSetting
GetReferralRebateSetting 取当前生效配置
func (*ReferralRebateSetting) EvaluateTier ¶
func (s *ReferralRebateSetting) EvaluateTier(cumulative int) ReferralTier
EvaluateTier 按累计业绩计算应生效档位
type ReferralTier ¶
type ReferralTier struct {
Level int `json:"level"` // 档位序号(从 1 开始)
Name string `json:"name"` // 展示名,如 "资深推广"
Threshold int `json:"threshold"` // 累计被推荐人实付金额门槛(元)
Rate float64 `json:"rate"` // 该档返利比例,如 0.05 = 5%
}
ReferralTier 推荐返利阶梯档位
type StatusCodeRange ¶
func ParseHTTPStatusCodeRanges ¶
func ParseHTTPStatusCodeRanges(input string) ([]StatusCodeRange, error)
type TokenSetting ¶
type TokenSetting struct {
MaxUserTokens int `json:"max_user_tokens"` // 每用户最大令牌数量
}
TokenSetting 令牌相关配置
type ToolPriceSetting ¶
ToolPriceSetting is managed by config.GlobalConfig.Register.