Just my Comfy nodes. But feel free to use it. Prompt Database Node, LMStudio server access (prompt enhancer and more).

#1
by Andyx1976 - opened

Updstes:

june 6th26- minor but important fix to Prompt Enhancer node. now loads (as it should) configuration (model lists, token...) from existing config file when added to workflow, instead of being empty. No other changes. The old Bothnodes.zip contained the previous version, so downlaod the new one to get the current versions.

June 17, big update to prompt enhance.
select Server model from dropdown menu, recent used first, all others later. Should work on all openai api server types, not just lmstudio.
Optional unload Comfyui models from Vram (only) IF prompt enhancer is run. If it is bypassed (manual or auto) this model unload is NOT triggered.

Readme:

Prompt Database:

Save multiple prompts (or whatever) with names, in three different categories (three separate sets of saved prompts). It's stored in the node's folder, in json file. so all saved prompts are available in any workflow in your comfy installation. Should be simple to understand.

Of course it doesn't have to be prompts. You can use it as simple database for whatever, any name and any text. Keep in mind it is saved in plain text in the nodes local folder! (a5prompt_database.json)

promptdatabase2

LMStudio Prompt Enhancer:

Little patches as mentioned above. I think all below is adjusted to it.

Send any system prompt to a localhost server (Example LMStudio) and/or a user prompt (to improve) and/or a image. Then get the llm's enhanced prompt back, exportable as string for any text input in Comfyui.
Three modes "Always run LLM", "Use last prompt" (Manual Bypass, sends last enhanced prompt again, which can be manually edited) and "Bypass if unchanged", also sends the last enhanced prompt, IF input image and prompt have not changed.

IF input prompt ot image has changed, it runs the LLM again, creating a new enhanced prompt, overwriting the old one.

This functionality is the main reason, i (i.e. Codex) made my own. So i don't have to copy and paste stuff betwen prompt and clip fields to use an already anhanced prompt again AND be able to make edits to it myself. .
Model change and manual edits to the enhanced prompt are ignored in the bypass check!

Optional load/unload model for generation switches, (needs token set in LMSTUDIO, see below). dropdown for last used models, followed by all models the server lists. Selecting a model instead of "use Loaded Default" LMStudio requires api authentication enabled and token set!

New: server dropdown list. New Optional Comfymodel unload IF llm runs.

  • More Options: Api token, max tokens, auto removes thinking blocks.
  • NEW (17.june): No need to manually copy model names anymore thanks to dropdown. For more compatibility for openai api servers other than LMStudio, we use a more generic server get list instead of th neat LMStudio specific one. Combined with little algorithm to mark likely vision capable models.
  • NEW option: Unload ComfyUi models from Vram (ONLY) if LLM is run. It will ONLY do that if the LLM is actually run. So IF lmstudio loads the llm to do your prommpt, it does not crash with a big Comfyui image model still in your vram.

Sending a image with your prompt requires a vision model to be,loaded of course. See community post (or node tooltips!) for some important details.
Also keep in mind this was made for local use with a local llm, on a single computer. So it deliberately balances convenience and complexity with safety. The server token is never displayed in the node (XXX) BUT is saved in plain text in that json file.

They dynamic Duo at work (more or less the example workflow):

newllmnodes1

Prompt enhancer up close.

grafik

Installation:

copy/clone directories or extract zip into Comfyui Custom_nodes (so it looks like this: \ComfyUI\custom_nodes\comfyui_A5lmstudio_prompt_enhancer\ )
See community post for more details, images. See example Workflow, using both nodes, under files.
NOT on github/comfyui Manager

New Workflow (Example workflow 2 db nodes , basically the same, just using two database nodes just to show an example. And the image shows the new enhancer node:

Exampleworkflow2nodes

(this is the example workflow under files) (The prompt enhance node in the image is the old one! If you load it it wil be the new one):

A5nodes

Added notes: To use the load and unload model switches, LMStudio (not me) requires a API token to be set.

But you don't need a token to just send it to whatever model the LMStudio server has currently loaded. Just disable the load/unload switches AND select "Use loaded Default Model" from the dropdown menu.
and it's in easy mode (it sends to whatever LMStudip/the server has loaded). The "require authentication" option needs to be disabled in LMStudios server settings of course (else you need a api token!).
a5settings
Also i recommend switching one "Unlaod Comfy models from Vram" to kick any comfy models out of vram before loading the lm studio model! Else LMStudio may try to load that xxGB LLM model while LTX or whatever is still in it.
That option ONLY removes models from Vram, it does NOT empty cach or anything. And it does NOT execute, if the llm is bypassed.

How to copy a model id to add to the node? :

This has changed. Simply select a server from the dropdown menu. "Use loaded Default Model" from the dropdown menu to just send to whatever is loaded.
The bypass functionality should still work (If input prompt or image have not changed, the last enhanced prompt is sent again. )
IF you added a new model to your server / LMStudio, you need to reload the prompt enhancer node (rigth click in it, "Reload node), to show it to the server list.")

Like if you like :)

Sign up or log in to comment