2025-01-27 00:23:23 -05:00
2025-01-27 00:23:23 -05:00
2025-01-27 00:23:23 -05:00
2025-01-27 00:17:57 -05:00
2025-01-27 00:23:23 -05:00
2025-01-27 00:23:23 -05:00
2025-01-27 00:23:23 -05:00
2025-01-27 00:23:23 -05:00

ComfyUI-EBU-LMStudio

A collection of custom nodes for ComfyUI that provide integration with LMStudio. These nodes allow you to load, unload, and interact with LLMs through the LMStudio command-line interface. This can be used to facilitate the automatic creation of descriptive prompts using a LLM, which is helpful for modern image models like Flux that respond well to detailed prompts in natural language.

Features

  • Load and manage LLM models directly from ComfyUI
  • Fuzzy model name searching for easy model selection
  • Configurable context length and parameters
  • Optional image model unloading to free up VRAM
  • Simple prompt submission interface
  • Option for UTF-8 safe LLM text responses
  • Detailed error reporting and status messages

Installation

  1. Copy this directory to your ComfyUI/custom_nodes/ directory
  2. Install LMStudio and make sure 'lms' command line tools are working and that 'Developer Mode' is enabled to run LMStudio as a local server.
  3. Make sure to have at least one LLM installed inside of LMStudio.
  4. Test this by running lms ls --detailed from the command line. You should see a list of all installed LLMs. If this doesn't work you may need to modify your PATH.
  5. Restart ComfyUI

Nodes

EBU LMStudio Load Model

Unloads any loaded LLMs and then loads an LLM model into LMStudio with the following parameters:

  • input_string: Input text (passed through unchanged), serves to trigger the action
  • model_search_string: Part of the model name to search for (default: "llama"). Spaces are treated as wild cards. First matching LLM is loaded. So "nemo q5" will match "Mistral-Nemo-Instruct-2407-abliterated.Q5_K_M.gguf" for example.
  • context_length: Model context length (default: 4096)
  • seed: Random seed to ensure that this runs on each request
  • unload_image_models_first: Whether to unload ComfyUI image models before loading LLM

Returns:

  • export_string: The input string (unchanged)
  • model_selected: Full path of the loaded model or error message
  • models_found: Complete list of available models

EBU LMStudio Unload Models

Unloads all currently loaded LLM models from LMStudio.

Parameters:

  • input_string: Input text (passed through unchanged), serves to trigger the action
  • seed: Random seed to ensure that this runs on each request

Returns:

  • export_string: The input string (unchanged)

EBU LMStudio Submit Prompt

Submits a prompt to the currently loaded LLM and returns the response.

Parameters:

  • prompt: The text prompt to send to the LLM
  • system_message: System context message (default provides image prompt generation context)
  • url: LMStudio API endpoint (default: http://127.0.0.1:1234/v1/chat/completions)
  • context_length: Context window size (default: 4096)
  • seed: Random seed for reproducibility
  • max_tokens: Maximum response length (default: 300)
  • temp: Temperature parameter (default: 0.5)
  • top_p: Top-p sampling parameter (default: 0.9)
  • utf8_safe_replace: Convert response to safe ASCII characters (default: false)

Returns:

  • generated_text: The LLM's response

Requirements

  • Python 3.x
  • ComfyUI
  • LMStudio with CLI access and local server configured

Common Issues and Solutions

"can't connect to lmstudio"

  • Ensure LMStudio is running
  • Check that LMS CLI Access is healthy
  • Verify the port number matches your LMStudio settings
  • Confirm LMStudio is in your system PATH

"no model by that name found"

  • Check that the model name search string matches part of your model's name
  • Use lms ls --detailed in terminal to see available models
  • Models must be added to LMStudio before they can be loaded

Model Loading Issues

  • Ensure you have enough VRAM available
  • Try unloading image models first
  • Check LMStudio logs for detailed error messages

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

  • Initially inspired by the LLM node from CrasH Utils Custom Nodes
  • Thanks to the ComfyUI and LMStudio teams

For more help

See the included example workflow flux_example_ebu_lmstudio.json to see how these three nodes can work together for VRAM efficient prompt generation and execution.

S
Description
No description provided
Readme MIT
124 KiB
Languages
Python 100%