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

providers.azure.test.ts 3.2 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
  1. import { AzureOpenAiCompletionProvider } from '../src/providers/azureopenai';
  2. import { maybeEmitAzureOpenAiWarning } from '../src/providers/azureopenaiUtil';
  3. import { HuggingfaceTextGenerationProvider } from '../src/providers/huggingface';
  4. import { OpenAiCompletionProvider } from '../src/providers/openai';
  5. import type { TestSuite, TestCase } from '../src/types';
  6. jest.mock('../src/logger');
  7. describe('maybeEmitAzureOpenAiWarning', () => {
  8. it('should not emit warning when no Azure providers are used', () => {
  9. const testSuite: TestSuite = {
  10. providers: [new OpenAiCompletionProvider('foo')],
  11. defaultTest: {},
  12. prompts: [],
  13. };
  14. const tests: TestCase[] = [
  15. {
  16. assert: [{ type: 'llm-rubric', value: 'foo bar' }],
  17. },
  18. ];
  19. const result = maybeEmitAzureOpenAiWarning(testSuite, tests);
  20. expect(result).toBe(false);
  21. });
  22. it('should not emit warning when Azure provider is used alone, but no model graded eval', () => {
  23. const testSuite: TestSuite = {
  24. providers: [new AzureOpenAiCompletionProvider('foo')],
  25. defaultTest: {},
  26. prompts: [],
  27. };
  28. const tests: TestCase[] = [
  29. {
  30. assert: [{ type: 'equals' }],
  31. },
  32. ];
  33. const result = maybeEmitAzureOpenAiWarning(testSuite, tests);
  34. expect(result).toBe(false);
  35. });
  36. it('should emit warning when Azure provider is used alone, but with model graded eval', () => {
  37. const testSuite: TestSuite = {
  38. providers: [new AzureOpenAiCompletionProvider('foo')],
  39. defaultTest: {},
  40. prompts: [],
  41. };
  42. const tests: TestCase[] = [
  43. {
  44. assert: [{ type: 'llm-rubric', value: 'foo bar' }],
  45. },
  46. ];
  47. const result = maybeEmitAzureOpenAiWarning(testSuite, tests);
  48. expect(result).toBe(true);
  49. });
  50. it('should emit warning when Azure provider used with non-OpenAI provider', () => {
  51. const testSuite: TestSuite = {
  52. providers: [
  53. new AzureOpenAiCompletionProvider('foo'),
  54. new HuggingfaceTextGenerationProvider('bar'),
  55. ],
  56. defaultTest: {},
  57. prompts: [],
  58. };
  59. const tests: TestCase[] = [
  60. {
  61. assert: [{ type: 'llm-rubric', value: 'foo bar' }],
  62. },
  63. ];
  64. const result = maybeEmitAzureOpenAiWarning(testSuite, tests);
  65. expect(result).toBe(true);
  66. });
  67. it('should not emit warning when Azure providers are used with a default provider set', () => {
  68. const testSuite: TestSuite = {
  69. providers: [new AzureOpenAiCompletionProvider('foo')],
  70. defaultTest: { options: { provider: 'azureopenai:....' } },
  71. prompts: [],
  72. };
  73. const tests: TestCase[] = [
  74. {
  75. assert: [{ type: 'llm-rubric', value: 'foo bar' }],
  76. },
  77. ];
  78. const result = maybeEmitAzureOpenAiWarning(testSuite, tests);
  79. expect(result).toBe(false);
  80. });
  81. it('should not emit warning when both Azure and OpenAI providers are used', () => {
  82. const testSuite: TestSuite = {
  83. providers: [new AzureOpenAiCompletionProvider('foo'), new OpenAiCompletionProvider('bar')],
  84. defaultTest: {},
  85. prompts: [],
  86. };
  87. const tests: TestCase[] = [
  88. {
  89. assert: [{ type: 'llm-rubric', value: 'foo bar' }],
  90. },
  91. ];
  92. const result = maybeEmitAzureOpenAiWarning(testSuite, tests);
  93. expect(result).toBe(false);
  94. });
  95. });
Tip!

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

Comments

Loading...