From b0e0aacad1b2e20dea7a89b8df69a7c0bd654c5e Mon Sep 17 00:00:00 2001 From: GeorgLegato Date: Mon, 1 May 2023 22:17:41 +0200 Subject: [PATCH] fix and clean json handling, commonX considered, headers not 0,1 anymore --- iz_helpers/prompt_util.py | 16 ++++++++++++---- iz_helpers/static_variables.py | 2 ++ iz_helpers/ui.py | 4 ++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/iz_helpers/prompt_util.py b/iz_helpers/prompt_util.py index 415a629..4ef5433 100644 --- a/iz_helpers/prompt_util.py +++ b/iz_helpers/prompt_util.py @@ -4,7 +4,8 @@ from jsonschema import validate from .static_variables import ( empty_prompt, invalid_prompt, - jsonprompt_schemafile + jsonprompt_schemafile, + promptTableHeaders ) def completeOptionals(j): @@ -13,15 +14,22 @@ def completeOptionals(j): if "prompts" in j: if "headers" in j["prompts"]: del j["prompts"]["headers"] - + j["prompts"]["headers"]=promptTableHeaders + if "negPrompt" not in j: j["negPrompt"]="" if "prePrompt" not in j: - j["prePrompt"]="" + if "commonPromptPrefix" in j: + j["prePrompt"]=j["commonPromptPrefix"] + else: + j["prePrompt"]="" if "postPrompt" not in j: - j["postPrompt"]="" + if "commonPromptSuffix" in j: + j["postPrompt"]=j["commonPromptSuffix"] + else: + j["postPrompt"]="" return j diff --git a/iz_helpers/static_variables.py b/iz_helpers/static_variables.py index c648b0e..71d0d94 100644 --- a/iz_helpers/static_variables.py +++ b/iz_helpers/static_variables.py @@ -2,6 +2,8 @@ import os from modules import scripts import modules.sd_samplers +promptTableHeaders=["Start at second [0,1,...]", "prompt", "image location", "blend mask", "is keyframe"], + default_prompt = """ { "prePrompt":" ", diff --git a/iz_helpers/ui.py b/iz_helpers/ui.py index c3967bb..3a1bcc5 100644 --- a/iz_helpers/ui.py +++ b/iz_helpers/ui.py @@ -11,6 +11,8 @@ from .static_variables import ( available_samplers, ) from .helpers import validatePromptJson_throws, putPrompts, clearPrompts +from .prompt_util import readJsonPrompt +from .static_variables import promptTableHeaders def on_ui_tabs(): @@ -58,6 +60,8 @@ def on_ui_tabs(): type="array", headers=["outpaint step", "prompt", "image location", "blend mask", "is keyframe"], datatype=["number", "str", "str", "str", "bool"], + headers= promptTableHeaders, + datatype=["number", "str", "str", "str", "bool"], row_count=1, col_count=(5, "fixed"), value=jpr["prompts"],