pups_1994
03/30/2024, 6:30 AMprompts section for the promptfooconfig.yaml ??
Option 1 - Should i make a json prompt file like https://github.com/promptfoo/promptfoo/blob/main/examples/multiple-turn-conversation/prompt.json ?
Iif yes then how to supplement other 10 vars within this prompt AND how to provide the big system prompt with proper escaping in nunjunks?
Option 2 - Should i make js prompt file? then how will i use nunjunks for the _conversation loop which is needed for multi turn convo?pups_1994
03/30/2024, 6:36 AMian
03/30/2024, 5:26 PMpups_1994
03/31/2024, 7:34 PMA multiline system prompt will be automatically escaped in nunjucks with a json file, coz in my case the editor keep throwing error if i pase a multi line prompt in the json file and that too a prompt which has multiple double qoutes in the prompt string itselfian
03/31/2024, 9:36 PM{% for message in previous_messages %} cause the file to not be interpreted as JSON, which in turn prevents the auto-escaping behavior.
The workaround is to use the built-in nunjucks dumps filter, which converts the variable to JSON.
Here's an example:
js
[
{
"role": "system",
"content": {{ system_message | dump }}
},
{% for message in previous_messages %}
{% for role, content in message %}
{
"role": {{ role | dump }},
"content": {{ content | dump }}
},
{% endfor %}
{% endfor %}
{
"role": "user",
"content": {{ question | dump }}
}
]
In this example, system_message is imported as a multiline text file and is properly quoted/escaped.pups_1994
04/02/2024, 1:14 PM