npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

comfyui-nodejs

v1.0.3

Published

An ComfyUI NodeJs Module for Easy Inference with pre-made Workflows

Downloads

7

Readme

ComfyUI Workflow Loader

ComfyUI Workflow Loader is a Node.js library designed to manage and manipulate ComfyUI workflows. This library allows you to load workflow JSON files, fill placeholders, and generate images based on the workflows.

Features

  • Load ComfyUI workflow JSON files
  • Automatically detect placeholders
  • Programmatically fill placeholders
  • Provide default values for missing placeholders
  • Generate updated workflows in JSON format
  • Generate images based on the workflow
  • Option to save generated images

Installation

Install ComfyUI Workflow Loader using npm:

npm install comfyui-nodejs

Usage

  • Make sure ComfyUi is up and running on local network before use this module

Preparing Workflow

Open ComfyUI, load or edit your workflow, then save it in API format.

  • edit workflow to add placeholders.
  • Placeholders must be between curly braces.
  • Paths or other escape charachters should be doubled. Ex:
"ckpt_name": "Stable-diffusion\\SdXl\\sd_xl_turbo_1.0_fp16.safetensors"

there is two \ for paths.

  • For numeric values use syntax like this :
 "width": {width}

, (No quotes around {width})

  • For strings ( like positive or negative prompt or model paths) use this syntax :
   "text": "{positive}"

( quotes around placeholders)

  • Save it into a folder named "workflows" inside your project root

Basic Usage

import { startComfyUi, initClient } from "comfyui-nodejs";
import Workflowloader from "comfyui-nodejs";

// Initialize the client
let client = await initClient(/*comfyuiaddress*/); //defaults to 127.0.0.1:8188
await client.connect();

// Load the workflow
let flux = new Workflowloader("sdxl_turbo.json", client, true);

// Prepare placeholders
flux.prepare({
  positive: "a cat in red suit, throws basketball",
  steps: 1,
  batchSize: 2,
});

// Set additional placeholders
flux.width = 768;

// Generate images
let result = await flux.generate();

// Prepare new placeholders and generate again
flux.prepare({
  positive: "a giraffe",
  steps: 1,
});
//Or set individual placeholders.
flux.width = 1024;
await flux.generate();

console.log("Done");

API

Workflowloader(workflowPath, client, saveImages)

Creates a new Workflowloader instance.

  • workflowPath: Path to the workflow JSON file.
  • client: ComfyUI client instance.
  • saveImages: Boolean, whether to save generated images (default: false).

prepare(obj)

Fills placeholders using the provided object.

  • obj: An object containing placeholder values.
  • Returns: { missingPlaceholders, extraKeys } object.

generate()

Generates images based on the current workflow.

  • Returns: A Promise that resolves to the generated image data.

finalize

Returns the updated workflow.

  • Returns: { status: boolean, workflow: string | null, message: string | null }

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

We welcome contributions! Please read our contributing guide before submitting a pull request.

Contact

For questions or feedback, please use GitHub Issues.