Codex/beta application review #5
+4
-1
@@ -18,9 +18,12 @@ const { pool, withTransaction } = require("./db");
|
|||||||
const { calculateCostMills, getModelPrice } = require("./pricing");
|
const { calculateCostMills, getModelPrice } = require("./pricing");
|
||||||
|
|
||||||
const CREDIT_UNITS_PER_CREDIT = 100;
|
const CREDIT_UNITS_PER_CREDIT = 100;
|
||||||
|
const CREDITS_PER_CNY = 100;
|
||||||
const CREDIT_UNITS_PER_CNY_CENT = 100;
|
const CREDIT_UNITS_PER_CNY_CENT = 100;
|
||||||
const CREDIT_UNITS_PER_CNY_MILL = 10;
|
const CREDIT_UNITS_PER_CNY_MILL = 10;
|
||||||
const IMAGE_GENERATION_FLAT_COST_CENTS = 20 * CREDIT_UNITS_PER_CREDIT;
|
const IMAGE_GENERATION_FLAT_COST_CNY = 20;
|
||||||
|
const IMAGE_GENERATION_FLAT_COST_CENTS =
|
||||||
|
IMAGE_GENERATION_FLAT_COST_CNY * CREDITS_PER_CNY * CREDIT_UNITS_PER_CREDIT;
|
||||||
|
|
||||||
function creditsToCreditUnits(credits) {
|
function creditsToCreditUnits(credits) {
|
||||||
return Math.max(0, Math.round(Number(credits || 0) * CREDIT_UNITS_PER_CREDIT));
|
return Math.max(0, Math.round(Number(credits || 0) * CREDIT_UNITS_PER_CREDIT));
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ const ENTERPRISE_VIDEO_ALLOWED_MODELS = new Set([
|
|||||||
"pixverse-c1-i2v",
|
"pixverse-c1-i2v",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const CREDITS_PER_CNY = 100;
|
||||||
|
const CREDIT_UNITS_PER_CREDIT = 100;
|
||||||
|
|
||||||
function normalizeModel(value) {
|
function normalizeModel(value) {
|
||||||
return String(value || "").trim().toLowerCase();
|
return String(value || "").trim().toLowerCase();
|
||||||
}
|
}
|
||||||
@@ -102,7 +105,7 @@ function getEnterpriseVideoCreditRate(input) {
|
|||||||
|
|
||||||
function calculateEnterpriseVideoCredits(input) {
|
function calculateEnterpriseVideoCredits(input) {
|
||||||
const duration = normalizeEnterpriseVideoDuration(input.durationSeconds || input.duration);
|
const duration = normalizeEnterpriseVideoDuration(input.durationSeconds || input.duration);
|
||||||
return Number((getEnterpriseVideoCreditRate(input) * duration).toFixed(2));
|
return Number((getEnterpriseVideoCreditRate(input) * duration * CREDITS_PER_CNY).toFixed(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateEnterpriseVideoCost(input) {
|
function calculateEnterpriseVideoCost(input) {
|
||||||
@@ -113,7 +116,7 @@ function calculateEnterpriseVideoCost(input) {
|
|||||||
resolution,
|
resolution,
|
||||||
durationSeconds,
|
durationSeconds,
|
||||||
});
|
});
|
||||||
const rateCentsPerSecond = Math.round(rateCreditsPerSecond * 100);
|
const rateCentsPerSecond = Math.round(rateCreditsPerSecond * CREDITS_PER_CNY * CREDIT_UNITS_PER_CREDIT);
|
||||||
return {
|
return {
|
||||||
resolution,
|
resolution,
|
||||||
durationSeconds,
|
durationSeconds,
|
||||||
|
|||||||
+6
-6
@@ -136,8 +136,8 @@ function registerUserRoutes(router) {
|
|||||||
CASE
|
CASE
|
||||||
WHEN billing_refunded = 1 THEN 0
|
WHEN billing_refunded = 1 THEN 0
|
||||||
WHEN cost_cents > 0 THEN cost_cents
|
WHEN cost_cents > 0 THEN cost_cents
|
||||||
WHEN status = 'completed' AND type = 'image' THEN 2000
|
WHEN status = 'completed' AND type = 'image' THEN 200000
|
||||||
WHEN status = 'completed' AND type = 'video' THEN 500
|
WHEN status = 'completed' AND type = 'video' THEN 50000
|
||||||
ELSE 0
|
ELSE 0
|
||||||
END
|
END
|
||||||
), 0) AS used_cents
|
), 0) AS used_cents
|
||||||
@@ -162,7 +162,7 @@ function registerUserRoutes(router) {
|
|||||||
resolution = params.resolution || params.quality || params.ratio || null;
|
resolution = params.resolution || params.quality || params.ratio || null;
|
||||||
if (row.status === "completed") {
|
if (row.status === "completed") {
|
||||||
if (row.type === "image") {
|
if (row.type === "image") {
|
||||||
estimatedCents = 2000;
|
estimatedCents = 200000;
|
||||||
} else if (row.type === "video") {
|
} else if (row.type === "video") {
|
||||||
const dur = params.duration || 5;
|
const dur = params.duration || 5;
|
||||||
const res = String(params.resolution || params.quality || "").toUpperCase();
|
const res = String(params.resolution || params.quality || "").toUpperCase();
|
||||||
@@ -172,7 +172,7 @@ function registerUserRoutes(router) {
|
|||||||
else if (model.includes("wan2.7-i2v") || model.includes("wanxiang")) rate = res === "720P" ? 0.6 : 1;
|
else if (model.includes("wan2.7-i2v") || model.includes("wanxiang")) rate = res === "720P" ? 0.6 : 1;
|
||||||
else if (model.includes("animate-mix") || model.includes("s2v")) rate = res === "720P" ? 0.6 : 1;
|
else if (model.includes("animate-mix") || model.includes("s2v")) rate = res === "720P" ? 0.6 : 1;
|
||||||
else if (model.includes("kling")) rate = res === "720P" ? 0.6 : 0.8;
|
else if (model.includes("kling")) rate = res === "720P" ? 0.6 : 0.8;
|
||||||
estimatedCents = Math.ceil(rate * dur * 100);
|
estimatedCents = Math.ceil(rate * dur * 10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
@@ -209,8 +209,8 @@ function registerUserRoutes(router) {
|
|||||||
CASE
|
CASE
|
||||||
WHEN billing_refunded = 1 THEN 0
|
WHEN billing_refunded = 1 THEN 0
|
||||||
WHEN cost_cents > 0 THEN cost_cents
|
WHEN cost_cents > 0 THEN cost_cents
|
||||||
WHEN status = 'completed' AND type = 'image' THEN 2000
|
WHEN status = 'completed' AND type = 'image' THEN 200000
|
||||||
WHEN status = 'completed' AND type = 'video' THEN 500
|
WHEN status = 'completed' AND type = 'video' THEN 50000
|
||||||
ELSE 0
|
ELSE 0
|
||||||
END
|
END
|
||||||
), 0) AS used_cents
|
), 0) AS used_cents
|
||||||
|
|||||||
Reference in New Issue
Block a user