All files / api/src/ai-providers/azure-openai index.ts

100% Statements 76/76
100% Branches 0/0
100% Functions 0/0
100% Lines 76/76

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 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 1021x 1x 1x   1x 1x 1x             1x 1x 1x 1x       1x       1x 1x       1x       1x 1x       1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x  
import { azureOpenAICreateTranscriptionResponseTransform } from '@api/ai-providers/azure-openai/create-transcription';
import { azureOpenAICreateTranslationResponseTransform } from '@api/ai-providers/azure-openai/create-translation';
import { azureOpenAIResponseTransform } from '@api/ai-providers/azure-openai/upload-file';
import type { AIProviderConfig } from '@shared/types/ai-providers/config';
import { FunctionName } from '@shared/types/api/request';
import { AIProvider } from '@shared/types/constants';
import {
  createModelResponseParams,
  openAICreateModelResponseTransformer,
  openAIDeleteModelResponseTransformer,
  openAIGetModelResponseTransformer,
  openAIListInputItemsResponseTransformer,
} from '../open-ai-base';
import { openAICreateFinetuneConfig } from '../openai/create-finetune';
import { openAIFileUploadRequestTransform } from '../openai/upload-file';
import { azureOpenAIAPIConfig } from './api';
import {
  azureOpenAIChatCompleteConfig,
  azureOpenAIChatCompleteResponseTransform,
} from './chat-complete';
import {
  azureOpenAICompleteConfig,
  azureOpenAICompleteResponseTransform,
} from './complete';
import { azureOpenAICreateBatchConfig } from './create-batch';
import {
  azureOpenAICreateSpeechConfig,
  azureOpenAICreateSpeechResponseTransform,
} from './create-speech';
import {
  azureOpenAIEmbedConfig,
  azureOpenAIEmbedResponseTransform,
} from './embed';
import { azureOpenAIGetBatchOutputRequestHandler } from './get-batch-output';
import {
  azureOpenAIImageGenerateConfig,
  azureOpenAIImageGenerateResponseTransform,
} from './image-generate';
import { azureOpenAIFinetuneResponseTransform } from './utils';
 
export const azureOpenAIConfig: AIProviderConfig = {
  api: azureOpenAIAPIConfig,
  [FunctionName.COMPLETE]: azureOpenAICompleteConfig,
  [FunctionName.EMBED]: azureOpenAIEmbedConfig,
  [FunctionName.GENERATE_IMAGE]: azureOpenAIImageGenerateConfig,
  [FunctionName.CHAT_COMPLETE]: azureOpenAIChatCompleteConfig,
  [FunctionName.CREATE_SPEECH]: azureOpenAICreateSpeechConfig,
  [FunctionName.CREATE_FINE_TUNING_JOB]: openAICreateFinetuneConfig,
  [FunctionName.CREATE_TRANSCRIPTION]: {},
  [FunctionName.CREATE_TRANSLATION]: {},
  [FunctionName.REALTIME]: {},
  [FunctionName.CANCEL_FINE_TUNING_JOB]: {},
  [FunctionName.CANCEL_BATCH]: {},
  [FunctionName.CREATE_BATCH]: azureOpenAICreateBatchConfig,
  [FunctionName.CREATE_MODEL_RESPONSE]: createModelResponseParams([]),
  [FunctionName.GET_MODEL_RESPONSE]: {},
  [FunctionName.DELETE_MODEL_RESPONSE]: {},
  [FunctionName.LIST_RESPONSE_INPUT_ITEMS]: {},
  requestHandlers: {
    [FunctionName.GET_BATCH_OUTPUT]: azureOpenAIGetBatchOutputRequestHandler,
  },
  // Transforms the Azure OpenAI response to the Super Agents response
  responseTransforms: {
    [FunctionName.COMPLETE]: azureOpenAICompleteResponseTransform,
    [FunctionName.CHAT_COMPLETE]: azureOpenAIChatCompleteResponseTransform,
    [FunctionName.EMBED]: azureOpenAIEmbedResponseTransform,
    [FunctionName.GENERATE_IMAGE]: azureOpenAIImageGenerateResponseTransform,
    [FunctionName.CREATE_SPEECH]: azureOpenAICreateSpeechResponseTransform,
    [FunctionName.CREATE_TRANSCRIPTION]:
      azureOpenAICreateTranscriptionResponseTransform,
    [FunctionName.CREATE_TRANSLATION]:
      azureOpenAICreateTranslationResponseTransform,
    [FunctionName.UPLOAD_FILE]: azureOpenAIResponseTransform,
    [FunctionName.LIST_FILES]: azureOpenAIResponseTransform,
    [FunctionName.RETRIEVE_FILE]: azureOpenAIResponseTransform,
    [FunctionName.DELETE_FILE]: azureOpenAIResponseTransform,
    [FunctionName.RETRIEVE_FILE_CONTENT]: azureOpenAIResponseTransform,
    [FunctionName.CREATE_FINE_TUNING_JOB]: azureOpenAIResponseTransform,
    [FunctionName.RETRIEVE_FINE_TUNING_JOB]:
      azureOpenAIFinetuneResponseTransform,
    [FunctionName.CREATE_BATCH]: azureOpenAIResponseTransform,
    [FunctionName.GET_BATCH_OUTPUT]: azureOpenAIResponseTransform,
    [FunctionName.CANCEL_BATCH]: azureOpenAIResponseTransform,
    [FunctionName.LIST_BATCHES]: azureOpenAIResponseTransform,
    [FunctionName.CREATE_MODEL_RESPONSE]: openAICreateModelResponseTransformer(
      AIProvider.AZURE_OPENAI,
    ),
    [FunctionName.GET_MODEL_RESPONSE]: openAIGetModelResponseTransformer(
      AIProvider.AZURE_OPENAI,
    ),
    [FunctionName.DELETE_MODEL_RESPONSE]: openAIDeleteModelResponseTransformer(
      AIProvider.AZURE_OPENAI,
    ),
    [FunctionName.LIST_RESPONSE_INPUT_ITEMS]:
      openAIListInputItemsResponseTransformer(AIProvider.AZURE_OPENAI),
  },
  requestTransforms: {
    // [FunctionName.CREATE_FINETUNING_JOB]: azureTransformFinetuneBody,
    [FunctionName.UPLOAD_FILE]: openAIFileUploadRequestTransform,
  },
};