https://promptfoo.dev/ logo
How do I define system prompts?
# questions
b
I am trying to write some test cases against my user prompt. There are two system prompts that go before it, so I'm trying to define it like this:
Copy code
prompts:
  - role: system
    content: file://../../system-1.md
  - role: system
    content: file://../../system-2.md
  - role: user
    content: file://../../user.md

tests:
  - file://./test_*.yaml
But that's not working for me. > Invalid configuration file /Users/me/code/evaluations/test1/promptfooconfig.yaml: > Validation error: Expected string, received array at "prompts", or Expected string, received object at "prompts[0]", or Required at "prompts[0].id", or Required at "prompts[0].raw"; Expected string, received object at "prompts[1]", or Required at "prompts[1].id", or Required at "prompts[1].raw", or Expected object, received array at "prompts" > Invalid configuration file /Users/me/code/evaluations/test1/promptfooconfig.yaml: > Validation error: Expected string, received array at "prompts", or Expected string, received object at "prompts[0]", or Required at "prompts[0].id", or Required at "prompts[0].raw"; Expected string, received object at "prompts[1]", or Required at "prompts[1].id", or Required at "prompts[1].raw", or Expected object, received array at "prompts" > Failed to validate configuration: Invalid prompt object: {"role":"system","label":"system","content":"file://../../system.md"} What am I doing wrong? How do I define my prompt chain with two system prompts and one user prompt from files?
t
@shuo0446
i
I was going to suggest putting this into a
conversation.yaml
, but right now
file://
references are not recursively resolved. My best advice now is to combine the prompts into a single
conversation.yaml
inline, unless Shuo has a better idea. An alternative would be to create a python or javascript [dynamic prompt](https://www.promptfoo.dev/docs/configuration/prompts/#dynamic-prompts-functions) that builds the prompt however you'd like
b
Ok, thanks. I'll probably go with the dynamic prompt optoin so that I can just reference the files directly. Copying them into a conversation.yaml defeats the purpose of having automated tests.
i
I'll have a fix out for recursive file loading in the next release
b
FYI: it was very easy for me to create a dynamic prompt for this. I had considered it but thought there was a more declarative way. I'll switch to the declarative way when this feature is out. Thanks for that! In the meantime, I'm unblocked. THANK YOU for your response. This is a VERY cool tool.
I am the Director of a technical learning platform called [CodeSignal Learn](https://codesignal.com/learn). We're going to build a course on Prompt Evaluations and use Promptfoo as the tool to teach the concept. If there's any particular thing you think we should be highlighting, LMK. Otherwise, I'll post it here in a month or so once it's done.
2 Views