api_nodes: added prices for Ideogram V3 node (character reference) (#5241)

* api_nodes: added prices for Ideogram V3 node (character reference)

* Support watching changes on connections. (#5250)

* rename renderingSpeed default value from 'balanced' to 'default'

* added missing type

---------

Co-authored-by: AustinMroz <austin@comfy.org>
This commit is contained in:
Alexander Piskun
2025-09-01 20:54:36 +03:00
committed by GitHub
parent ddd7b4866f
commit 1e6ba5c689
3 changed files with 128 additions and 35 deletions

View File

@@ -1,4 +1,4 @@
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
import type { INodeInputSlot, LGraphNode } from '@/lib/litegraph/src/litegraph'
import type { IComboWidget } from '@/lib/litegraph/src/types/widgets'
/**
@@ -179,6 +179,12 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
const numImagesWidget = node.widgets?.find(
(w) => w.name === 'num_images'
) as IComboWidget
const characterInput = node.inputs?.find(
(i) => i.name === 'character_image'
) as INodeInputSlot
const hasCharacter =
typeof characterInput?.link !== 'undefined' &&
characterInput.link != null
if (!renderingSpeedWidget)
return '$0.03-0.08 x num_images/Run (varies with rendering speed & num_images)'
@@ -188,11 +194,23 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
const renderingSpeed = String(renderingSpeedWidget.value)
if (renderingSpeed.toLowerCase().includes('quality')) {
basePrice = 0.09
} else if (renderingSpeed.toLowerCase().includes('balanced')) {
basePrice = 0.06
if (hasCharacter) {
basePrice = 0.2
} else {
basePrice = 0.09
}
} else if (renderingSpeed.toLowerCase().includes('default')) {
if (hasCharacter) {
basePrice = 0.15
} else {
basePrice = 0.06
}
} else if (renderingSpeed.toLowerCase().includes('turbo')) {
basePrice = 0.03
if (hasCharacter) {
basePrice = 0.1
} else {
basePrice = 0.03
}
}
const totalCost = (basePrice * numImages).toFixed(2)
@@ -1462,7 +1480,7 @@ export const useNodePricing = () => {
OpenAIGPTImage1: ['quality', 'n'],
IdeogramV1: ['num_images', 'turbo'],
IdeogramV2: ['num_images', 'turbo'],
IdeogramV3: ['rendering_speed', 'num_images'],
IdeogramV3: ['rendering_speed', 'num_images', 'character_image'],
FluxProKontextProNode: [],
FluxProKontextMaxNode: [],
VeoVideoGenerationNode: ['duration_seconds'],

View File

@@ -75,6 +75,29 @@ export const useComputedWithWidgetWatch = (
}
})
})
if (widgetNames && widgetNames.length > widgetsToObserve.length) {
//Inputs have been included
const indexesToObserve = widgetNames
.map((name) =>
widgetsToObserve.some((w) => w.name == name)
? -1
: node.inputs.findIndex((i) => i.name == name)
)
.filter((i) => i >= 0)
node.onConnectionsChange = useChainCallback(
node.onConnectionsChange,
(_type: unknown, index: number, isConnected: boolean) => {
if (!indexesToObserve.includes(index)) return
widgetValues.value = {
...widgetValues.value,
[indexesToObserve[index]]: isConnected
}
if (triggerCanvasRedraw) {
node.graph?.setDirtyCanvas(true, true)
}
}
)
}
}
// Returns a function that creates a computed that responds to widget changes.