Merge pull request #79 from ComfyAssets/feature/PromptSearchList

Feature/prompt search list
This commit is contained in:
Vito
2025-12-06 07:27:40 -08:00
committed by GitHub
4 changed files with 247 additions and 87 deletions
+58 -86
View File
@@ -2,95 +2,12 @@
A comprehensive ComfyUI custom node that extends the standard text encoder with persistent prompt storage, advanced search capabilities, automatic image gallery system, and powerful ComfyUI workflow metadata analysis using SQLite.
# 🚀 Prompt Manager v2 Beta - Now Available!
## 📋 A Note on v2 Development
## ⚠️ IMPORTANT: BACKUP YOUR DATA FIRST!
**Before testing v2, you MUST backup your `prompts.db` file!** The v1 to v2 migration is irreversible. Copy your `prompts.db` to a safe location before proceeding.
## 🎉 Beta Testing Now Open
We're excited to announce that Prompt Manager v2 is ready for beta testing! This is a complete rewrite with major improvements and new features.
### ✨ What's Working in Beta
- **🖼️ Gallery System** - Completely redesigned with improved performance
- **📊 New Prompt Tracking** - Advanced tracking system with better metadata handling
- **🎛️ 3 New Widgets** - Enhanced UI components for better workflow integration
- **🎬 Film Strip View** - Visual prompt browsing with thumbnail preview
- **🌫️ Smart Blur** - New blur option with customizable tag triggers for sensitive content
- **⚙️ Settings Panel** - Comprehensive configuration options
- **➕ Add Prompt Dialog** - Streamlined prompt creation interface
### 🚧 Still in Development
- **📋 Metadata Viewer** - Being ported from v1
- **📁 Collections** - New organizational system coming soon
### ⚠️ Known Issues & Important Notes
- **⏳ Initial Stats Processing**: The first time you load v2, stats parsing can take **2-3 minutes** for large databases. We're actively optimizing this - it's one of the main reasons for the beta!
- **🔄 v1 → v2 Migration**: We especially need testers who can help validate the migration process from v1 databases
- The migration is one-way - once converted, you cannot go back to v1
### 📊 Beta Testing Focus Areas
1. **Database Migration** - Test the v1 to v2 migration with your existing data (after backing up!)
2. **Performance** - Report initial load times and any performance issues
3. **Gallery Functionality** - Test the new gallery with your image collections
4. **Widget Integration** - Verify the 3 new widgets work in your workflows
5. **Film Strip View** - Test thumbnail generation and navigation
6. **Blur Feature** - Configure and test the tag-triggered blur system
## 🧪 How to Join Beta Testing
1. **Backup your `prompts.db` file** (Critical!)
2. Checkout the `v2/beta-02-win32` branch:
```bash
git checkout v2/beta-02-win32
```
3. Restart ComfyUI
4. Test the features and migration process
5. Report issues or feedback via [Issues](../../issues) or [Discussions](../../discussions)
## 🤝 Help Shape the Future of Prompt Manager!
**Join our growing community and influence the features YOU want!**
This beta is more than just testing - it's your chance to:
- **Shape Development** - Your feedback directly influences what we build next
- **Request Features** - Tell us what tools would make your workflow better
- **Build Community** - Connect with other power users and share workflows
- **Priority Access** - Beta testers get early access to new features
We're building Prompt Manager WITH the community, not just for it. Your use cases, workflow needs, and feature ideas are what drive our roadmap. Whether you need better organization tools, advanced search capabilities, or integration features - we want to hear about it!
👥 **Join the conversation:**
- Share your workflows and use cases
- Vote on upcoming features
- Collaborate with other creators
- Help prioritize our development roadmap
## 📊 Progress
**Beta completion status:**
- [█████████░] 90% complete
✅ Core migration system
✅ Gallery redesign
✅ New widgets & UI
✅ Prompt tracking system
✅ Film strip view
✅ Blur feature with triggers
✅ Settings panel
⬜ Performance optimization
⬜ Metadata viewer port
⬜ Collections system
V2 development will take longer as life has taken me in other directions for the moment. I will still work on it but not as actively as before. In the meantime, I will backport some of the features users have requested from v2 over to v1. Once v2 is ready, I will update here. Thank you for your continued support!
---
💡 Your feedback is crucial for making v2 stable and performant. Together, we're building the prompt management system the community needs!
## Overview
![Prompt Manager Interface](images/pm-01.png)
@@ -114,6 +31,17 @@ A text-focused variant that outputs raw STRING for maximum flexibility:
- **🔗 Text Concatenation**: Built-in prepend/append functionality for dynamic text assembly
- **⚡ Lightweight Processing**: No CLIP encoding overhead for text-only workflows
### **PromptSearchList** (Batch Processing Node)
A search node that outputs prompts as a list for batch processing workflows:
- **🔍 Database Search**: Search prompts by text, category, tags, and rating
- **📋 List Output**: Uses `OUTPUT_IS_LIST` for native batch processing support
- **🔗 Batch Compatible**: Connect directly to batch processing nodes like String OutputList
- **⚡ Read-Only**: Lightweight search operation without database writes
This node enables powerful batch workflows by allowing you to search your prompt database and process multiple prompts in a single execution.
### **Shared Features**
Both nodes include the complete PromptManager feature set:
@@ -329,6 +257,20 @@ For text-only workflows or when you need STRING output:
- **Append Text**: Text added after your main prompt
4. **Connect the STRING output** to any node that accepts text input
#### Using PromptSearchList (Batch Processing)
For batch processing workflows that need multiple prompts:
1. **Add the PromptSearchList node** to your workflow
2. **Configure search filters**:
- **text**: Search for prompts containing this text
- **category**: Filter by specific category
- **tags**: Comma-separated tags to filter by (e.g., "anime, detailed")
- **min_rating**: Minimum rating (0-5) to include
- **limit**: Maximum number of results (1-1000, default 50)
3. **Connect the prompts output** to batch-compatible nodes like String OutputList
4. **Each matching prompt** will be processed as a separate batch item
#### Shared Metadata Options
Both nodes support the same metadata fields:
@@ -528,9 +470,29 @@ PromptManagerText → Text Processor → Style Applicator → Final Text Node
"cyberpunk city" → style processing → "neon-lit cyberpunk metropolis at night"
```
### PromptSearchList (Batch Processing) Examples
#### Example 6: Batch Processing with Tags
```
Tags: "anime, detailed"
Limit: 10
→ Outputs: List of up to 10 prompts with both "anime" and "detailed" tags
→ Each prompt is processed as a separate batch item
```
#### Example 7: Category-Based Batch
```
Category: "portraits"
Min Rating: 4
Limit: 20
→ Outputs: List of up to 20 highly-rated portrait prompts for batch generation
```
### Traditional Examples
#### Example 6: Abstract Art
#### Example 8: Abstract Art
```
Input: "Swirling colors in an abstract geometric pattern"
@@ -581,6 +543,7 @@ CREATE TABLE generated_images (
- **`prompt_manager.py`** - Main ComfyUI node implementation (CLIP encoding)
- **`prompt_manager_text.py`** - Text-only node implementation (STRING output)
- **`prompt_search_list.py`** - Batch search node implementation (LIST output)
- **`database/models.py`** - Database schema and connection management
- **`database/operations.py`** - CRUD operations and search functionality
- **`py/api.py`** - Web API endpoints for the interface
@@ -604,6 +567,7 @@ ComfyUI_PromptManager/
├── __init__.py # Node registration
├── prompt_manager.py # Main node implementation (CLIP encoding)
├── prompt_manager_text.py # Text-only node implementation (STRING output)
├── prompt_search_list.py # Batch search node implementation (LIST output)
├── database/
│ ├── __init__.py
│ ├── models.py # Database schema
@@ -813,6 +777,14 @@ MIT License - see LICENSE file for details.
## Changelog
### v3.0.10 (Batch Processing Node)
- **📋 PromptSearchList Node**: New node that searches the prompt database and outputs results as a list
- **🔗 Batch Processing Support**: Uses `OUTPUT_IS_LIST` for native ComfyUI batch processing compatibility
- **🔍 Full Search Capabilities**: Search by text, category, tags, minimum rating, and result limit
- **⚡ Lightweight Operation**: Read-only search with no database writes
- **🎯 Workflow Integration**: Connect directly to batch processing nodes like String OutputList
### v3.0.9 (Output-Wide Gallery & Video Support)
- **📁 Output-Wide Gallery Mode**: Complete gallery redesign to show ALL content from ComfyUI output directory
+3
View File
@@ -39,15 +39,18 @@ def get_version():
from .prompt_manager import PromptManager
from .prompt_manager_text import PromptManagerText
from .prompt_search_list import PromptSearchList
NODE_CLASS_MAPPINGS = {
"PromptManager": PromptManager,
"PromptManagerText": PromptManagerText,
"PromptSearchList": PromptSearchList,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"PromptManager": "Prompt Manager",
"PromptManagerText": "Prompt Manager Text",
"PromptSearchList": "Prompt Search List",
}
# Define path to web directory for UI components
+185
View File
@@ -0,0 +1,185 @@
"""
PromptSearchList: A ComfyUI node that searches prompts and outputs results as a list.
This node enables batch processing workflows by outputting prompt texts with
OUTPUT_IS_LIST=True, allowing direct connection to nodes that accept list inputs.
"""
from typing import Any, Dict, List, Tuple
try:
from .utils.logging_config import get_logger
except ImportError:
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from utils.logging_config import get_logger
try:
from comfy.comfy_types import IO, ComfyNodeABC, InputTypeDict
except ImportError:
class ComfyNodeABC:
pass
class IO:
STRING = "STRING"
INT = "INT"
InputTypeDict = dict
try:
from .database.operations import PromptDatabase
except ImportError:
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from database.operations import PromptDatabase
class PromptSearchList(ComfyNodeABC):
"""
A ComfyUI node that searches the prompt database and outputs matching
prompts as a list for batch processing workflows.
Features:
- Search by text content
- Filter by category, tags, and minimum rating
- Outputs as OUTPUT_IS_LIST for batch node compatibility
- Read-only operation (no database writes)
"""
def __init__(self):
self.logger = get_logger("prompt_search_list.node")
self.logger.debug("Initializing PromptSearchList node")
self.db = PromptDatabase()
@classmethod
def INPUT_TYPES(cls) -> InputTypeDict:
return {
"required": {},
"optional": {
"text": (
IO.STRING,
{
"default": "",
"tooltip": "Search text to match against prompt content",
},
),
"category": (
IO.STRING,
{
"default": "",
"tooltip": "Filter by specific category",
},
),
"tags": (
IO.STRING,
{
"default": "",
"tooltip": "Comma-separated list of tags to filter by",
},
),
"min_rating": (
IO.INT,
{
"default": 0,
"min": 0,
"max": 5,
"tooltip": "Minimum rating (0-5) to include in results",
},
),
"limit": (
IO.INT,
{
"default": 50,
"min": 1,
"max": 1000,
"tooltip": "Maximum number of results to return",
},
),
},
}
RETURN_TYPES = (IO.STRING,)
RETURN_NAMES = ("prompts",)
OUTPUT_IS_LIST = (True,)
OUTPUT_TOOLTIPS = ("List of prompt texts matching the search criteria.",)
FUNCTION = "search"
CATEGORY = "🫶 ComfyAssets/🧠 Prompts"
DESCRIPTION = (
"Searches the prompt database and outputs matching prompts as a list. "
"Use this node to retrieve stored prompts for batch processing workflows. "
"Connect to nodes that accept list inputs like String OutputList or batch processors."
)
def search(
self,
text: str = "",
category: str = "",
tags: str = "",
min_rating: int = 0,
limit: int = 50,
) -> Tuple[List[str]]:
"""
Search for prompts matching the given criteria.
Args:
text: Search text to match against prompt content
category: Filter by specific category
tags: Comma-separated list of tags to filter by
min_rating: Minimum rating (0-5) to include
limit: Maximum number of results to return
Returns:
Tuple containing a list of prompt text strings
"""
try:
# Parse tags from comma-separated string
tags_list = None
if tags and tags.strip():
tags_list = [tag.strip() for tag in tags.split(",") if tag.strip()]
# Perform search
results = self.db.search_prompts(
text=text.strip() if text and text.strip() else None,
category=category.strip() if category and category.strip() else None,
tags=tags_list,
rating_min=min_rating if min_rating > 0 else None,
limit=limit,
)
# Extract just the prompt text from results
prompt_texts = [r["text"] for r in results if r.get("text")]
self.logger.debug(
f"Search returned {len(prompt_texts)} prompts "
f"(text='{text[:20]}...' if text else '', category='{category}', "
f"tags={tags_list}, min_rating={min_rating}, limit={limit})"
)
# Return empty list if no results (not an error)
if not prompt_texts:
self.logger.info("Search returned no results")
return ([],)
return (prompt_texts,)
except Exception as e:
self.logger.error(f"Search error: {e}", exc_info=True)
# Return empty list on error to avoid breaking workflows
return ([],)
@classmethod
def IS_CHANGED(cls, text="", category="", tags="", min_rating=0, limit=50):
"""
Always re-execute to get fresh results from the database.
The database contents may have changed since the last execution,
so we always return a unique value to trigger re-execution.
"""
import time
return time.time()
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "promptmanager"
description = "A powerful ComfyUI custom node that extends the standard text encoder with persistent prompt storage, advanced search capabilities, and an automatic image gallery system using SQLite."
version = "3.0.21"
version = "3.0.22"
license = {file = "LICENSE"}
dependencies = ["# Core dependencies for PromptManager", "# Note: Most dependencies are already included with ComfyUI", "# Already included with Python standard library:", "# - sqlite3", "# - hashlib", "# - json", "# - datetime", "# - os", "# - typing", "# - threading", "# - uuid", "# Required for gallery functionality:", "watchdog>=2.1.0 # For file system monitoring", "Pillow>=8.0.0 # For image metadata extraction (usually included with ComfyUI)", "# Optional dependencies for enhanced search functionality:", "# fuzzywuzzy[speedup]>=0.18.0 # For fuzzy string matching (optional)", "# sqlalchemy>=1.4.0 # For advanced ORM features (optional)", "# Development dependencies (optional):", "# pytest>=6.0.0 # For running tests", "# black>=22.0.0 # For code formatting", "# flake8>=4.0.0 # For linting", "# mypy>=0.910 # For type checking"]