Skip to content

Commit

Permalink
add TESTNODE_TOKEN
Browse files Browse the repository at this point in the history
显示text-to-token的过程,方便对prompt进行精修
  • Loading branch information
shadowcz007 committed Feb 12, 2024
1 parent 7c655e3 commit f0db08a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
3 changes: 2 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ async def nodes_map_hander(request):

from .nodes.ChatGPT import ChatGPTNode,ShowTextForGPT,CharacterInText
from .nodes.Audio import GamePal,SpeechRecognition,SpeechSynthesis
from .nodes.Utils import CreateLoraNames,CreateSampler_names,CreateCkptNames,CreateSeedNode,TESTNODE_,AppInfo,IntNumber,FloatSlider,TextInput,ColorInput,FontInput,TextToNumber,DynamicDelayProcessor,LimitNumber,SwitchByIndex,MultiplicationNode
from .nodes.Utils import CreateLoraNames,CreateSampler_names,CreateCkptNames,CreateSeedNode,TESTNODE_,TESTNODE_TOKEN,AppInfo,IntNumber,FloatSlider,TextInput,ColorInput,FontInput,TextToNumber,DynamicDelayProcessor,LimitNumber,SwitchByIndex,MultiplicationNode
from .nodes.Mask import OutlineMask,FeatheredMask


Expand All @@ -546,6 +546,7 @@ async def nodes_map_hander(request):
NODE_CLASS_MAPPINGS = {
"AppInfo":AppInfo,
"TESTNODE_":TESTNODE_,
"TESTNODE_TOKEN":TESTNODE_TOKEN,
"RandomPrompt":RandomPrompt,
"EmbeddingPrompt":EmbeddingPrompt,
"PromptSlide":PromptSlide,
Expand Down
40 changes: 37 additions & 3 deletions nodes/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class TextInput:
@classmethod
def INPUT_TYPES(s):
return {"required": {
"text": ("STRING",{"multiline": True,"default": ""}),
"text": ("STRING",{"multiline": True,"default": ""})
},
}

Expand Down Expand Up @@ -695,7 +695,9 @@ def count_types(lst):
class TESTNODE_:
@classmethod
def INPUT_TYPES(s):
return {"required": { "ANY":(any_type,), },
return {"required": {
"ANY":(any_type,),
},
}

RETURN_TYPES = (any_type,)
Expand All @@ -715,10 +717,42 @@ def run(self,ANY):

# 调用count_types方法进行统计
result = list_stats.count_types(ANY)



return {"ui": {"data": result,"type":[str(type(ANY[0]))]}, "result": (ANY,)}


class TESTNODE_TOKEN:
@classmethod
def INPUT_TYPES(s):
return {"required": {
"text":("STRING", {"forceInput": True,}),
"clip": ("CLIP", )
},
}

RETURN_TYPES = ("STRING",)

FUNCTION = "run"

CATEGORY = "♾️Mixlab/__TEST"

OUTPUT_NODE = True
INPUT_IS_LIST = False
OUTPUT_IS_LIST = (False,)

def run(self,text,clip=None):
# print(text)

tokens = clip.tokenize(text)

tokens=[v for v in tokens.values()][0][0]

tokens=json.dumps(tokens)

return (tokens,)



class CreateSeedNode:
def __init__(self):
Expand Down
3 changes: 2 additions & 1 deletion web/javascript/ui_mixlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,8 @@ app.registerExtension({

widget.element.addEventListener('mouseover', e => {
// console.log(node.widgets_values[index])
widget.element.setAttribute('title', node.widgets_values[index])
if (node.widgets_values[index])
widget.element.setAttribute('title', node.widgets_values[index])
})
}
}
Expand Down

0 comments on commit f0db08a

Please sign in to comment.