feat: 算力引擎 Go 后端核心(new-api)
- 统一 OpenAI 兼容 /v1 中继 + 渠道/额度/令牌/流水 - 各领域包:relay 模型网关、model 数据层、controller 管理 API
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package billingexpr
|
||||
|
||||
import "github.com/QuantumNous/new-api/common"
|
||||
|
||||
// QuotaRound converts a float64 quota value to int using half-away-from-zero
|
||||
// rounding with int32 saturation. Every tiered billing path (pre-consume,
|
||||
// settlement, breakdown validation, log fields) MUST use this function to
|
||||
// avoid +-1 discrepancies.
|
||||
//
|
||||
// It delegates to common.QuotaRound so all quota rounding/conversion shares
|
||||
// one saturation + logging policy (see common/quota_math.go).
|
||||
func QuotaRound(f float64) int {
|
||||
return common.QuotaRound(f)
|
||||
}
|
||||
|
||||
// QuotaRoundStrict rejects an unrepresentable pre-consume estimate.
|
||||
func QuotaRoundStrict(f float64) (int, error) {
|
||||
return common.QuotaRoundStrict(f)
|
||||
}
|
||||
Reference in New Issue
Block a user