From d778d0d85d98624338abe5c1b3185bc83aaf4698 Mon Sep 17 00:00:00 2001 From: Tasha Upchurch Date: Fri, 26 May 2023 10:51:32 -0400 Subject: [PATCH] more changes to streamline for our alternate use case --- __init__.py | 2 +- image.py | 13 ++++++++----- nlp.py | 26 ++++++++++++-------------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/__init__.py b/__init__.py index 042c4cf..0fbc5df 100644 --- a/__init__.py +++ b/__init__.py @@ -6,7 +6,7 @@ try: use_generic_nodes = False except: use_generic_nodes = True - print("Failed to import comfy.samplers, assuming no comfyui skipping SD related nodes") + print("ETK> Failed to import comfy.samplers, assuming no comfyui skipping SD related nodes") from custom_nodes.EternalKernelLiteGraphNodes.latent import LatentInterpolation from custom_nodes.EternalKernelLiteGraphNodes.image import PadToMatch diff --git a/image.py b/image.py index 7408c3d..73132ac 100644 --- a/image.py +++ b/image.py @@ -5,8 +5,7 @@ try: SaveImage from custom_nodes.ComfyUI_ADV_CLIP_emb.nodes import AdvancedCLIPTextEncode as CLIPTextEncodeAdvanced except ImportError as e: - print("comfy.samplers not found, skipping comfyui") - print(e) + print("ETK> comfy.samplers not found, skipping comfyui") SaveImage = None import torch @@ -263,11 +262,15 @@ class ExecWidget: # globals().update(new_locals) # locals().update(new_locals) # print(globals()) - out_str = new_locals.get("out_str", None) + out_string = new_locals.get("out_string", None) out_image = new_locals.get("out_image", None) out_float = new_locals.get("out_float", None) - return (out_str, out_image, out_float,) - + return (out_string, out_image, out_float,) + @classmethod + def IS_CHANGED(s, name): + m = hashlib.sha256() + m.update(name) + return m.digest().hex() class PromptTemplate: """replaces the text in the given text string with a given other text at some key positions""" diff --git a/nlp.py b/nlp.py index f3719cd..ec313f1 100644 --- a/nlp.py +++ b/nlp.py @@ -43,7 +43,6 @@ class SimpleTextWidget: return {"required": { "text": ("STRING", {"multiline": True}), - "Display": ("SERVER_STRING", {"multiline": True}), }, } @@ -52,7 +51,7 @@ class SimpleTextWidget: RETURN_TYPES = ("STRING",) FUNCTION = "handler" - def handler(self, text,Display): + def handler(self, text): ret = self.func(text) return (ret,) @@ -79,6 +78,16 @@ avoid numpy and PIL as much as possible class LLMCompletion(SimpleTextWidget): """uses the input text to call the specified LLM model and returns the output string""" + def __init__(self): + self.func = self.OAI_completion + super().__init__(self.func) + import uuid + self.SSID = str(uuid.uuid4()) + + from main import server_obj_holder + self.server_string = server_obj_holder[0]["server_strings"] + self.server_string[self.SSID] = "empty" + def OAI_completion(self, text): out_message = [{"role": "user", "content": text}] @@ -87,19 +96,8 @@ class LLMCompletion(SimpleTextWidget): messages=out_message ) gpt_message = response["choices"][0]["message"]["content"].strip() - self.server_strings[self.SSID] = gpt_message + self.server_string[self.SSID] = gpt_message return gpt_message - def __init__(self): - self.func = self.OAI_completion - super().__init__(self.func) - import uuid - self.SSID = str(uuid.uuid4()) - from main import server_obj_holder - self.server_strings = server_obj_holder[0].server_strings - self.server_strings["self.SSID"] = "empty" - - - LLMCompletion.register("LLM_Completion")