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

max-score.test.ts 1.5 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
  1. import type { Assertion } from '../../src/types';
  2. import { runAssertions } from '../../src/assertions';
  3. describe('max-score assertion integration', () => {
  4. it('should exclude max-score from regular assertion processing', async () => {
  5. const test = {
  6. assert: [
  7. { type: 'contains', value: 'test' } as Assertion,
  8. { type: 'max-score' } as Assertion,
  9. ],
  10. };
  11. const result = await runAssertions({
  12. prompt: 'test prompt',
  13. providerResponse: { output: 'test output' },
  14. test,
  15. });
  16. // Only the contains assertion should be processed
  17. expect(result.componentResults).toHaveLength(1);
  18. expect(result.componentResults![0].assertion?.type).toBe('contains');
  19. });
  20. it('should filter out select-best and max-score from processing', async () => {
  21. const test = {
  22. assert: [
  23. { type: 'contains', value: 'test' } as Assertion,
  24. { type: 'select-best', value: 'best criteria' } as Assertion,
  25. { type: 'max-score' } as Assertion,
  26. { type: 'equals', value: 'test output' } as Assertion,
  27. ],
  28. };
  29. const result = await runAssertions({
  30. prompt: 'test prompt',
  31. providerResponse: { output: 'test output' },
  32. test,
  33. });
  34. // Only contains and equals should be processed
  35. expect(result.componentResults).toHaveLength(2);
  36. const processedTypes = result.componentResults!.map((cr) => cr.assertion?.type);
  37. expect(processedTypes).toEqual(['contains', 'equals']);
  38. });
  39. });
Tip!

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

Comments

Loading...