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

utils.ts 1.1 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
  1. import type { ApiProvider, ProviderResponse } from '../../src/types';
  2. export class TestGrader implements ApiProvider {
  3. async callApi(): Promise<ProviderResponse> {
  4. return {
  5. output: JSON.stringify({ pass: true, reason: 'Test grading output' }),
  6. tokenUsage: { total: 10, prompt: 5, completion: 5 },
  7. };
  8. }
  9. id(): string {
  10. return 'TestGradingProvider';
  11. }
  12. }
  13. export function createMockResponse(options: Partial<Response> = {}): Response {
  14. const mockResponse: Response = {
  15. ok: true,
  16. status: 200,
  17. statusText: 'OK',
  18. headers: new Headers(),
  19. redirected: false,
  20. type: 'basic',
  21. url: 'https://example.com',
  22. json: () => Promise.resolve({}),
  23. text: () => Promise.resolve(''),
  24. blob: () => Promise.resolve(new Blob()),
  25. arrayBuffer: () => Promise.resolve(new ArrayBuffer(0)),
  26. formData: () => Promise.resolve(new FormData()),
  27. bytes: () => Promise.resolve(new Uint8Array()),
  28. bodyUsed: false,
  29. body: null,
  30. clone() {
  31. return createMockResponse(this);
  32. },
  33. ...options,
  34. };
  35. return mockResponse;
  36. }
Tip!

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

Comments

Loading...