Generate image block is not able to pick up variables with JSON

I’m not sure if this link works:
https://app.mindstudio.ai/agents/kids-personalized-story-generator-c73b31c1/run/c6aea471-9f84-462f-a224-d39dae4cefa3?draftVersionId=8bd76596-aeb5-43cf-a221-66e35c076819

But the “Generate Image” block is not able to resolve variables which have json, mostly when I try to read from an array, this is my prompt

Generate image for a personalized kid story. 

Details about the story

Title: {{story_text.title}}

Summary: {{story_text.summary}}

Generate image for this scene

1. Scene Description: {{story_text.scenes[0].description}}

2. Scene Setting: {{story_text.scenes[0].setting}}

3. Use this prompt apart from other details in the message: {{story_text.scenes[0].image_prompt}}

Few questions:

  1. When I just give title and summary, it works fine. Am I parsing the array scenes correctly?

  2. There are some “referenced but does not exist” warnings, but those are only for a subsequent block which displays content correctly (including array). If I have issue with one variable, will it not resolve any variable in a prompt?

Thanks

This is the json stored in the variable:

{"title":"Daniel Tiger Helps Aadit Learn About Being a Big Brother","summary":"A heartwarming story about Daniel Tiger helping Aadit understand and navigate the challenges and joys of becoming a big brother, while sharing special moments with his parents.","scenes":[{"characters":["Daniel Tiger","Aadit","Mom Tiger","Baby Margaret"],"setting":"Daniel Tiger's living room","description":"Daniel notices Aadit feeling unsure about his new baby sister and shares his own experience of being a big brother, teaching Aadit how to gently help with the baby and still feel special.","image_prompt":"Daniel Tiger sitting next to Aadit, showing him how to softly play with a baby, both looking happy and engaged"},{"characters":["Daniel Tiger","Aadit","Dad Tiger"],"setting":"Neighborhood playground","description":"Daniel helps Aadit practice catching balls and riding his balance bike, showing him that learning new skills takes time and patience, just like being a big brother.","image_prompt":"Daniel Tiger demonstrating ball-catching techniques to Aadit, both smiling and enjoying outdoor play"},{"characters":["Daniel Tiger","Aadit","Mom Tiger","Baby Margaret"],"setting":"Daniel's family room","description":"Aadit learns to build a special Magna-Tiles tower next to his baby sister, feeling proud of his building skills and his role as a helpful big brother.","image_prompt":"Aadit carefully building a colorful Magna-Tiles structure near his baby sister, with Daniel Tiger watching and encouraging him"},{"characters":["Daniel Tiger","Aadit","Mom Tiger","Dad Tiger"],"setting":"Daniel Tiger's kitchen","description":"Daniel teaches Aadit a special song about being a big brother and helping parents, making Aadit feel important and loved.","image_prompt":"Daniel and Aadit singing together, with parents smiling in the background, showing a warm family moment"}]}

Can you post a screenshot of your debugger? You can see what has been filled in into each variable reference you’ve made. You can then isolate the variable reference that’s giving you some trouble. Thanks,

Yes, I have been using the debugger, and it doesn’t get resolved, still see curly braces.

This seems to be causing the problem

Scene Description: {{story_text.scenes[0].description}}

Hi @ag12,

Thanks for the screenshot!

Since you’re extracting specific items from the JSON array, it’s best to use the get helper so your variables look like this:

{{get story_text "$.scenes[0].description"}}

You can also find more details on the get helper in our documentation:

1 Like

Thanks a lot Alex. This worked :slight_smile:

2 Likes