Skip to content

Commit

Permalink
fix: ⚡️ hack to handle prompt validation
Browse files Browse the repository at this point in the history
I can finally reproduce :)
Fixes #85
  • Loading branch information
melMass committed Oct 4, 2023
1 parent 87b245c commit d49b257
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
25 changes: 15 additions & 10 deletions nodes/debug.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from ..utils import tensor2pil
from ..log import log
import io, base64
import torch
import folder_paths
from typing import Optional
import base64
import io
from pathlib import Path
from typing import Optional

import folder_paths
import torch

from ..log import log
from ..utils import tensor2pil


# region processors
Expand Down Expand Up @@ -71,18 +74,18 @@ class Debug:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {"anything_1": ("*")},
"required": {"output_to_console": ("BOOLEAN", {"default": False})},
}

RETURN_TYPES = ("STRING",)
RETURN_TYPES = ()
FUNCTION = "do_debug"
CATEGORY = "mtb/debug"
OUTPUT_NODE = True

def do_debug(self, **kwargs):
def do_debug(self, output_to_console, **kwargs):
output = {
"ui": {"b64_images": [], "text": []},
"result": ("A"),
# "result": ("A"),
}

processors = {
Expand All @@ -91,6 +94,8 @@ def do_debug(self, **kwargs):
dict: process_dict,
bool: process_bool,
}
if output_to_console:
print("bouh!")

for anything in kwargs.values():
processor = processors.get(type(anything), process_text)
Expand Down
9 changes: 9 additions & 0 deletions web/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ app.registerExtension({
name: 'mtb.Debug',
async beforeRegisterNodeDef(nodeType, nodeData, app) {
if (nodeData.name === 'Debug (mtb)') {
const onNodeCreated = nodeType.prototype.onNodeCreated
nodeType.prototype.onNodeCreated = function () {
const r = onNodeCreated
? onNodeCreated.apply(this, arguments)
: undefined
this.addInput(`anything_1`, '*')
return r
}

const onConnectionsChange = nodeType.prototype.onConnectionsChange
nodeType.prototype.onConnectionsChange = function (
type,
Expand Down

0 comments on commit d49b257

Please sign in to comment.