How kijai/comfyui-promptrelay works
Purpose
ComfyUI Prompt-Relay is a work-in-progress custom-node extension for creating time-segmented text-conditioning prompts for video workflows. It converts a multi-segment prompt into conditioning distributed over a video’s latent-frame timeline, with an automatic “Smart” authoring mode. Primary extension modules are nodes.py, prompt_relay.py, and smart_nodes.py.
ComfyUI Entry and Node Surface
ComfyUI discovers the extension through its Python package root and node registration layer:
• __init__.py
• nodes.py
The node implementation is split between conventional Prompt Relay behavior in prompt_relay.py and automatic segment/frame allocation in smart_nodes.py. advanced_options.py likely supplies the additional node options exposed alongside the main encode behavior.
Smart Prompt Parsing Stage
The Smart node accepts one smart_prompt input and supports two mutually exclusive source formats:
• Inline segments separated by |
• Block segments introduced by numbered/ranged headers
parser.py is the architectural boundary that should turn raw author text into ordered segment text plus optional relative weights. Range annotations represent proportional spans rather than literal output-frame counts; ordinal block headers result in equal weighting. Optional word-number parsing is enabled by the word2number dependency declared in requirements.txt.
Allocation and Conditioning Flow
The core flow is: user prompt → parsed segments and weights → allocation across the workflow’s latent frames → encoded segment conditioning. smart_nodes.py owns the automatic allocation concept described by the Smart node, while prompt_relay.py represents the lower-level relay/conditioning mechanism.
A global_prompt provides persistent visual context across every segment. If empty, the first segment becomes the global anchor. The normalize_by_tokens option changes allocation by multiplying segment weights by CLIP token counts, making tokenization an important boundary between parsed prompt text and frame assignment.
Timeline and Frontend Integration
The extension includes a browser-side timeline component:
• web/js/prompt_relay_timeline.js
This is the UI boundary for visualizing or editing the relay timeline within ComfyUI, complementing the Python node execution path. Timeline-oriented example workflows are provided in:
• example_workflows/prompt_relay_test.json
• example_workflows/prompt_relay_ltx23_test_02.json
Patches and Compatibility Boundary
patches.py is a distinct integration point, indicating behavior may be adapted or patched around host/runtime functionality rather than being entirely self-contained. Changes affecting prompt encoding, latent-frame handling, or node interoperability should be traced through:
• patches.py
• prompt_relay.py
• nodes.py
Runtime Dependencies and Assets
The runtime is Python inside ComfyUI, with JavaScript executed in ComfyUI’s web frontend. Package dependencies are defined in requirements.txt; word2number is optional but extends block-header parsing. UI/documentation assets reside under assets, including images for the Smart nodes and timeline.
Main entry points: nodes.py Node registration · prompt_relay.py Prompt relay · smart_nodes.py Smart node · __init__.py Package entry
Components 13
Python extension
Custom nodes and prompt-processing runtime.
- Package entry
__init__.py - Node registration · Exposes Prompt Relay nodes to ComfyUI.
nodes.py - Smart node · Builds segment timing from a single smart prompt.
smart_nodes.py - Prompt parser · Parses inline or headed blocks into ordered weighted segments.
parser.py - Word-number support · Extends block-header parsing.
requirements.txt - Prompt relay · Distributes encoded conditioning over latent-frame spans.
prompt_relay.py - Advanced options
advanced_options.py - Compatibility patches · Adapts behavior at ComfyUI runtime boundaries.
patches.py
ComfyUI frontend
Timeline UI integration.
- Relay timeline UI · Visualizes or edits the relay timeline.
web/js/prompt_relay_timeline.js
Examples and assets
- Prompt Relay workflow
example_workflows/prompt_relay_test.json - LTX23 workflow
example_workflows/prompt_relay_ltx23_test_02.json - UI assets · Smart-node and timeline assets.
assets
Other components
- ComfyUI host · Discovers nodes and runs workflow execution.
Connections 15
- ComfyUI host → Package entry: discovers
- Package entry → Node registration: loads
- Node registration → Smart node: registers
- Node registration → Prompt relay: registers
- Node registration → Advanced options: exposes
- Smart node → Prompt parser: parses smart_prompt
- Prompt parser → Word-number support: optionally uses
- Smart node → Prompt relay: allocates segments and frames
- Advanced options → Prompt relay: configures encoding
- Prompt relay → Compatibility patches: uses host adaptations
- Compatibility patches → ComfyUI host: integrates with
- Relay timeline UI → Node registration: complements node UI
- Prompt Relay workflow → Node registration: exercises
- LTX23 workflow → Node registration: exercises
- UI assets → Relay timeline UI: supports