https://promptfoo.dev/ logo
Tips for formatting text for YAML tests?
# ❓|questions
w
Hey everyone, sometimes I have long blocks of text with lots of new lines, markdown formatting, and minified/escaped JSON that I need top pass into tests as variables. The problem is they look really awful in a YAML file and I often end up with indentation issues when I paste them in. I tried using a CSV to handle tests and that worked beautifully, but I prefer to write my assertions in yaml. Just looking to see if anyone has tips to easily move text into a YAML file without running into formatting issues. Honestly I might just paste things to a LLM and ask it to format for me 😂
i
For complicated blocks, you might prefer to include them as txt files:
Copy code
yaml
vars:
  myVar: file://path/to/myVar.txt
w
yeah I tried that but it got cumbersome quickly, i have about ~20 tests like this, so would be hard to deal with when updating / moving tests around
thank you though! I think I might just have to deal with a bit of pain here.. I think the best solutions are just to try to prettify/fix my YAML with an LLM, or to use the csvs
i
Hmm, I think i should try to solve the yaml indentation issue
The indentation is getting screwed up when it’s replaced in the prompt?
w
well actually I just figured out its a lot easier if I use a pipe for text
2 Views