From 9d8a0418bb8c79db3930e60ab4aba176fc3f5c8a Mon Sep 17 00:00:00 2001 From: drago87 Date: Thu, 26 Feb 2026 06:14:32 +0100 Subject: [PATCH] Update Changed the compilers output to use less tokens by collapsing the json sting to a single line updated the character json with more information --- nodes.py | 35 +++++-- pyproject.toml | 2 +- web/schema/character_female.json | 175 +++++++++++++++++++++++++++---- web/schema/character_male.json | 112 +++++++++++++++++++- 4 files changed, 292 insertions(+), 32 deletions(-) diff --git a/nodes.py b/nodes.py index 9a0e4cd..b3cb757 100644 --- a/nodes.py +++ b/nodes.py @@ -200,7 +200,7 @@ class DragosSceneCompiler: return { "required": {}, "optional": { - "input_1": (PROMPT_VAR_TYPE, {"forceInput": True}), + "input_1": ("PROMPT_VAR", {"forceInput": True}), }, "hidden": { "output_json_string": ("STRING", {"multiline": True}), @@ -214,28 +214,47 @@ class DragosSceneCompiler: @staticmethod def _unwrap_prompt_var(v): - """Recursively unwrap tuples from ComfyUI PROMPT_VAR_TYPE nodes.""" - depth = 0 while isinstance(v, tuple) and len(v) == 1: v = v[0] - depth += 1 return v + @staticmethod + def _compact_for_llm(text: str) -> str: + """ + Replace tabs and newlines with spaces and collapse multiple spaces. + This reduces token count and improves semantic locality. + """ + if not text: + return "" + + # Replace newline and tab with space + text = re.sub(r"[\n\t]+", " ", text) + + # Collapse multiple spaces into one + text = re.sub(r" {2,}", " ", text) + + return text.strip() + def compile_json(self, **kwargs): - # If hidden output exists, use it directly + hidden_json = kwargs.get("output_json_string") + if hidden_json: - return (hidden_json,) + compact = self._compact_for_llm(hidden_json) + return (compact,) - # Otherwise, build from inputs as before scene = {} + for key, v in kwargs.items(): unwrapped = self._unwrap_prompt_var(v) if isinstance(unwrapped, dict) and "name" in unwrapped and "value" in unwrapped: scene[unwrapped["name"]] = unwrapped["value"] json_out = json.dumps(scene, indent="\t", ensure_ascii=False) - return (json_out,) + + compact = self._compact_for_llm(json_out) + + return (compact,) class DragosStructuredBuilderNode: diff --git a/pyproject.toml b/pyproject.toml index 77fb182..c477bc5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "Dragos-SceneBuilder" description = "This node pack offers various ways to build json strings that is ment to be used with a LLM to generate Prompts. It also have a node that can load different prompts so that a LLM can use the json string to make the Image Prompt." -version = "1.1.1" +version = "1.1.2" license = { file = "LICENSE" } [project.urls] diff --git a/web/schema/character_female.json b/web/schema/character_female.json index ed0f978..74b62c4 100644 --- a/web/schema/character_female.json +++ b/web/schema/character_female.json @@ -18,6 +18,7 @@ "bottom-right" ], "proximity_to_camera": [ + "", "foreground", "midground", "background", @@ -26,6 +27,7 @@ "far" ], "orientation": [ + "", "facing camera", "facing left", "facing right", @@ -36,37 +38,174 @@ "three-quarter right" ], "relative_to": "" - }, + }, + "appearance": { + "body_form": [ + "", + "slim", + "athletic", + "toned", + "curvy", + "hourglass", + "pear-shaped", + "petite", + "tall", + "plump", + "voluptuous", + "other" + ], + "face_form": [ + "", + "oval", + "round", + "heart-shaped", + "square", + "diamond", + "long", + "angular", + "soft", + "other" + ], + "skin": { + "tone": [ + "", + "pale", + "fair", + "tan", + "olive", + "brown", + "dark", + "ebony", + "other" + ], + "details": [ + "", + "freckles", + "moles", + "birthmarks", + "scars", + "tattoos", + "piercings", + "clear", + "other" + ] + }, + "eyes": { + "left": { + "color": [ + "", + "blue", + "brown", + "green", + "hazel", + "gray", + "amber", + "other" + ], + "shape": [ + "", + "almond", + "round", + "hooded", + "upturned", + "downturned", + "wide-set", + "other" + ] + }, + "right": { + "color": [ + "", + "blue", + "brown", + "green", + "hazel", + "gray", + "amber", + "other" + ], + "shape": [ + "", + "almond", + "round", + "hooded", + "upturned", + "downturned", + "wide-set", + "other" + ] + } + }, + "head_hair": { + "presence": ["Yes", "No"], + "style": [ + "", + "straight", + "wavy", + "curly", + "coily", + "pixie cut", + "bob", + "shoulder-length", + "long", + "ponytail", + "braids", + "bun", + "other" + ], + "color": [ + "", + "blonde", + "brunette", + "black", + "red", + "platinum", + "auburn", + "gray", + "dyed-unnatural", + "other" + ], + "length": [ + "", + "shaved", + "short", + "medium", + "long", + "very long", + "other" + ] + } + }, "anatomy": { "mons_pubis": { - "size":["small","medium","large"], - "shape":["flat","rounded","prominent"], + "size":["","small","medium","large"], + "shape":["","flat","rounded","prominent"], "hair": { - "presence":["yes","no"], + "presence":["","yes","no"], "density":["","sparse","moderate","dense"], "distribution":["","none","central","full","wide"], "color":["","blonde","brown","black","red","gray","other"] } }, "labia_majora": { - "size":["small","medium","large"], - "thickness":["thin","average","thick"], - "symmetry":["symmetric","slightly asymmetric","asymmetric"], - "shape":["slit","rounded","full"], - "fullness":["flat","moderate","full"], - "texture":["smooth","soft","wrinkled"] + "size":["","small","medium","large"], + "thickness":["","thin","average","thick"], + "symmetry":["","symmetric","slightly asymmetric","asymmetric"], + "shape":["","slit","rounded","full"], + "fullness":["","flat","moderate","full"], + "texture":["","smooth","soft","wrinkled"] }, "labia_minora": { - "size":["small","medium","large"], - "length":["short","average","long"], - "protrusion":["none","slight","moderate","prominent"], - "symmetry":["symmetric","slightly asymmetric","asymmetric"], - "shape":["slit","rounded","elongated"], - "visibility":["hidden","partially visible","visible"], - "texture":["smooth","soft","wrinkled"] + "visibility":["","hidden","partially visible","visible"], + "size":["","small","medium","large"], + "length":["","short","average","long"], + "protrusion":["","none","slight","moderate","prominent"], + "symmetry":["","symmetric","slightly asymmetric","asymmetric"], + "shape":["","slit","rounded","elongated"], + "texture":["","smooth","soft","wrinkled"] }, "clitoris": { - "visibility":["hidden","partially visible","visible"], + "visibility":["","hidden","partially visible","visible"], "size":["","small","medium","large"], "hood": { "coverage":["","fully covered","partially covered","exposed"], diff --git a/web/schema/character_male.json b/web/schema/character_male.json index 259d2a8..469d4d7 100644 --- a/web/schema/character_male.json +++ b/web/schema/character_male.json @@ -18,6 +18,7 @@ "bottom-right" ], "proximity_to_camera": [ + "", "foreground", "midground", "background", @@ -26,6 +27,7 @@ "far" ], "orientation": [ + "", "facing camera", "facing left", "facing right", @@ -36,17 +38,117 @@ "three-quarter right" ], "relative_to": "" - }, + }, + "appearance": { + "body_build": [ + "", + "slim", + "average", + "athletic", + "muscular", + "bodybuilder", + "stocky", + "lean", + "lanky", + "other" + ], + "face_form": [ + "", + "square", + "oval", + "chiseled", + "round", + "heart-shaped", + "rectangular", + "angular", + "other" + ], + "skin": { + "tone": [ + "", + "pale", + "fair", + "tan", + "olive", + "brown", + "dark", + "ebony", + "other" + ], + "details": [ + "", + "freckles", + "stubble", + "scars", + "tattoos", + "piercings", + "chest hair", + "back hair", + "other" + ] + }, + "head_hair": { + "presence": ["","Yes", "No"], + "style": [ + "", + "short-cropped", + "buzz cut", + "faded", + "slicked-back", + "undercut", + "messy", + "long", + "man-bun", + "bald", + "other" + ], + "color": [ + "", + "blonde", + "brown", + "black", + "red", + "gray", + "salt and pepper", + "other" + ] + }, + "facial_hair": { + "presence": ["","Yes", "No"], + "style": [ + "", + "clean-shaven", + "stubble", + "goatee", + "full beard", + "mustache", + "mutton chops", + "van dyke", + "other" + ] + } + }, "anatomy": { - "gentile": { + "genitals": { "size": [ "small", "average", "large" ], - "body_hair":["none","sparse","moderate","dense"] + "circumcised": [ + "", + "yes", + "no" + ], + "pubic_hair": { + "presence": ["","yes", "no"], + "density": ["", "sparse", "moderate", "dense"], + "style": ["", "natural", "trimmed", "shaved", "other"] + } }, - - "musculature":["slim","average","athletic","muscular"] + "physique_details": { + "definition": ["", "soft", "toned", "ripped", "bulky"], + "shoulder_width": ["", "narrow", "average", "broad"] + } } } \ No newline at end of file