fix: price badges algo

Signed-off-by: bigcat88 <bigcat88@icloud.com>
This commit is contained in:
bigcat88 2026-05-07 11:21:14 +03:00
parent ace5eb9060
commit e1a6800866
No known key found for this signature in database
GPG Key ID: 1F0BF0EC3CF22721
2 changed files with 26 additions and 53 deletions

View File

@ -276,6 +276,7 @@ class TripoTask(BaseModel):
create_time: Optional[int] = Field(None, description='The creation time of the task') create_time: Optional[int] = Field(None, description='The creation time of the task')
running_left_time: Optional[int] = Field(None, description='The estimated time left for the task') running_left_time: Optional[int] = Field(None, description='The estimated time left for the task')
queue_position: Optional[int] = Field(None, description='The position in the queue') queue_position: Optional[int] = Field(None, description='The position in the queue')
consumed_credit: int | None = Field(None)
class TripoTaskResponse(BaseModel): class TripoTaskResponse(BaseModel):
code: int = Field(0, description='The response code') code: int = Field(0, description='The response code')

View File

@ -60,6 +60,7 @@ async def poll_until_finished(
], ],
status_extractor=lambda x: x.data.status, status_extractor=lambda x: x.data.status,
progress_extractor=lambda x: x.data.progress, progress_extractor=lambda x: x.data.progress,
price_extractor=lambda x: x.data.consumed_credit * 0.01 if x.data.consumed_credit else None,
estimated_duration=average_duration, estimated_duration=average_duration,
) )
if response_poll.data.status == TripoTaskStatus.SUCCESS: if response_poll.data.status == TripoTaskStatus.SUCCESS:
@ -113,7 +114,6 @@ class TripoTextToModelNode(IO.ComfyNode):
depends_on=IO.PriceBadgeDepends( depends_on=IO.PriceBadgeDepends(
widgets=[ widgets=[
"model_version", "model_version",
"style",
"texture", "texture",
"pbr", "pbr",
"quad", "quad",
@ -124,20 +124,17 @@ class TripoTextToModelNode(IO.ComfyNode):
expr=""" expr="""
( (
$isV14 := $contains(widgets.model_version,"v1.4"); $isV14 := $contains(widgets.model_version,"v1.4");
$style := widgets.style; $isV3OrLater := $contains(widgets.model_version,"v3.");
$hasStyle := ($style != "" and $style != "none");
$withTexture := widgets.texture or widgets.pbr; $withTexture := widgets.texture or widgets.pbr;
$isHdTexture := (widgets.texture_quality = "detailed"); $isHdTexture := (widgets.texture_quality = "detailed");
$isDetailedGeometry := (widgets.geometry_quality = "detailed"); $isDetailedGeometry := (widgets.geometry_quality = "detailed");
$baseCredits := $credits := $isV14 ? 20 : (
$isV14 ? 20 : ($withTexture ? 20 : 10); ($withTexture ? 20 : 10)
$credits :=
$baseCredits
+ ($hasStyle ? 5 : 0)
+ (widgets.quad ? 5 : 0) + (widgets.quad ? 5 : 0)
+ ($isHdTexture ? 10 : 0) + ($isHdTexture ? 10 : 0)
+ ($isDetailedGeometry ? 20 : 0); + (($isDetailedGeometry and $isV3OrLater) ? 20 : 0)
{"type":"usd","usd": $round($credits * 0.01, 2)} );
{"type":"usd","usd": $round($credits * 0.01, 2), "format": {"approximate": true}}
) )
""", """,
), ),
@ -239,7 +236,6 @@ class TripoImageToModelNode(IO.ComfyNode):
depends_on=IO.PriceBadgeDepends( depends_on=IO.PriceBadgeDepends(
widgets=[ widgets=[
"model_version", "model_version",
"style",
"texture", "texture",
"pbr", "pbr",
"quad", "quad",
@ -250,20 +246,17 @@ class TripoImageToModelNode(IO.ComfyNode):
expr=""" expr="""
( (
$isV14 := $contains(widgets.model_version,"v1.4"); $isV14 := $contains(widgets.model_version,"v1.4");
$style := widgets.style; $isV3OrLater := $contains(widgets.model_version,"v3.");
$hasStyle := ($style != "" and $style != "none");
$withTexture := widgets.texture or widgets.pbr; $withTexture := widgets.texture or widgets.pbr;
$isHdTexture := (widgets.texture_quality = "detailed"); $isHdTexture := (widgets.texture_quality = "detailed");
$isDetailedGeometry := (widgets.geometry_quality = "detailed"); $isDetailedGeometry := (widgets.geometry_quality = "detailed");
$baseCredits := $credits := $isV14 ? 30 : (
$isV14 ? 30 : ($withTexture ? 30 : 20); ($withTexture ? 30 : 20)
$credits :=
$baseCredits
+ ($hasStyle ? 5 : 0)
+ (widgets.quad ? 5 : 0) + (widgets.quad ? 5 : 0)
+ ($isHdTexture ? 10 : 0) + ($isHdTexture ? 10 : 0)
+ ($isDetailedGeometry ? 20 : 0); + (($isDetailedGeometry and $isV3OrLater) ? 20 : 0)
{"type":"usd","usd": $round($credits * 0.01, 2)} );
{"type":"usd","usd": $round($credits * 0.01, 2), "format": {"approximate": true}}
) )
""", """,
), ),
@ -387,17 +380,17 @@ class TripoMultiviewToModelNode(IO.ComfyNode):
expr=""" expr="""
( (
$isV14 := $contains(widgets.model_version,"v1.4"); $isV14 := $contains(widgets.model_version,"v1.4");
$isV3OrLater := $contains(widgets.model_version,"v3.");
$withTexture := widgets.texture or widgets.pbr; $withTexture := widgets.texture or widgets.pbr;
$isHdTexture := (widgets.texture_quality = "detailed"); $isHdTexture := (widgets.texture_quality = "detailed");
$isDetailedGeometry := (widgets.geometry_quality = "detailed"); $isDetailedGeometry := (widgets.geometry_quality = "detailed");
$baseCredits := $credits := $isV14 ? 30 : (
$isV14 ? 30 : ($withTexture ? 30 : 20); ($withTexture ? 30 : 20)
$credits :=
$baseCredits
+ (widgets.quad ? 5 : 0) + (widgets.quad ? 5 : 0)
+ ($isHdTexture ? 10 : 0) + ($isHdTexture ? 10 : 0)
+ ($isDetailedGeometry ? 20 : 0); + (($isDetailedGeometry and $isV3OrLater) ? 20 : 0)
{"type":"usd","usd": $round($credits * 0.01, 2)} );
{"type":"usd","usd": $round($credits * 0.01, 2), "format": {"approximate": true}}
) )
""", """,
), ),
@ -498,7 +491,7 @@ class TripoTextureNode(IO.ComfyNode):
expr=""" expr="""
( (
$tq := widgets.texture_quality; $tq := widgets.texture_quality;
{"type":"usd","usd": ($contains($tq,"detailed") ? 0.2 : 0.1)} {"type":"usd","usd": ($contains($tq,"detailed") ? 0.2 : 0.1), "format": {"approximate": true}}
) )
""", """,
), ),
@ -555,7 +548,7 @@ class TripoRefineNode(IO.ComfyNode):
is_api_node=True, is_api_node=True,
is_output_node=True, is_output_node=True,
price_badge=IO.PriceBadge( price_badge=IO.PriceBadge(
expr="""{"type":"usd","usd":0.3}""", expr="""{"type":"usd","usd":0.3, "format": {"approximate": true}}""",
), ),
) )
@ -592,7 +585,7 @@ class TripoRigNode(IO.ComfyNode):
is_api_node=True, is_api_node=True,
is_output_node=True, is_output_node=True,
price_badge=IO.PriceBadge( price_badge=IO.PriceBadge(
expr="""{"type":"usd","usd":0.25}""", expr="""{"type":"usd","usd":0.25, "format": {"approximate": true}}""",
), ),
) )
@ -652,7 +645,7 @@ class TripoRetargetNode(IO.ComfyNode):
is_api_node=True, is_api_node=True,
is_output_node=True, is_output_node=True,
price_badge=IO.PriceBadge( price_badge=IO.PriceBadge(
expr="""{"type":"usd","usd":0.1}""", expr="""{"type":"usd","usd":0.1, "format": {"approximate": true}}""",
), ),
) )
@ -761,19 +754,10 @@ class TripoConversionNode(IO.ComfyNode):
"face_limit", "face_limit",
"texture_size", "texture_size",
"texture_format", "texture_format",
"force_symmetry",
"flatten_bottom", "flatten_bottom",
"flatten_bottom_threshold", "flatten_bottom_threshold",
"pivot_to_center_bottom", "pivot_to_center_bottom",
"scale_factor", "scale_factor",
"with_animation",
"pack_uv",
"bake",
"part_names",
"fbx_preset",
"export_vertex_colors",
"export_orientation",
"animate_in_place",
], ],
), ),
expr=""" expr="""
@ -783,28 +767,16 @@ class TripoConversionNode(IO.ComfyNode):
$flatThresh := (widgets.flatten_bottom_threshold != null) ? widgets.flatten_bottom_threshold : 0; $flatThresh := (widgets.flatten_bottom_threshold != null) ? widgets.flatten_bottom_threshold : 0;
$scale := (widgets.scale_factor != null) ? widgets.scale_factor : 1; $scale := (widgets.scale_factor != null) ? widgets.scale_factor : 1;
$texFmt := (widgets.texture_format != "" ? widgets.texture_format : "jpeg"); $texFmt := (widgets.texture_format != "" ? widgets.texture_format : "jpeg");
$part := widgets.part_names;
$fbx := (widgets.fbx_preset != "" ? widgets.fbx_preset : "blender");
$orient := (widgets.export_orientation != "" ? widgets.export_orientation : "default");
$advanced := $advanced :=
widgets.quad or widgets.quad or
widgets.force_symmetry or
widgets.flatten_bottom or widgets.flatten_bottom or
widgets.pivot_to_center_bottom or widgets.pivot_to_center_bottom or
widgets.with_animation or
widgets.pack_uv or
widgets.bake or
widgets.export_vertex_colors or
widgets.animate_in_place or
($face != -1) or ($face != -1) or
($texSize != 4096) or ($texSize != 4096) or
($flatThresh != 0) or ($flatThresh != 0) or
($scale != 1) or ($scale != 1) or
($texFmt != "jpeg") or ($texFmt != "jpeg");
($part != "") or {"type":"usd","usd": ($advanced ? 0.1 : 0.05), "format": {"approximate": true}}
($fbx != "blender") or
($orient != "default");
{"type":"usd","usd": ($advanced ? 0.1 : 0.05)}
) )
""", """,
), ),