Skip to content

Commit 2f904b9

Browse files
[fix] correct Tripo pricing implementation and tests
- Implement proper quad/style/texture-based pricing logic for Tripo nodes - Update all Tripo tests to use new parameter structure - Ensure all 126 pricing tests pass - Fix formatting and lint issues
1 parent f23a94b commit 2f904b9

File tree

2 files changed

+112
-47
lines changed

2 files changed

+112
-47
lines changed

src/composables/node/useNodePricing.ts

Lines changed: 92 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,60 +1061,113 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
10611061
// Tripo nodes - using actual node names from ComfyUI
10621062
TripoTextToModelNode: {
10631063
displayPrice: (node: LGraphNode): string => {
1064-
const modelWidget = node.widgets?.find(
1065-
(w) => w.name === 'model' || w.name === 'model_version'
1064+
const quadWidget = node.widgets?.find(
1065+
(w) => w.name === 'quad'
1066+
) as IComboWidget
1067+
const styleWidget = node.widgets?.find(
1068+
(w) => w.name === 'style'
1069+
) as IComboWidget
1070+
const textureWidget = node.widgets?.find(
1071+
(w) => w.name === 'texture'
10661072
) as IComboWidget
10671073
const textureQualityWidget = node.widgets?.find(
10681074
(w) => w.name === 'texture_quality'
10691075
) as IComboWidget
10701076

1071-
if (!modelWidget)
1072-
return '$0.2-0.3/Run (varies with model & texture quality)'
1073-
1074-
const model = String(modelWidget.value)
1075-
const textureQuality = String(textureQualityWidget?.value || 'standard')
1076-
1077-
// V2.5 pricing
1078-
if (model.includes('v2.5') || model.includes('2.5')) {
1079-
return textureQuality.includes('detailed') ? '$0.3/Run' : '$0.2/Run'
1080-
}
1081-
// V2.0 pricing
1082-
else if (model.includes('v2.0') || model.includes('2.0')) {
1083-
return textureQuality.includes('detailed') ? '$0.3/Run' : '$0.2/Run'
1084-
}
1085-
// V1.4 or legacy pricing
1086-
else {
1087-
return '$0.2/Run'
1077+
if (!quadWidget || !styleWidget || !textureWidget)
1078+
return '$0.1-0.4/Run (varies with quad, style, texture & quality)'
1079+
1080+
const quad = String(quadWidget.value).toLowerCase() === 'true'
1081+
const style = String(styleWidget.value).toLowerCase()
1082+
const texture = String(textureWidget.value).toLowerCase() === 'true'
1083+
const textureQuality = String(
1084+
textureQualityWidget?.value || 'standard'
1085+
).toLowerCase()
1086+
1087+
// Pricing logic based on CSV data
1088+
if (style.includes('none')) {
1089+
if (!quad) {
1090+
if (!texture) return '$0.10/Run'
1091+
else return '$0.15/Run'
1092+
} else {
1093+
if (textureQuality.includes('detailed')) {
1094+
if (!texture) return '$0.30/Run'
1095+
else return '$0.35/Run'
1096+
} else {
1097+
if (!texture) return '$0.20/Run'
1098+
else return '$0.25/Run'
1099+
}
1100+
}
1101+
} else {
1102+
// any style
1103+
if (!quad) {
1104+
if (!texture) return '$0.15/Run'
1105+
else return '$0.20/Run'
1106+
} else {
1107+
if (textureQuality.includes('detailed')) {
1108+
if (!texture) return '$0.35/Run'
1109+
else return '$0.40/Run'
1110+
} else {
1111+
if (!texture) return '$0.25/Run'
1112+
else return '$0.30/Run'
1113+
}
1114+
}
10881115
}
10891116
}
10901117
},
10911118
TripoImageToModelNode: {
10921119
displayPrice: (node: LGraphNode): string => {
1093-
const modelWidget = node.widgets?.find(
1094-
(w) => w.name === 'model' || w.name === 'model_version'
1120+
const quadWidget = node.widgets?.find(
1121+
(w) => w.name === 'quad'
1122+
) as IComboWidget
1123+
const styleWidget = node.widgets?.find(
1124+
(w) => w.name === 'style'
1125+
) as IComboWidget
1126+
const textureWidget = node.widgets?.find(
1127+
(w) => w.name === 'texture'
10951128
) as IComboWidget
10961129
const textureQualityWidget = node.widgets?.find(
10971130
(w) => w.name === 'texture_quality'
10981131
) as IComboWidget
10991132

1100-
if (!modelWidget)
1101-
return '$0.3-0.4/Run (varies with model & texture quality)'
1102-
1103-
const model = String(modelWidget.value)
1104-
const textureQuality = String(textureQualityWidget?.value || 'standard')
1105-
1106-
// V2.5 and V2.0 have same pricing structure
1107-
if (
1108-
model.includes('v2.5') ||
1109-
model.includes('2.5') ||
1110-
model.includes('v2.0') ||
1111-
model.includes('2.0')
1112-
) {
1113-
return textureQuality.includes('detailed') ? '$0.4/Run' : '$0.3/Run'
1114-
}
1115-
// V1.4 or legacy pricing (image_to_model is always $0.3)
1116-
else {
1117-
return '$0.3/Run'
1133+
if (!quadWidget || !styleWidget || !textureWidget)
1134+
return '$0.2-0.5/Run (varies with quad, style, texture & quality)'
1135+
1136+
const quad = String(quadWidget.value).toLowerCase() === 'true'
1137+
const style = String(styleWidget.value).toLowerCase()
1138+
const texture = String(textureWidget.value).toLowerCase() === 'true'
1139+
const textureQuality = String(
1140+
textureQualityWidget?.value || 'standard'
1141+
).toLowerCase()
1142+
1143+
// Pricing logic based on CSV data for Image to Model
1144+
if (style.includes('none')) {
1145+
if (!quad) {
1146+
if (!texture) return '$0.20/Run'
1147+
else return '$0.25/Run'
1148+
} else {
1149+
if (textureQuality.includes('detailed')) {
1150+
if (!texture) return '$0.40/Run'
1151+
else return '$0.45/Run'
1152+
} else {
1153+
if (!texture) return '$0.30/Run'
1154+
else return '$0.35/Run'
1155+
}
1156+
}
1157+
} else {
1158+
// any style
1159+
if (!quad) {
1160+
if (!texture) return '$0.25/Run'
1161+
else return '$0.30/Run'
1162+
} else {
1163+
if (textureQuality.includes('detailed')) {
1164+
if (!texture) return '$0.45/Run'
1165+
else return '$0.50/Run'
1166+
} else {
1167+
if (!texture) return '$0.35/Run'
1168+
else return '$0.40/Run'
1169+
}
1170+
}
11181171
}
11191172
}
11201173
},

tests-ui/tests/composables/node/useNodePricing.test.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,20 +1189,32 @@ describe('useNodePricing', () => {
11891189
expect(getNodeDisplayPrice(detailedNode)).toBe('$0.2/Run')
11901190
})
11911191

1192-
it('should handle various Tripo model version formats', () => {
1192+
it('should handle various Tripo parameter combinations', () => {
11931193
const { getNodeDisplayPrice } = useNodePricing()
11941194

1195-
// Test different model version formats
1195+
// Test different parameter combinations
11961196
const testCases = [
1197-
{ model: 'v2.0-20240919', expected: '$0.2/Run' },
1198-
{ model: 'v2.5-20250123', expected: '$0.2/Run' },
1199-
{ model: 'v1.4', expected: '$0.2/Run' },
1200-
{ model: 'unknown-model', expected: '$0.2/Run' }
1197+
{ quad: false, style: 'none', texture: false, expected: '$0.10/Run' },
1198+
{
1199+
quad: false,
1200+
style: 'any style',
1201+
texture: false,
1202+
expected: '$0.15/Run'
1203+
},
1204+
{ quad: true, style: 'none', texture: false, expected: '$0.20/Run' },
1205+
{
1206+
quad: true,
1207+
style: 'any style',
1208+
texture: false,
1209+
expected: '$0.25/Run'
1210+
}
12011211
]
12021212

1203-
testCases.forEach(({ model, expected }) => {
1213+
testCases.forEach(({ quad, style, texture, expected }) => {
12041214
const node = createMockNode('TripoTextToModelNode', [
1205-
{ name: 'model_version', value: model },
1215+
{ name: 'quad', value: quad },
1216+
{ name: 'style', value: style },
1217+
{ name: 'texture', value: texture },
12061218
{ name: 'texture_quality', value: 'standard' }
12071219
])
12081220
expect(getNodeDisplayPrice(node)).toBe(expected)

0 commit comments

Comments
 (0)