feat: add billing expression system documentation and enhance tiered billing logic
- Introduced a new rule for the Billing Expression System, emphasizing the importance of reading `pkg/billingexpr/expr.md` for dynamic billing. - Updated the billing expression logic to support new variables and improved handling of image and audio tokens. - Enhanced the tiered billing functionality with versioning support for expressions and refined quota calculations. - Added tests to validate the new billing expression features and ensure correctness in pricing calculations.
This commit is contained in:
@@ -646,8 +646,8 @@ export function useModelPricingEditorState({
|
||||
ImageRatio: parseOptionJSON(options.ImageRatio),
|
||||
AudioRatio: parseOptionJSON(options.AudioRatio),
|
||||
AudioCompletionRatio: parseOptionJSON(options.AudioCompletionRatio),
|
||||
ModelBillingMode: parseOptionJSON(options.ModelBillingMode),
|
||||
ModelBillingExpr: parseOptionJSON(options.ModelBillingExpr),
|
||||
ModelBillingMode: parseOptionJSON(options['billing_setting.billing_mode']),
|
||||
ModelBillingExpr: parseOptionJSON(options['billing_setting.billing_expr']),
|
||||
};
|
||||
|
||||
const names = new Set([
|
||||
@@ -1035,19 +1035,19 @@ export function useModelPricingEditorState({
|
||||
};
|
||||
|
||||
const tieredOutput = {
|
||||
ModelBillingMode: {},
|
||||
ModelBillingExpr: {},
|
||||
'billing_setting.billing_mode': {},
|
||||
'billing_setting.billing_expr': {},
|
||||
};
|
||||
|
||||
for (const model of models) {
|
||||
if (model.billingMode === 'tiered_expr') {
|
||||
tieredOutput.ModelBillingMode[model.name] = 'tiered_expr';
|
||||
tieredOutput['billing_setting.billing_mode'][model.name] = 'tiered_expr';
|
||||
const finalBillingExpr = combineBillingExpr(
|
||||
model.billingExpr,
|
||||
model.requestRuleExpr,
|
||||
);
|
||||
if (finalBillingExpr) {
|
||||
tieredOutput.ModelBillingExpr[model.name] = finalBillingExpr;
|
||||
tieredOutput['billing_setting.billing_expr'][model.name] = finalBillingExpr;
|
||||
}
|
||||
}
|
||||
if (model.billingMode === 'tiered_expr') {
|
||||
|
||||
Reference in New Issue
Block a user