Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions src/composables/node/useNodePricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1768,28 +1768,41 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
},
ByteDanceSeedreamNode: {
displayPrice: (node: LGraphNode): string => {
const modelWidget = node.widgets?.find(
(w) => w.name === 'model'
) as IComboWidget
const sequentialGenerationWidget = node.widgets?.find(
(w) => w.name === 'sequential_image_generation'
) as IComboWidget
const maxImagesWidget = node.widgets?.find(
(w) => w.name === 'max_images'
) as IComboWidget

if (!sequentialGenerationWidget || !maxImagesWidget)
return '$0.03/Run ($0.03 for one output image)'
const model = String(modelWidget?.value ?? '').toLowerCase()
let pricePerImage = 0.03 // default for seedream-4-0-250828 and fallback
if (model.includes('seedream-4-5-251128')) {
pricePerImage = 0.04
} else if (model.includes('seedream-4-0-250828')) {
pricePerImage = 0.03
}

if (
String(sequentialGenerationWidget.value).toLowerCase() === 'disabled'
) {
return '$0.03/Run'
if (!sequentialGenerationWidget || !maxImagesWidget) {
return `$${pricePerImage}/Run ($${pricePerImage} for one output image)`
}

const maxImages = Number(maxImagesWidget.value)
const seqMode = String(sequentialGenerationWidget.value).toLowerCase()
if (seqMode === 'disabled') {
return `$${pricePerImage}/Run`
}
Comment on lines +1789 to +1796
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Good defensive handling for missing widgets and disabled mode.

The code appropriately handles cases where widgets are missing or sequential generation is disabled, providing clear pricing information to users.

For consistency with line 1804, consider using .toFixed(2) when displaying prices:

     if (!sequentialGenerationWidget || !maxImagesWidget) {
-      return `$${pricePerImage}/Run ($${pricePerImage} for one output image)`
+      return `$${pricePerImage.toFixed(2)}/Run ($${pricePerImage.toFixed(2)} for one output image)`
     }

     const seqMode = String(sequentialGenerationWidget.value).toLowerCase()
     if (seqMode === 'disabled') {
-      return `$${pricePerImage}/Run`
+      return `$${pricePerImage.toFixed(2)}/Run`
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!sequentialGenerationWidget || !maxImagesWidget) {
return `$${pricePerImage}/Run ($${pricePerImage} for one output image)`
}
const maxImages = Number(maxImagesWidget.value)
const seqMode = String(sequentialGenerationWidget.value).toLowerCase()
if (seqMode === 'disabled') {
return `$${pricePerImage}/Run`
}
if (!sequentialGenerationWidget || !maxImagesWidget) {
return `$${pricePerImage.toFixed(2)}/Run ($${pricePerImage.toFixed(2)} for one output image)`
}
const seqMode = String(sequentialGenerationWidget.value).toLowerCase()
if (seqMode === 'disabled') {
return `$${pricePerImage.toFixed(2)}/Run`
}
🤖 Prompt for AI Agents
In src/composables/node/useNodePricing.ts around lines 1789 to 1796, the price
strings currently interpolate pricePerImage raw; update both return paths to
format the numeric price with two decimals for consistency (use
pricePerImage.toFixed(2) or Number(pricePerImage).toFixed(2) if pricePerImage
might be non-number) so the outputs become `$${formatted}/Run ($${formatted} for
one output image)` and `$${formatted}/Run`.


const maxImagesRaw = Number(maxImagesWidget.value)
const maxImages =
Number.isFinite(maxImagesRaw) && maxImagesRaw > 0 ? maxImagesRaw : 1
if (maxImages === 1) {
return '$0.03/Run'
return `$${pricePerImage}/Run`
}
const cost = (0.03 * maxImages).toFixed(2)
return `$${cost}/Run ($0.03 for one output image)`
const totalCost = (pricePerImage * maxImages).toFixed(2)
return `$${totalCost}/Run ($${pricePerImage} for one output image)`
}
},
ByteDanceTextToVideoNode: {
Expand Down