Prompt Edit 是一个为 ComfyUI 设计的自定义节点,它允许你在工作流执行过程中暂停,编辑文本提示词,然后继续执行。这对于需要在生成过程中动态调整提示词的场景非常有用。
custom_nodes 目录:cd ComfyUI/custom_nodes
git clone https://github.com/your-username/Comfyui_Prompt_Edit.git
ComfyUI/custom_nodes/Comfyui_Prompt_EditComfyui_Prompt_Edit/ ├── __init__.py # 主节点实现(后端) ├── web/ │ └── prompt_edit.js # 前端 UI 实现 ├── README.md # 本文档 ├── EXAMPLE.md # 使用示例 └── test_node.py # 测试脚本
在 ComfyUI 界面中:
右键点击空白处 → Add Node → Ken-Chen → Prompt Edit ✏️
[文本源节点] → [Prompt Edit] → [目标节点] ↓ ↓ ↓ (输出文本) (编辑文本) (接收编辑后的文本)
示例工作流:
[Primitive STRING] → [Prompt Edit] → [Show Text]
方式 A:在弹出对话框中编辑
方式 B:在节点内编辑
方式 C:混合编辑
点击 ✓ 继续执行 后:
┌─────────────────────────────────┐ │ Prompt Edit ✏️ │ ├─────────────────────────────────┤ │ ● text (输入端口) │ │ │ │ ┌─────────────────────────────┐ │ │ │ │ │ │ │ 多行文本编辑框 │ │ │ │ (200px 高) │ │ │ │ │ │ │ └─────────────────────────────┘ │ │ │ │ [📝 打开大编辑器] │ │ [✓ 继续执行] │ │ │ │ ● edited_text (输出端口) │ └─────────────────────────────────┘
工作流: [Primitive STRING] → [Prompt Edit] → [Show Text] 步骤: 1. 在 Primitive STRING 中输入: "a beautiful sunset" 2. 运行工作流 3. Prompt Edit 节点暂停,对话框弹出 4. 编辑文本为: "a beautiful sunset over the ocean, golden hour, cinematic" 5. 点击 "✓ 继续执行" 6. Show Text 显示编辑后的文本
工作流: [Text Node] → [Prompt Edit] → [Another Prompt Edit] → [Final Output] 说明: - 可以在工作流中添加多个 Prompt Edit 节点 - 每个节点都会暂停并等待编辑 - 适合需要多次调整的复杂工作流
工作流: [Generate Text] → [Prompt Edit] → [Image Generation] 用途: - 自动生成初始提示词 - 人工审核和优化 - 生成最终图像
| 参数 | 类型 | 说明 |
|---|---|---|
text | STRING (输入) | 从其他节点接收的文本(强制连线输入) |
edited_text_widget | STRING (widget) | 节点内的多行文本编辑框 |
edited_text | STRING (输出) | 编辑后的文本输出 |
text 输入端口接收文本session_id| 端点 | 方法 | 说明 |
|---|---|---|
/prompt_edit/update | POST | 更新文本(自动保存,500ms 防抖) |
/prompt_edit/confirm | POST | 确认编辑,继续执行 |
/prompt_edit/cancel | POST | 取消对话框(工作流继续等待) |
timeout 变量编辑 __init__.py,找到以下代码:
timeout = 3600 # 1 hour timeout
修改为你需要的秒数,例如:
timeout = 7200 # 2 hours
编辑 web/prompt_edit.js,找到以下代码:
dialog.style.cssText = `
min-width: 800px;
max-width: 90vw;
...
`;
textarea.style.cssText = `
...
min-height: 400px;
max-height: 70vh;
...
`;
根据需要调整尺寸。
症状:节点左侧没有绿色的 text 输入端口
解决方案:
症状:点击"取消"或"继续执行"后对话框不关闭
解决方案:
症状:节点内的文本框只有一行,无法显示多行文本
解决方案:
__init__.py 中 edited_text_widget 的 multiline 设置为 True欢迎提交 Issue 和 Pull Request!
MIT License
Prompt Edit is a custom node for ComfyUI that allows you to pause workflow execution, edit text prompts, and then continue. This is very useful for scenarios where you need to dynamically adjust prompts during the generation process.
custom_nodes directory:cd ComfyUI/custom_nodes
git clone https://github.com/your-username/Comfyui_Prompt_Edit.git
ComfyUI/custom_nodes/Comfyui_Prompt_EditIn ComfyUI interface:
Right-click → Add Node → Ken-Chen → Prompt Edit ✏️
[Text Source Node] → [Prompt Edit] → [Target Node]
Example Workflow:
[Primitive STRING] → [Prompt Edit] → [Show Text]
Method A: Edit in popup dialog
Method B: Edit in node
Method C: Mixed editing
| Parameter | Type | Description |
|---|---|---|
text | STRING (input) | Text received from other nodes (forced input) |
edited_text_widget | STRING (widget) | Multiline text editor inside node |
edited_text | STRING (output) | Edited text output |
text input portsession_id| Endpoint | Method | Description |
|---|---|---|
/prompt_edit/update | POST | Update text (auto-save, 500ms debounce) |
/prompt_edit/confirm | POST | Confirm edit, continue execution |
/prompt_edit/cancel | POST | Cancel dialog (workflow keeps waiting) |
Issues and Pull Requests are welcome!
MIT License