fix and clean json handling, commonX considered, headers not 0,1 anymore

pull/78/head
GeorgLegato 2023-05-01 22:17:41 +02:00
parent 90a5aab9dd
commit 38355dfab8
3 changed files with 16 additions and 5 deletions

View File

@ -4,7 +4,8 @@ from jsonschema import validate
from .static_variables import ( from .static_variables import (
empty_prompt, empty_prompt,
invalid_prompt, invalid_prompt,
jsonprompt_schemafile jsonprompt_schemafile,
promptTableHeaders
) )
def completeOptionals(j): def completeOptionals(j):
@ -13,14 +14,21 @@ def completeOptionals(j):
if "prompts" in j: if "prompts" in j:
if "headers" in j["prompts"]: if "headers" in j["prompts"]:
del j["prompts"]["headers"] del j["prompts"]["headers"]
j["prompts"]["headers"]=promptTableHeaders
if "negPrompt" not in j: if "negPrompt" not in j:
j["negPrompt"]="" j["negPrompt"]=""
if "prePrompt" not in j: if "prePrompt" not in j:
if "commonPromptPrefix" in j:
j["prePrompt"]=j["commonPromptPrefix"]
else:
j["prePrompt"]="" j["prePrompt"]=""
if "postPrompt" not in j: if "postPrompt" not in j:
if "commonPromptSuffix" in j:
j["postPrompt"]=j["commonPromptSuffix"]
else:
j["postPrompt"]="" j["postPrompt"]=""
return j return j

View File

@ -2,6 +2,8 @@ import os
from modules import scripts from modules import scripts
import modules.sd_samplers import modules.sd_samplers
promptTableHeaders=["Start at second [0,1,...]","Prompt"]
default_prompt = """ default_prompt = """
{ {
"prePrompt": "Huge spectacular Waterfall in ", "prePrompt": "Huge spectacular Waterfall in ",

View File

@ -9,6 +9,7 @@ from .static_variables import (
) )
from .helpers import putPrompts, clearPrompts from .helpers import putPrompts, clearPrompts
from .prompt_util import readJsonPrompt from .prompt_util import readJsonPrompt
from .static_variables import promptTableHeaders
def on_ui_tabs(): def on_ui_tabs():
@ -55,7 +56,7 @@ def on_ui_tabs():
main_prompts = gr.Dataframe( main_prompts = gr.Dataframe(
type="array", type="array",
headers=["Start at second [0,1,...]", "Prompt"], headers= promptTableHeaders,
datatype=["number", "str"], datatype=["number", "str"],
row_count=1, row_count=1,
col_count=(2, "fixed"), col_count=(2, "fixed"),