JSON to AI Prompt
AI-generatedOverview
This node transforms JSON data into a formatted text prompt suitable for AI models. It allows users to define a prompt template with placeholders for JSON data, which can be formatted in various ways such as pretty JSON, compact JSON, key-value pairs, markdown tables, or plain text descriptions. The node supports filtering fields to include or exclude, limiting data length, and optionally adding an estimated token count. It is useful for preparing structured data to be analyzed or processed by AI systems, for example, generating insights or summaries from JSON data.
Use Case Examples
- Generating a prompt for an AI assistant to analyze user data by formatting the data as pretty JSON and embedding it in a custom prompt template.
- Creating a markdown table from an array of JSON objects to include in a prompt for an AI model to interpret tabular data.
- Filtering sensitive fields like passwords or tokens from JSON data before generating a prompt to ensure data privacy.
Properties
| Name | Meaning |
|---|---|
| Prompt Template | The template for the prompt text, where {{data}} inserts the formatted JSON data and {{field.name}} inserts specific fields from the JSON. |
| Data Format | Specifies how the JSON data is formatted in the prompt, options include pretty JSON, compact JSON, key-value pairs, markdown table, or plain text. |
| Output Field Name | The name of the field in the output JSON where the generated prompt text will be stored. |
| Options | Additional options to customize the data formatting and output, including fields to include or exclude, maximum data length, whether to add an estimated token count, and whether to keep the original JSON data in the output. |
Output
JSON
- The generated prompt text based on the template and formatted JSON data.
_promptInfodataFormat- The format used for the JSON data in the prompt.originalLength- The length of the original JSON data string.promptLength- The length of the generated prompt string.timestamp- Timestamp when the prompt was generated.estimatedTokens- (Optional) Estimated token count of the prompt text, if enabled.
Troubleshooting
- Ensure the prompt template includes the {{data}} placeholder or specific field placeholders like {{field.name}} to avoid empty prompts.
- If the output prompt is unexpectedly truncated, check the Max Data Length option and increase it if necessary.
- When using the markdown table format, ensure the input JSON is an array of objects; otherwise, the table may not render correctly.
- If fields are missing in the output, verify the Include Only Fields and Exclude Fields options to ensure the correct fields are selected.