feat: sync deployed v1.0.0-rc.38-custom.42
Sync production source including routing, billing, Astra detection and public uptime. Update custom build instructions and license packaging.
This commit is contained in:
1 parent
aa6c3f50f4
commit
ceddfd3d6b
828 files changed
+122253
-13702
No files matched your search
@@ -1,6 +1,10 @@
|
||||
package billingexpr
|
||||
|
||||
import "github.com/QuantumNous/new-api/common"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/QuantumNous/new-api/common"
|
||||
)
|
||||
|
||||
// quotaConversion converts raw expression output to quota based on the
|
||||
// expression version. This is the central dispatch point for future versions
|
||||
@@ -22,6 +26,9 @@ func ComputeTieredQuota(snap *BillingSnapshot, params TokenParams) (TieredResult
|
||||
}
|
||||
|
||||
func ComputeTieredQuotaWithRequest(snap *BillingSnapshot, params TokenParams, request RequestInput) (TieredResult, error) {
|
||||
if snap.TaskUsageBilling && UsesFixedPricingByHash(snap.ExprString, snap.ExprHash) {
|
||||
return TieredResult{}, fmt.Errorf("fixed pricing is not supported for task usage expressions")
|
||||
}
|
||||
cost, trace, err := RunExprByHashWithRequest(snap.ExprString, snap.ExprHash, params, request)
|
||||
if err != nil {
|
||||
return TieredResult{}, err
|
||||
@@ -31,12 +38,19 @@ func ComputeTieredQuotaWithRequest(snap *BillingSnapshot, params TokenParams, re
|
||||
afterGroup, clamp := common.QuotaRoundChecked(quotaBeforeGroup * snap.GroupRatio)
|
||||
crossed := trace.MatchedTier != snap.EstimatedTier
|
||||
|
||||
return TieredResult{
|
||||
result := TieredResult{
|
||||
ImageCount: trace.ImageCount,
|
||||
BillingUnit: trace.BillingUnit,
|
||||
FixedPrice: trace.FixedPrice,
|
||||
ActualQuotaBeforeGroup: quotaBeforeGroup,
|
||||
ActualQuotaAfterGroup: afterGroup,
|
||||
MatchedTier: trace.MatchedTier,
|
||||
RequestRules: trace.RequestRules,
|
||||
CrossedTier: crossed,
|
||||
Clamp: clamp,
|
||||
}, nil
|
||||
}
|
||||
if trace.BillingUnit == BillingUnitToken && UsedVarsByHash(snap.ExprString, snap.ExprHash)["img_cr"] {
|
||||
result.BillingTokens = ¶ms
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
Reference in new issue
Block a user