https://promptfoo.dev/ logo
json in input variables
# ❓|questions
l
Hi and thanks for a great tool! I need to pass some json into my prompt. I tried using this: tests: - vars: question: [{"questionId":903,"questionText"},....] but it appears in the prompt as [object Object],[object Object],[object Object],[object Object] Tried with JSON.stringify( [...]) but with no luck. Any ideas what I could try? And a bonus question, the best would be if I could referer to a json file, but it seems like I could only refere to .csv files in the -test section?
d
I don't know if this helps you or not, but you can pass json directly into the prompt key description: My Test Config prompts: 'app/prompts/my_jsonfile.json' providers: - id: my_provider This works great for me.
i
@larserikfinholt if I understand correctly, you want to include the JSON literal in the YAML config? In that case, I would just wrap it in single quotes. daver's suggestion might also work here
l
Ahhh. Of course, that simple Thanks