Are variables nested in wildcards possible? #613
-
Hello and thank you for a very useful extension. I've recently stumbled about a usecase which I'm unable to solve on my own. Here's a simplified example using the following wildcards file (*.yaml): cars:
ford:
name:
- Ford
types:
- muscle car
- compact car
- roadster
colors:
- white
- black
- brown
- red
porsche:
name:
- Porsche
types:
- sports car
colors:
- red
- black
john_deere:
name:
- John Deere
types:
- tractor
colors:
- green
- yellow Now I would like to generate dynamic images of cars with consistent and matching colors, e.g.:
I hoped that something along the following lines would work:
But this only results in an exception. I've made similar attempts but wasn't successful. Is something like this even supported? Or can it be achieved by using a workaround/different structuring? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
That's a nice idea - unfortunately the standard syntax doesn't support it because the string is only parsed once. The
|
Beta Was this translation helpful? Give feedback.
That's a nice idea - unfortunately the standard syntax doesn't support it because the string is only parsed once. The
${car}
token becomes a literal and the prompt generator sees__cars/${car}/types__
without the variable being resolved. You can use jinja2 templates to make it work. It's a little clunky but gets the job done: