Skip to content
Merged
Show file tree
Hide file tree
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
37 changes: 36 additions & 1 deletion src/composables/node/useNodePricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,38 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
},
ViduStartEndToVideoNode: {
displayPrice: '$0.4/Run'
},
ByteDanceImageNode: {
displayPrice: (node: LGraphNode): string => {
const modelWidget = node.widgets?.find(
(w) => w.name === 'model'
) as IComboWidget
Comment on lines +1389 to +1391
Copy link
Contributor

Choose a reason for hiding this comment

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

Note to self: This looks like a good extraction target for refactoring within this file.

Something like

return modelPriceFor(node, 'seedream-3-0-t2i', '$0.03/Run')


if (!modelWidget) return 'Token-based'

const model = String(modelWidget.value)

if (model.includes('seedream-3-0-t2i')) {
return '$0.03/Run'
}
return 'Token-based'
}
},
ByteDanceImageEditNode: {
displayPrice: (node: LGraphNode): string => {
const modelWidget = node.widgets?.find(
(w) => w.name === 'model'
) as IComboWidget

if (!modelWidget) return 'Token-based'

const model = String(modelWidget.value)

if (model.includes('seededit-3-0-i2i')) {
return '$0.03/Run'
}
return 'Token-based'
}
}
}

Expand Down Expand Up @@ -1470,7 +1502,10 @@ export const useNodePricing = () => {
// Google/Gemini nodes
GeminiNode: ['model'],
// OpenAI nodes
OpenAIChatNode: ['model']
OpenAIChatNode: ['model'],
// ByteDance
ByteDanceImageNode: ['model'],
ByteDanceImageEditNode: ['model']
}
return widgetMap[nodeType] || []
}
Expand Down
24 changes: 24 additions & 0 deletions tests-ui/tests/composables/node/useNodePricing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,30 @@ describe('useNodePricing', () => {
'$0.1-0.4/Run (varies with quad, style, texture & quality)'
)
})

it('should return correct pricing for exposed ByteDance models', () => {
const { getNodeDisplayPrice } = useNodePricing()

const testCases = [
{
node_name: 'ByteDanceImageNode',
model: 'seedream-3-0-t2i-250415',
expected: '$0.03/Run'
},
{
node_name: 'ByteDanceImageEditNode',
model: 'seededit-3-0-i2i-250628',
expected: '$0.03/Run'
}
]

testCases.forEach(({ node_name, model, expected }) => {
const node = createMockNode(node_name, [
{ name: 'model', value: model }
])
expect(getNodeDisplayPrice(node)).toBe(expected)
})
})
})
})
})