Add a separate preview node to prevent generator from running twice, unique_id is buggy
This commit is contained in:
@@ -19,18 +19,21 @@ pip install https://github.com/jllllll/exllama/releases/download/0.0.17/exllama-
|
||||
## Nodes
|
||||
Comes with the following nodes:
|
||||
|
||||
### ExLlama Loader
|
||||
### Loader
|
||||
Used to load 4-bit GPTQ Llama/2 models. You can find a lot of them over at [Hugging Face](https://huggingface.co/TheBloke).
|
||||
ExLlama allocates [memory](https://github.com/turboderp/exllama/issues/259) according to `max_seq_len`. Lowering it is a good way to save on GPU RAM.
|
||||
It's currently not possible to [offload](https://github.com/turboderp/exllama/issues/177) the model to CPU RAM.
|
||||
|
||||
### ExLlama Generator
|
||||
### Generator
|
||||
Generates a `string` based on the given `prompt` for use with other nodes.
|
||||
Default values correspond to the `simple-1` preset from [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
|
||||
ExLlama isn't [deterministic](https://github.com/turboderp/exllama/issues/201), so the outputs may differ even with the same seed.
|
||||
|
||||
## Example
|
||||
The workflow can be opened directly in ComfyUI.
|
||||
### Previewer
|
||||
Displays generated prompts in the UI.
|
||||
|
||||
## Workflow
|
||||
Can be opened directly in ComfyUI.
|
||||
Model used: [MythoLogic-Mini-7B](https://huggingface.co/TheBloke/MythoLogic-Mini-7B-GPTQ).
|
||||
|
||||

|
||||
|
||||
+5
-3
@@ -1,13 +1,15 @@
|
||||
from .nodes import Generator, Loader
|
||||
from .nodes import Generator, Loader, Previewer
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"ZuellniExLlamaGenerator": Generator,
|
||||
"ZuellniExLlamaLoader": Loader,
|
||||
"ZuellniExLlamaGenerator": Generator,
|
||||
"ZuellniExLlamaPreviewer": Previewer,
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"ZuellniExLlamaGenerator": "ExLlama Generator",
|
||||
"ZuellniExLlamaLoader": "ExLlama Loader",
|
||||
"ZuellniExLlamaGenerator": "ExLlama Generator",
|
||||
"ZuellniExLlamaPreviewer": "ExLlama Previewer",
|
||||
}
|
||||
|
||||
WEB_DIRECTORY = "."
|
||||
|
||||
@@ -27,7 +27,6 @@ class Generator:
|
||||
|
||||
CATEGORY = "Zuellni/ExLlama"
|
||||
FUNCTION = "generate"
|
||||
OUTPUT_NODE = True
|
||||
RETURN_NAMES = ("TEXT",)
|
||||
RETURN_TYPES = ("STRING",)
|
||||
|
||||
@@ -58,7 +57,7 @@ class Generator:
|
||||
text += chunk
|
||||
|
||||
text = text.strip()
|
||||
return {"ui": {"text": [text]}, "result": (text,)}
|
||||
return (text,)
|
||||
|
||||
|
||||
class Loader:
|
||||
@@ -91,3 +90,17 @@ class Loader:
|
||||
tokenizer = ExLlamaTokenizer(str(model_dir / "tokenizer.model"))
|
||||
generator = ExLlamaAltGenerator(model, tokenizer, cache)
|
||||
return (generator,)
|
||||
|
||||
|
||||
class Previewer:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {"required": {"text": ("STRING", {"forceInput": True})}}
|
||||
|
||||
CATEGORY = "Zuellni/ExLlama"
|
||||
FUNCTION = "preview"
|
||||
OUTPUT_NODE = True
|
||||
RETURN_TYPES = ()
|
||||
|
||||
def preview(self, text):
|
||||
return {"ui": {"text": [text]}}
|
||||
|
||||
+2
-2
@@ -4,9 +4,9 @@ import { app } from "../../../scripts/app.js";
|
||||
import { ComfyWidgets } from "../../../scripts/widgets.js";
|
||||
|
||||
app.registerExtension({
|
||||
name: "Zuellni.ExLlama.Generator",
|
||||
name: "ZuellniExLlamaPreviewer",
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||
if (nodeData.name === "ZuellniExLlamaGenerator") {
|
||||
if (nodeData.name === "ZuellniExLlamaPreviewer") {
|
||||
const onExecuted = nodeType.prototype.onExecuted;
|
||||
|
||||
nodeType.prototype.onExecuted = function (message) {
|
||||
|
||||
Reference in New Issue
Block a user