KIE Parse Prompt Grid JSON (1..9):
The KIEParsePromptGridJSON node is designed to efficiently parse JSON data generated by language models (LLMs) to extract up to nine distinct prompts. This node is particularly useful for AI artists and developers who work with LLMs and need to handle multiple prompts in a structured manner. By converting raw JSON input into separate prompt strings, this node simplifies the process of managing and utilizing multiple prompts for creative or automation tasks. It ensures that even if the JSON data is not perfectly structured, the node can attempt to clean and extract meaningful prompts, providing a robust solution for handling JSON data in creative workflows.
KIE Parse Prompt Grid JSON (1..9) Input Parameters:
json_text
The json_text parameter is a required input that takes a raw JSON string from a language model, which can be either a list or an object. This parameter is crucial as it serves as the primary source of data from which the node will attempt to extract prompts. The JSON text should ideally contain structured data that the node can parse into individual prompts.
default_prompt
The default_prompt is an optional string parameter that acts as a fallback prompt in case the parsing process does not yield any valid prompts. This ensures that there is always a prompt available, even if the JSON input is empty or improperly formatted. The default value is an empty string, and it can be customized to suit specific needs.
max_items
The max_items parameter is an optional integer that limits the number of prompts to be extracted, with a range from 1 to 9. This parameter allows you to control the maximum number of prompts you want to handle, ensuring that the output remains manageable and within the desired scope. The default value is 9.
strict
The strict parameter is an optional boolean that determines whether the node should raise errors when parsing fails or yields no prompts. When set to true, the node will enforce strict parsing rules and report errors if the JSON input is not properly structured. The default value is false, allowing for more lenient parsing.
debug
The debug parameter is an optional boolean that, when enabled, provides additional debugging information during the parsing process. This can be useful for troubleshooting and understanding how the node processes the JSON input. The default value is false.
KIE Parse Prompt Grid JSON (1..9) Output Parameters:
p1..p9
These are the output parameters representing up to nine individual prompt strings extracted from the JSON input. Each parameter corresponds to a separate prompt, and if fewer than nine prompts are extracted, the remaining outputs will be empty strings. These outputs allow you to easily access and utilize each prompt separately.
count
The count output is an integer representing the number of prompts successfully parsed from the JSON input. This provides a quick overview of how many prompts were extracted, which can be useful for further processing or validation.
prompts_list
The prompts_list output is a raw list of all the prompts extracted from the JSON input. This list can be used for future automation tasks or for further manipulation within your workflow, providing a comprehensive view of all the parsed prompts.
KIE Parse Prompt Grid JSON (1..9) Usage Tips:
- Ensure that the
json_textinput is as clean and structured as possible to facilitate accurate parsing of prompts. - Use the
default_promptparameter to provide a fallback option, ensuring that your workflow continues smoothly even if the JSON input is not ideal. - Adjust the
max_itemsparameter according to your specific needs to control the number of prompts you want to handle.
KIE Parse Prompt Grid JSON (1..9) Common Errors and Solutions:
Failed to parse JSON from json_text. Ensure the input contains a JSON object or array.
- Explanation: This error occurs when the input JSON text is not properly formatted or does not contain a valid JSON object or array.
- Solution: Verify that the
json_textinput is correctly formatted as a JSON object or array. Use a JSON validator to check for syntax errors.
No prompts found in json_text and no default_prompt provided.
- Explanation: This error indicates that the parsing process did not yield any prompts, and no default prompt was specified.
- Solution: Ensure that the
json_textcontains valid prompt data. If necessary, provide adefault_promptto serve as a fallback option.
