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

assert.js 993 B

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
  1. module.exports = (output, context) => {
  2. console.log('Prompt:', context.prompt);
  3. console.log('Vars', context.vars.topic);
  4. // You can return a bool...
  5. // return output.toLowerCase().includes('bananas');
  6. // A score (where 0 = Fail)...
  7. // return 0.5;
  8. // Or an entire grading result, which can be simple...
  9. let result = {
  10. pass: output.toLowerCase().includes('bananas'),
  11. score: 0.5,
  12. reason: 'Contains banana',
  13. };
  14. // Or include nested assertions...
  15. result = {
  16. pass: true,
  17. score: 0.75,
  18. reason: 'Looks good to me',
  19. componentResults: [
  20. {
  21. pass: output.toLowerCase().includes('bananas'),
  22. score: 0.5,
  23. reason: 'Contains banana',
  24. namedScores: {
  25. 'Uses banana': 1.0,
  26. },
  27. },
  28. {
  29. pass: output.toLowerCase().includes('yellow'),
  30. score: 0.5,
  31. reason: 'Contains yellow',
  32. namedScores: {
  33. Yellowish: 0.66,
  34. },
  35. },
  36. ],
  37. };
  38. return result;
  39. };
Tip!

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

Comments

Loading...