Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

promptfooconfig.yaml 1.4 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  1. # yaml-language-server: $schema=https://promptfoo.dev/config-schema.json
  2. description: 'JSON object evals'
  3. prompts:
  4. - 'Output a JSON object that contains the keys `color` and `countries`, describing the following object: {{item}}'
  5. providers:
  6. - openai:chat:gpt-4o-mini
  7. tests:
  8. - vars:
  9. item: Banana
  10. assert:
  11. - type: is-json
  12. - type: javascript
  13. # Parse the JSON and test the contents
  14. value: JSON.parse(output).color === 'yellow' && JSON.parse(output).countries.includes('Ecuador')
  15. - vars:
  16. item: Passion fruit
  17. options:
  18. # Parse the JSON before all assertions
  19. transform: JSON.parse(output)
  20. assert:
  21. - type: is-json
  22. # Optional JSON schema
  23. value:
  24. required:
  25. - 'color'
  26. - 'countries'
  27. type: object
  28. properties:
  29. color:
  30. type: string
  31. countries:
  32. type: array
  33. items:
  34. type: string
  35. - type: javascript
  36. # JSON.parse is no longer necessary here
  37. value: output.color === 'purple' && output.countries.includes('Brazil')
  38. - type: contains-any
  39. transform: output.countries
  40. value:
  41. - Guatemala
  42. - Costa Rica
  43. - India
  44. - Indonesia
  45. # Uncomment to parse JSON outputs for ALL tests
  46. # defaultTest:
  47. # options:
  48. # transform: JSON.parse(output)
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...