功能增加
This commit is contained in:
@@ -759,18 +759,7 @@ function billingJobChargeFromValue(value: unknown): GenerationJob["billing"] {
|
||||
settlementLedgerEntryId: optionalString(value.settlementLedgerEntryId),
|
||||
settledAt: optionalString(value.settledAt),
|
||||
settlementReason: optionalString(value.settlementReason),
|
||||
providerUsage: isRecord(value.providerUsage)
|
||||
&& Number.isFinite(Number(value.providerUsage.completionTokens))
|
||||
&& typeof value.providerUsage.resolution === "string"
|
||||
&& typeof value.providerUsage.inputVideo === "boolean"
|
||||
&& Number.isFinite(Number(value.providerUsage.tokenPriceFenPerMillion))
|
||||
? {
|
||||
completionTokens: Number(value.providerUsage.completionTokens),
|
||||
resolution: value.providerUsage.resolution,
|
||||
inputVideo: value.providerUsage.inputVideo,
|
||||
tokenPriceFenPerMillion: Number(value.providerUsage.tokenPriceFenPerMillion)
|
||||
}
|
||||
: undefined,
|
||||
providerUsage: billingProviderUsageFromValue(value.providerUsage),
|
||||
ledgerEntryId: optionalString(value.ledgerEntryId),
|
||||
refundLedgerEntryId: optionalString(value.refundLedgerEntryId),
|
||||
chargedAt: optionalString(value.chargedAt),
|
||||
@@ -779,6 +768,30 @@ function billingJobChargeFromValue(value: unknown): GenerationJob["billing"] {
|
||||
};
|
||||
}
|
||||
|
||||
function billingProviderUsageFromValue(value: unknown): NonNullable<GenerationJob["billing"]>["providerUsage"] {
|
||||
if (!isRecord(value) || typeof value.resolution !== "string") return undefined;
|
||||
const completionTokens = optionalNumber(value.completionTokens);
|
||||
const tokenPriceFenPerMillion = optionalNumber(value.tokenPriceFenPerMillion);
|
||||
const outputSeconds = optionalNumber(value.outputSeconds);
|
||||
const inputVideoSeconds = optionalNumber(value.inputVideoSeconds);
|
||||
const inputImageCount = optionalNumber(value.inputImageCount);
|
||||
const videoPriceFenPerSecond = optionalNumber(value.videoPriceFenPerSecond);
|
||||
const inputVideo = typeof value.inputVideo === "boolean" ? value.inputVideo : undefined;
|
||||
const model = optionalString(value.model);
|
||||
if (completionTokens === undefined && outputSeconds === undefined) return undefined;
|
||||
return {
|
||||
resolution: value.resolution,
|
||||
model,
|
||||
completionTokens,
|
||||
inputVideo,
|
||||
tokenPriceFenPerMillion,
|
||||
outputSeconds,
|
||||
inputVideoSeconds,
|
||||
inputImageCount,
|
||||
videoPriceFenPerSecond
|
||||
};
|
||||
}
|
||||
|
||||
function imageTemplateToRow(template: Partial<ImageTemplate>) {
|
||||
const row: Record<string, unknown> = {};
|
||||
if (template.id !== undefined) row.id = template.id;
|
||||
|
||||
Reference in New Issue
Block a user