- Cache manager with JSON read/write, TTL, corruption handling - Civitai client with SHA256 hash (sync+async) and API fetch - KaiCivitaiLoRALoader node with trigger words and JSON output - Node registration, HTTP routes, and secure image serving - Frontend extension with image preview, pagination, and NSFW blur - 49 unit tests covering all modules
71 lines
2.2 KiB
Markdown
71 lines
2.2 KiB
Markdown
# ComfyUI KaiUtilities - KaiCivitaiLoRALoader
|
|
|
|
A ComfyUI custom node that extends the built-in LoRA Loader to fetch and display Civitai metadata, including trigger words and preview images.
|
|
|
|
## Features
|
|
|
|
- **Trigger Words Output**: Automatically outputs comma-separated trigger words from Civitai metadata
|
|
- **Full JSON Output**: Exports complete Civitai metadata as JSON string for downstream nodes
|
|
- **Preview Images**: Displays preview images directly on the node with pagination support
|
|
- **NSFW Blur**: Automatically blurs NSFW preview images (click to toggle)
|
|
- **Local Caching**: Caches Civitai metadata and preview images locally with 7-day TTL
|
|
- **Concurrent Deduplication**: Multiple requests for the same LoRA are deduplicated automatically
|
|
|
|
## Installation
|
|
|
|
1. Clone this repository into your ComfyUI `custom_nodes/` directory:
|
|
|
|
```bash
|
|
cd ComfyUI/custom_nodes
|
|
git clone https://github.com/your-username/ComfyUI_KaiUtilities.git
|
|
```
|
|
|
|
2. Install dependencies:
|
|
|
|
```bash
|
|
cd ComfyUI_KaiUtilities
|
|
pip install aiohttp
|
|
```
|
|
|
|
3. Restart ComfyUI.
|
|
|
|
## Usage
|
|
|
|
1. In ComfyUI, add the node: **KaiUtilities/loaders** → **Kai Civitai LoRA Loader**
|
|
2. Select your LoRA file from the dropdown
|
|
3. Click **"Fetch Civitai Info"** to fetch metadata
|
|
4. The button changes to **"Refresh"** after fetching (click to force re-fetch)
|
|
5. Trigger words appear in the text widget
|
|
6. Preview images render below the widgets — click left/right arrows to paginate
|
|
7. Connect `trigger_words` or `civitai_json` outputs to downstream nodes
|
|
|
|
## File Structure
|
|
|
|
```
|
|
ComfyUI_KaiUtilities/
|
|
├── __init__.py # Node registration + HTTP routes
|
|
├── cache_manager.py # Local JSON/image cache manager
|
|
├── civitai_client.py # SHA256 hashing + Civitai API client
|
|
├── nodes.py # KaiCivitaiLoRALoader node class
|
|
├── frontend/ # Frontend JavaScript extension
|
|
│ └── kai_civitai_lora.js
|
|
└── tests/ # Unit tests
|
|
├── test_cache_manager.py
|
|
├── test_civitai_client.py
|
|
├── test_init.py
|
|
└── test_nodes.py
|
|
```
|
|
|
|
## Development
|
|
|
|
Run tests:
|
|
|
|
```bash
|
|
cd ComfyUI/custom_nodes/ComfyUI_KaiUtilities
|
|
PYTHONPATH=/path/to/ComfyUI:$PYTHONPATH python -m pytest tests/ -v
|
|
```
|
|
|
|
## License
|
|
|
|
MIT
|