The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
[Partner Nodes] feat(Quiver): add Arrow 2 models with reasoning effort to the SVG nodes (#16478)
Alexander Piskun512389263395
diff --git a/comfy_api_nodes/apis/quiver.py b/comfy_api_nodes/apis/quiver.pyindex bc8708754..adc7a52e0 100644--- a/comfy_api_nodes/apis/quiver.py+++ b/comfy_api_nodes/apis/quiver.py@@ -6,8 +6,9 @@ class QuiverImageObject(BaseModel):class QuiverTextToSVGRequest(BaseModel):- model: str = Field(default="arrow-preview")+ model: str = Field(...)prompt: str = Field(...)+ reasoning_effort: str | None = Field(default=None)instructions: str | None = Field(default=None)references: list[QuiverImageObject] | None = Field(default=None, max_length=4)temperature: float | None = Field(default=None, ge=0, le=2)@@ -16,8 +17,9 @@ class QuiverTextToSVGRequest(BaseModel):class QuiverImageToSVGRequest(BaseModel):- model: str = Field(default="arrow-preview")+ model: str = Field(...)image: QuiverImageObject = Field(...)+ reasoning_effort: str | None = Field(default=None)auto_crop: bool | None = Field(default=None)target_size: int | None = Field(default=None, ge=128, le=4096)temperature: float | None = Field(default=None, ge=0, le=2)diff --git a/comfy_api_nodes/nodes_quiver.py b/comfy_api_nodes/nodes_quiver.pyindex 34929fa0c..08639eacb 100644--- a/comfy_api_nodes/nodes_quiver.py+++ b/comfy_api_nodes/nodes_quiver.py@@ -17,7 +17,78 @@ from comfy_api_nodes.util import ()from comfy_extras.nodes_images import SVG-_ARROW_MODELS = ["arrow-1.1", "arrow-1.1-max", "arrow-preview"]+_ARROW_MODELS = ["arrow-2", "arrow-2-telos", "arrow-1.1", "arrow-1.1-max", "arrow-preview"]+_EFFORT_LEVELS = ["low", "medium", "high", "xhigh"]+_TOKEN_MODEL_RATES = {"arrow-2": (4, 20), "arrow-2-telos": (6, 30)}+_FIXED_GENERATION_USD = {"arrow-1.1": 0.286, "arrow-1.1-max": 0.3575, "arrow-preview": 0.429}+_FIXED_VECTORIZATION_USD = {"arrow-1.1": 0.2145, "arrow-1.1-max": 0.286, "arrow-preview": 0.429}++_GENERATION_TOKENS = {+ "arrow-2": {+ "low": (713, 1100, 723, 20000),+ "medium": (713, 2200, 723, 34000),+ "high": (713, 2200, 723, 36000),+ "xhigh": (713, 2200, 723, 38000),+ },+ "arrow-2-telos": {+ "low": (476, 1100, 749, 36000),+ "medium": (476, 1300, 749, 67000),+ "high": (476, 1300, 749, 71000),+ "xhigh": (476, 10000, 749, 106000),+ },+}+_VECTORIZATION_TOKENS = {+ "arrow-2": {+ "low": (591, 600, 783, 23000),+ "medium": (591, 1300, 783, 36000),+ "high": (591, 1300, 783, 38000),+ "xhigh": (591, 1300, 783, 40000),+ },+ "arrow-2-telos": {+ "low": (394, 300, 522, 47000),+ "medium": (394, 300, 522, 48000),+ "high": (394, 300, 522, 101000),+ "xhigh": (394, 12000, 522, 115000),+ },+}+++def _effort_bands(model, tokens):+ rate_in, rate_out = _TOKEN_MODEL_RATES[model]+ effort = "widgets.reasoning_effort"++ def band(level):+ min_in, min_out, max_in, max_out = tokens[model][level]+ return (+ '{"type":"range_usd",'+ f'"min_usd":({min_in} * {rate_in} + {min_out} * {rate_out}) * 1.43 / 1000000,'+ f'"max_usd":({max_in} * {rate_in} + {max_out} * {rate_out}) * 1.43 / 1000000,'+ '"format":{"approximate":true}}'+ )++ levels = [f'{effort} = "{level}" ? {band(level)}' for level in ("low", "medium", "xhigh")]+ return " : ".join([*levels, band("high")])+++def _arrow_price_badge(tokens, fixed_usd):+ branches = [f'widgets.model = "{model}" ? {{"type":"usd","usd":{usd}}}' for model, usd in fixed_usd.items()]+ branches.append(f'widgets.model = "arrow-2-telos" ? ({_effort_bands("arrow-2-telos", tokens)})')+ branches.append(f'({_effort_bands("arrow-2", tokens)})')+ return IO.PriceBadge(+ depends_on=IO.PriceBadgeDepends(widgets=["model", "reasoning_effort"]),+ expr="(" + " : ".join(branches) + ")",+ )+++def _reasoning_effort_input():+ return IO.Combo.Input(+ "reasoning_effort",+ options=_EFFORT_LEVELS,+ default="high",+ optional=True,+ tooltip="How much reasoning the model spends before drawing. Higher levels improve "+ "detail and cost more tokens. Only used by the Arrow 2 models.",+ )def _arrow_sampling_inputs():@@ -104,6 +175,7 @@ class QuiverTextToSVGNode(IO.ComfyNode):tooltip="Seed to determine if node should re-run; ""actual results are nondeterministic regardless of seed.",),+ _reasoning_effort_input(),],outputs=[IO.SVG.Output(),@@ -114,18 +186,7 @@ class QuiverTextToSVGNode(IO.ComfyNode):IO.Hidden.unique_id,],is_api_node=True,- price_badge=IO.PriceBadge(- depends_on=IO.PriceBadgeDepends(widgets=["model"]),- expr="""- (- $contains(widgets.model, "max")- ? {"type":"usd","usd":0.3575}- : $contains(widgets.model, "preview")- ? {"type":"usd","usd":0.429}- : {"type":"usd","usd":0.286}- )- """,- ),+ price_badge=_arrow_price_badge(_GENERATION_TOKENS, _FIXED_GENERATION_USD),)@classmethod@@ -134,6 +195,7 @@ class QuiverTextToSVGNode(IO.ComfyNode):prompt: str,model: dict,seed: int,+ reasoning_effort: str = None,instructions: str = None,reference_images: IO.Autogrow.Type = None,) -> IO.NodeOutput:@@ -145,8 +207,6 @@ class QuiverTextToSVGNode(IO.ComfyNode):for key in reference_images:url = await upload_image_to_comfyapi(cls, reference_images[key], mime_type="image/png")references.append(QuiverImageObject(url=url))- if len(references) > 4:- raise ValueError("Maximum 4 reference images are allowed.")instructions_val = instructions.strip() if instructions else Noneif instructions_val == "":@@ -158,6 +218,7 @@ class QuiverTextToSVGNode(IO.ComfyNode):response_model=QuiverSVGResponse,data=QuiverTextToSVGRequest(model=model["model"],+ reasoning_effort=reasoning_effort if model["model"] in _TOKEN_MODEL_RATES else None,prompt=prompt,instructions=instructions_val,references=references,@@ -198,10 +259,11 @@ class QuiverImageToSVGNode(IO.ComfyNode):[IO.Int.Input("target_size",- default=1024,- min=128,+ default=0,+ min=0,max=4096,- tooltip="Square resize target in pixels.",+ tooltip="Square resize target in pixels, 128 to 4096. 0 keeps the source "+ "image size, which vectorizes more cleanly than forcing a resize.",advanced=True,),*_arrow_sampling_inputs(),@@ -220,6 +282,7 @@ class QuiverImageToSVGNode(IO.ComfyNode):tooltip="Seed to determine if node should re-run; ""actual results are nondeterministic regardless of seed.",),+ _reasoning_effort_input(),],outputs=[IO.SVG.Output(),@@ -230,18 +293,7 @@ class QuiverImageToSVGNode(IO.ComfyNode):IO.Hidden.unique_id,],is_api_node=True,- price_badge=IO.PriceBadge(- depends_on=IO.PriceBadgeDepends(widgets=["model"]),- expr="""- (- $contains(widgets.model, "max")- ? {"type":"usd","usd":0.3575}- : $contains(widgets.model, "preview")- ? {"type":"usd","usd":0.429}- : {"type":"usd","usd":0.286}- )- """,- ),+ price_badge=_arrow_price_badge(_VECTORIZATION_TOKENS, _FIXED_VECTORIZATION_USD),)@classmethod@@ -251,6 +303,7 @@ class QuiverImageToSVGNode(IO.ComfyNode):auto_crop: bool,model: dict,seed: int,+ reasoning_effort: str = None,) -> IO.NodeOutput:image_url = await upload_image_to_comfyapi(cls, image, mime_type="image/png")@@ -260,9 +313,10 @@ class QuiverImageToSVGNode(IO.ComfyNode):response_model=QuiverSVGResponse,data=QuiverImageToSVGRequest(model=model["model"],+ reasoning_effort=reasoning_effort if model["model"] in _TOKEN_MODEL_RATES else None,image=QuiverImageObject(url=image_url),auto_crop=auto_crop if auto_crop else None,- target_size=model.get("target_size"),+ target_size=model.get("target_size") or None,temperature=model.get("temperature"),top_p=model.get("top_p"),presence_penalty=model.get("presence_penalty"),