ComfyUI Extension: ComfyUI Prompt Companion
A node that lets you save and reuse parts of prompts (embeddings, quality keywords, and so on.)
Custom Nodes (0)
README
ComfyUI Prompt Companion
A ComfyUI extension for managing and organizing prompt additions with support for individual prompts, prompt groups, and automatic trigger-word matching.
๐ Features
Core Functionality
- Individual Prompt Management: Create, edit, and organize individual prompt additions.
- Prompt Groups: Group related prompt additons together for batch operations.
- Multiple Operation Modes: Choose between applying an individual prompt addition, a specific group of prompt additions, or automatically apply groups of prompt additions based on the checkpoint name.
๐ฆ Installation
Quick Install (Recommended)
This will be available once I'm happy enough with this node to publish it to the repository.
- ~~Install ComfyUI~~
- ~~Install ComfyUI-Manager~~
- ~~Look up "ComfyUI Prompt Companion" in ComfyUI-Manager and install~~
- ~~Restart ComfyUI~~
Manual Install
- Clone this repository to your ComfyUI custom nodes directory:
cd ComfyUI/custom_nodes/ git clone https://github.com/jfcantu/ComfyUI-Prompt-Companion.git
- Restart ComfyUI
- The Prompt Companion node will be available in the
jfc
category
๐ฏ Usage
Basic Setup
-
Add the Node: Search for "PromptCompanion" in the node browser and add it to your workflow.
-
Configure Inputs:
-
ckpt_name
: Select your checkpoint. -
addition_type
: Choose "Individual" mode to select an individual prompt addition, or "Group" mode to apply one or more groups of prompt additions. -
prompt_group_mode
: Only available in "Group" mode. Choose "Manual" to select a single prompt addition, or "Automatic" to apply multiple groups based on the checkpoint name. -
combine_mode
: Specify whether your prompt additions go in front of your prompts (prepend) or after them (append). -
prompt_addition_name
: Only available in "Individual" mode. Select the prompt addition to apply. -
prompt_addition_group
: Only available in "Group" addition mode when "Manual" group mode is selected. Select a prompt addition group to apply. -
positive_addition
/negative_addition
:- In Individual mode, you can edit your prompt addition here directly.
- In Group mode, this will display the collected prompt additions that will be applied, which cannot be edited.
-
positive_prompt
/negative_prompt
: Your base prompts. Can be input from another node, or entered directly.
-
Managing Prompt Additions
Start by right-clicking the node, and selecting "Edit Prompt Additions."
Adding/Modifying Prompt Additions
Pretty self-explanatory. Create, delete, modify, rename, save with a new name.
Adding/Modifying Prompt Groups
Click "Create New" to create a new one, or select one from the list to edit an exiting one.
"Trigger words" are strings that Prompt Companion will look for in your checkpoint name/path. If they match any part of it, the prompt group will be included in the list of additions.
While a prompt group is selected, select individual prompt additions to add/remove them from the prompt group.
Select "(none)" or click "Cancel" to exit.
NOTE: You can't edit prompt additions while editing a Prompt Group.
๐ง Architecture
Frontend Components
extension.js
: Main ComfyUI extension registration and node behaviorpromptAdditionManager.js
: Dialog manager for CRUD operationsapi-operations.js
: HTTP client for backend communicationstate-manager.js
: Centralized state management with event system
Backend Components
nodes.py
: ComfyUI node definition and API endpointsextension_config.py
: Data models and configuration managementconfig-schema.json
: JSON schema for data validation
Debug Mode
Enable debug logging by opening browser developer tools:
// Check current state
console.log(window.promptState?.getState());
๐งช Development
Setup
To install the dev dependencies and pre-commit:
cd ComfyUI-Prompt-Companion
pip install -e .[dev]
pre-commit install
Project Structure
ComfyUI-Prompt-Companion/
โโโ src/
โ โโโ web/ # Frontend JavaScript modules
โ โ โโโ extension.js # Main ComfyUI extension
โ โ โโโ promptAdditionManager.js # UI dialog manager
โ โ โโโ api-operations.js # HTTP client
โ โ โโโ state-manager.js # State management
โ โโโ nodes.py # Backend node and API
โ โโโ extension_config.py # Data models and config
โ โโโ config-schema.json # Data validation schema
โโโ __init__.py # Python module initialization
โโโ README.md # This file
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make changes with proper documentation
- Add tests for new functionality
- Submit a pull request