https://promptfoo.dev/ logo
Using functions in the prompts.txt file
# ❓|questions
r
Is it possible to use Nunjucks style functions (in addition to the variables) in the prompts.txt file? What I want to do is have a custom function that will determine the number of lines in a string variable that is defined in promptfooconfig.yaml. I see here (https://www.promptfoo.dev/docs/configuration/parameters) that there is also the option of using a prompts.js with javascript functions, so maybe that's the recommended way to do this. Thanks!
i
Custom nunjucks functions aren't supported right now - but a javascript prompt (or custom provider) is the way to go if you want to customize the prompt
made the change for nunjucks filters, it'll be supported in the next release 🙂 https://github.com/promptfoo/promptfoo/pull/243
r
😀 That's awesome! Thanks, @ian