All files / src/services gpt.service.ts

100% Statements 4/4
100% Branches 6/6
100% Functions 2/2
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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          23x     23x             15x     15x                  
import axios, { AxiosInstance, AxiosResponse } from 'axios';
import { GptResponsePayload } from '@3cr/viewer-types-ts';
 
export class GptService {
  static Instantiate() {
    return new GptService();
  }
 
  client: AxiosInstance = axios.create();
 
  async GenerateAnnotations(
    title: string,
    question: number = 0,
  ): Promise<AxiosResponse<GptResponsePayload>> {
    const testVersion =
      window.location.href.includes('test.') ||
      window.location.href.includes('localhost') ||
      window.location.href.includes('next.');
    return this.client.post(
      `https://${testVersion ? 'test.' : ''}api.singular.health/api/GPT/Smart/Annotation`,
      null,
      {
        params: { annotationTitle: title, question },
      },
    );
  }
}