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

index.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 { GradingConfig } from '../../dist/src/types';
  2. import { installJestMatchers } from './matchers';
  3. installJestMatchers();
  4. describe('toMatchSemanticSimilarity', () => {
  5. it('should pass when strings are semantically similar', async () => {
  6. await expect('The quick brown fox').toMatchSemanticSimilarity('A fast brown fox');
  7. });
  8. it('should fail when strings are not semantically similar', async () => {
  9. await expect('The quick brown fox').not.toMatchSemanticSimilarity('The weather is nice today');
  10. });
  11. it('should pass when strings are semantically similar with custom threshold', async () => {
  12. await expect('The quick brown fox').toMatchSemanticSimilarity('A fast brown fox', 0.7);
  13. });
  14. it('should fail when strings are not semantically similar with custom threshold', async () => {
  15. await expect('The quick brown fox').not.toMatchSemanticSimilarity(
  16. 'The weather is nice today',
  17. 0.9,
  18. );
  19. });
  20. });
  21. const gradingConfig: GradingConfig = {
  22. provider: 'openai:chat:gpt-4.1-mini',
  23. };
  24. describe('toPassLLMRubric', () => {
  25. it('should pass when strings meet the LLM Rubric criteria', async () => {
  26. await expect('Four score and seven years ago').toPassLLMRubric(
  27. 'Contains part of a famous speech',
  28. gradingConfig,
  29. );
  30. });
  31. it('should fail when strings do not meet the LLM Rubric criteria', async () => {
  32. await expect('It is time to do laundry').not.toPassLLMRubric(
  33. 'Contains part of a famous speech',
  34. gradingConfig,
  35. );
  36. });
  37. });
Tip!

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

Comments

Loading...