All files / shared/src/types/api/response body.ts

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

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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247        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 type {
  SuperAgentsRequestBody,
  SuperAgentsTarget,
} from '@shared/types/api/request';
import {
  CreateSpeechResponseBody,
  CreateTranscriptionResponseBody,
  CreateTranslationResponseBody,
} from '@shared/types/api/routes/audio-api';
import {
  CancelBatchResponseBody,
  type CreateBatchRequestBody,
  CreateBatchResponseBody,
  ListBatchesResponseBody,
  RetrieveBatchResponseBody,
} from '@shared/types/api/routes/batch-api';
import { ChatCompletionResponseBody } from '@shared/types/api/routes/chat-completions-api';
import type { ChatCompletionRequestBody } from '@shared/types/api/routes/chat-completions-api/request';
import type { CompletionRequestBody } from '@shared/types/api/routes/completions-api/request';
import { CompletionResponseBody } from '@shared/types/api/routes/completions-api/response';
import type { CreateEmbeddingsRequestBody } from '@shared/types/api/routes/embeddings-api';
import {
  CreateEmbeddingsErrorResponseBody,
  CreateEmbeddingsResponseBody,
} from '@shared/types/api/routes/embeddings-api';
import {
  FileContentResponseBody,
  FileDeleteResponseBody,
  FileErrorResponseBody,
  FileListResponseBody,
  FileRetrieveResponseBody,
  FileUploadResponseBody,
} from '@shared/types/api/routes/files-api';
import {
  CancelFineTuningJobResponseBody,
  type CreateFineTuningJobRequestBody,
  CreateFineTuningJobResponseBody,
  ListFineTuningCheckpointsResponseBody,
  ListFineTuningEventsResponseBody,
  ListFineTuningJobsResponseBody,
  RetrieveFineTuningJobResponseBody,
} from '@shared/types/api/routes/fine-tuning-api';
import {
  type GenerateImageRequestBody,
  GenerateImageResponseBody,
} from '@shared/types/api/routes/images-api';
import { ModerationResponseBody } from '@shared/types/api/routes/moderations-api';
import type { ResponsesRequestBody } from '@shared/types/api/routes/responses-api/request';
import {
  DeleteResponseResponseBody,
  GetResponseResponseBody,
  ListResponsesResponseBody,
  ResponsesResponseBody,
} from '@shared/types/api/routes/responses-api/response';
import type { ChatCompletionMessage } from '@shared/types/api/routes/shared/messages';
import { z } from 'zod';
 
export type ParameterValueTypes =
  | string
  | string[]
  | number
  | number[]
  | boolean
  | Record<string, unknown>
  | Record<string, unknown>[]
  | undefined
  | null;
 
export type ParameterConfigDefaultFunction = (params: {
  saRequestBody: SuperAgentsRequestBody;
  saTarget: SuperAgentsTarget;
}) => ParameterValueTypes;
 
export type CreateBatchRequestParameterTransformFunction = (
  saRequestBody: CreateBatchRequestBody,
) => ParameterValueTypes;
 
export type ChatCompletionParameterTransformFunction = (
  saRequestBody: ChatCompletionRequestBody,
) => ParameterValueTypes;
 
export type CompletionParameterTransformFunction = (
  saRequestBody: CompletionRequestBody,
) => ParameterValueTypes;
 
export type CreateFineTuningJobParameterTransformFunction = (
  saRequestBody: CreateFineTuningJobRequestBody,
) => ParameterValueTypes;
 
export type ImageGenerationParameterTransformFunction = (
  saRequestBody: GenerateImageRequestBody,
) => ParameterValueTypes;
 
export type ResponsesParameterTransformFunction = (
  saRequestBody: ResponsesRequestBody,
) => ParameterValueTypes;
 
export type EmbeddingsParameterTransformFunction = (
  saRequestBody: CreateEmbeddingsRequestBody,
) => ParameterValueTypes;
 
/**
 * Configuration for a parameter.
 */
export interface ParameterConfig {
  /** The name of the parameter. */
  param: string;
  /** The minimum value of the parameter. */
  min?: number;
  /** The maximum value of the parameter. */
  max?: number;
  /** Whether the parameter is required. */
  required?: boolean;
  /** A function to transform the value of the parameter. */
  transform?:
    | CreateBatchRequestParameterTransformFunction
    | ChatCompletionParameterTransformFunction
    | CompletionParameterTransformFunction
    | ImageGenerationParameterTransformFunction
    | ResponsesParameterTransformFunction
    | EmbeddingsParameterTransformFunction
    | CreateFineTuningJobParameterTransformFunction;
 
  /** The default value of the parameter, if not provided in the request. */
  default?:
    | string
    | number
    | boolean
    | Record<string, unknown>
    | null
    | ChatCompletionMessage[]
    | ParameterConfigDefaultFunction;
}
 
export type endpointStrings =
  | 'complete'
  | 'chatComplete'
  | 'embed'
  | 'rerank'
  | 'moderate'
  | 'stream-complete'
  | 'stream-chatComplete'
  | 'proxy'
  | 'imageGenerate'
  | 'createSpeech'
  | 'createTranscription'
  | 'createTranslation'
  | 'realtime'
  | 'uploadFile'
  | 'listFiles'
  | 'retrieveFile'
  | 'deleteFile'
  | 'retrieveFileContent'
  | 'createBatch'
  | 'retrieveBatch'
  | 'cancelBatch'
  | 'listBatches'
  | 'getBatchOutput'
  | 'listFinetunes'
  | 'createFinetune'
  | 'retrieveFinetune'
  | 'cancelFinetune'
  | 'createModelResponse'
  | 'getModelResponse'
  | 'deleteModelResponse'
  | 'listResponseInputItems'
  | 'initiateMultipartUpload';
 
/**
 * The structure of a error response for all functions
 */
export const ErrorResponseBody = z.object({
  error: z.object({
    message: z.string(),
    type: z.string().optional(),
    param: z.string().optional(),
    code: z.string().optional(),
  }),
  provider: z.string(),
  message: z.string().optional(),
  status: z.number().optional(),
});
 
export type ErrorResponseBody = z.infer<typeof ErrorResponseBody>;
 
export const SuperAgentsResponseBody = z.union([
  // Audio API
  CreateSpeechResponseBody,
  CreateTranscriptionResponseBody,
  CreateTranslationResponseBody,
 
  // Batch API
  CreateBatchResponseBody,
  RetrieveBatchResponseBody,
  CancelBatchResponseBody,
  ListBatchesResponseBody,
 
  // Chat Completions API
  ChatCompletionResponseBody,
 
  // Completions API
  CompletionResponseBody,
 
  // Embeddings API
  CreateEmbeddingsResponseBody,
  CreateEmbeddingsErrorResponseBody,
 
  // Files API
  FileUploadResponseBody,
  FileListResponseBody,
  FileRetrieveResponseBody,
  FileDeleteResponseBody,
  FileContentResponseBody,
  FileErrorResponseBody,
 
  // Fine-tuning API
  CreateFineTuningJobResponseBody,
  RetrieveFineTuningJobResponseBody,
  CancelFineTuningJobResponseBody,
  ListFineTuningJobsResponseBody,
  ListFineTuningEventsResponseBody,
  ListFineTuningCheckpointsResponseBody,
 
  // Images API
  GenerateImageResponseBody,
 
  // Moderations API
  ModerationResponseBody,
 
  // Responses API
  ResponsesResponseBody,
  DeleteResponseResponseBody,
  ListResponsesResponseBody,
  GetResponseResponseBody,
 
  // Other
  ErrorResponseBody,
]);
 
export type SuperAgentsResponseBody = z.infer<typeof SuperAgentsResponseBody>;
 
export type AIProviderResponseBody =
  | Record<string, unknown>
  | ReadableStream
  | FormData
  | ArrayBuffer;