-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathglobals.ts
More file actions
311 lines (293 loc) · 8.83 KB
/
Copy pathglobals.ts
File metadata and controls
311 lines (293 loc) · 8.83 KB
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
import { endpointStrings } from './providers/types';
export const POWERED_BY: string = 'portkey';
export const MAX_RETRY_LIMIT_MS = 60 * 1000; // 60 seconds
export const POSSIBLE_RETRY_STATUS_HEADERS = [
'retry-after-ms',
'x-ms-retry-after-ms',
'retry-after',
];
export const HEADER_KEYS: Record<string, string> = {
API_KEY: `x-${POWERED_BY}-api-key`,
MODE: `x-${POWERED_BY}-mode`,
RETRIES: `x-${POWERED_BY}-retry-count`,
PROVIDER: `x-${POWERED_BY}-provider`,
CONFIG: `x-${POWERED_BY}-config`,
TRACE_ID: `x-${POWERED_BY}-trace-id`,
CACHE: `x-${POWERED_BY}-cache`,
METADATA: `x-${POWERED_BY}-metadata`,
FORWARD_HEADERS: `x-${POWERED_BY}-forward-headers`,
CUSTOM_HOST: `x-${POWERED_BY}-custom-host`,
REQUEST_TIMEOUT: `x-${POWERED_BY}-request-timeout`,
STRICT_OPEN_AI_COMPLIANCE: `x-${POWERED_BY}-strict-open-ai-compliance`,
CONTENT_TYPE: `Content-Type`,
VIRTUAL_KEY: `x-${POWERED_BY}-virtual-key`,
};
export const RESPONSE_HEADER_KEYS: Record<string, string> = {
RETRY_ATTEMPT_COUNT: `x-${POWERED_BY}-retry-attempt-count`,
LAST_USED_OPTION_INDEX: `x-${POWERED_BY}-last-used-option-index`,
LAST_USED_OPTION_PARAMS: `x-${POWERED_BY}-last-used-option-params`,
CACHE_STATUS: `x-${POWERED_BY}-cache-status`,
TRACE_ID: `x-${POWERED_BY}-trace-id`,
};
export const RETRY_STATUS_CODES = [429, 500, 502, 503, 504];
export const MAX_RETRIES = 5;
export const REQUEST_TIMEOUT_STATUS_CODE = 408;
export const PRECONDITION_CHECK_FAILED_STATUS_CODE = 412;
export const OPEN_AI: string = 'openai';
export const COHERE: string = 'cohere';
export const AZURE_OPEN_AI: string = 'azure-openai';
export const AZURE_AI_INFERENCE: string = 'azure-ai';
export const ANTHROPIC: string = 'anthropic';
export const ANYSCALE: string = 'anyscale';
export const PALM: string = 'palm';
export const TOGETHER_AI: string = 'together-ai';
export const GOOGLE: string = 'google';
export const GOOGLE_VERTEX_AI: string = 'vertex-ai';
export const HUGGING_FACE: string = 'huggingface';
export const PERPLEXITY_AI: string = 'perplexity-ai';
export const REKA_AI: string = 'reka-ai';
export const MISTRAL_AI: string = 'mistral-ai';
export const DEEPINFRA: string = 'deepinfra';
export const NCOMPASS: string = 'ncompass';
export const STABILITY_AI: string = 'stability-ai';
export const NOMIC: string = 'nomic';
export const OLLAMA: string = 'ollama';
export const AI21: string = 'ai21';
export const BEDROCK: string = 'bedrock';
export const GROQ: string = 'groq';
export const SEGMIND: string = 'segmind';
export const JINA: string = 'jina';
export const FIREWORKS_AI: string = 'fireworks-ai';
export const WORKERS_AI: string = 'workers-ai';
export const MOONSHOT: string = 'moonshot';
export const OPENROUTER: string = 'openrouter';
export const LINGYI: string = 'lingyi';
export const ZHIPU: string = 'zhipu';
export const NOVITA_AI: string = 'novita-ai';
export const MONSTERAPI: string = 'monsterapi';
export const DEEPSEEK: string = 'deepseek';
export const PREDIBASE: string = 'predibase';
export const TRITON: string = 'triton';
export const VOYAGE: string = 'voyage';
export const GITHUB: string = 'github';
export const DEEPBRICKS: string = 'deepbricks';
export const SILICONFLOW: string = 'siliconflow';
export const CEREBRAS: string = 'cerebras';
export const INFERENCENET: string = 'inference-net';
export const SAMBANOVA: string = 'sambanova';
export const LEMONFOX_AI: string = 'lemonfox-ai';
export const UPSTAGE: string = 'upstage';
export const LAMBDA: string = 'lambda';
export const DASHSCOPE: string = 'dashscope';
export const X_AI: string = 'x-ai';
export const CORTEX: string = 'cortex';
export const SAGEMAKER: string = 'sagemaker';
export const NEBIUS: string = 'nebius';
export const RECRAFTAI: string = 'recraft-ai';
export const MILVUS: string = 'milvus';
export const REPLICATE: string = 'replicate';
export const LEPTON: string = 'lepton';
export const KLUSTER_AI: string = 'kluster-ai';
export const NSCALE: string = 'nscale';
export const HYPERBOLIC: string = 'hyperbolic';
export const BYTEZ: string = 'bytez';
export const FEATHERLESS_AI: string = 'featherless-ai';
export const KRUTRIM: string = 'krutrim';
export const QDRANT: string = 'qdrant';
export const THREE_ZERO_TWO_AI: string = '302ai';
export const COMETAPI: string = 'cometapi';
export const MATTERAI: string = 'matterai';
export const MESHY: string = 'meshy';
export const TRIPO3D: string = 'tripo3d';
export const NEXTBIT: string = 'nextbit';
export const MODAL: string = 'modal';
export const Z_AI: string = 'z-ai';
export const ORACLE: string = 'oracle';
export const IO_INTELLIGENCE: string = 'iointelligence';
export const AIBADGR: string = 'aibadgr';
export const OVHCLOUD: string = 'ovhcloud';
export const MIXLAYER: string = 'mixlayer';
export const VALID_PROVIDERS = [
ANTHROPIC,
ANYSCALE,
AZURE_OPEN_AI,
COHERE,
GOOGLE,
GOOGLE_VERTEX_AI,
MISTRAL_AI,
OPEN_AI,
PALM,
PERPLEXITY_AI,
REKA_AI,
TOGETHER_AI,
DEEPINFRA,
NCOMPASS,
STABILITY_AI,
NOMIC,
OLLAMA,
AI21,
BEDROCK,
GROQ,
SEGMIND,
JINA,
FIREWORKS_AI,
WORKERS_AI,
MOONSHOT,
OPENROUTER,
LINGYI,
ZHIPU,
NOVITA_AI,
MONSTERAPI,
DEEPSEEK,
PREDIBASE,
TRITON,
VOYAGE,
AZURE_AI_INFERENCE,
GITHUB,
DEEPBRICKS,
SILICONFLOW,
HUGGING_FACE,
CEREBRAS,
INFERENCENET,
SAMBANOVA,
LEMONFOX_AI,
UPSTAGE,
LAMBDA,
DASHSCOPE,
X_AI,
CORTEX,
SAGEMAKER,
NEBIUS,
RECRAFTAI,
MILVUS,
REPLICATE,
POWERED_BY,
LEPTON,
KLUSTER_AI,
NSCALE,
HYPERBOLIC,
BYTEZ,
FEATHERLESS_AI,
KRUTRIM,
QDRANT,
THREE_ZERO_TWO_AI,
COMETAPI,
MATTERAI,
MESHY,
TRIPO3D,
NEXTBIT,
MODAL,
Z_AI,
ORACLE,
IO_INTELLIGENCE,
AIBADGR,
OVHCLOUD,
MIXLAYER,
];
export const CONTENT_TYPES = {
APPLICATION_JSON: 'application/json',
MULTIPART_FORM_DATA: 'multipart/form-data',
EVENT_STREAM: 'text/event-stream',
AUDIO_MPEG: 'audio/mpeg',
APPLICATION_OCTET_STREAM: 'application/octet-stream',
BINARY_OCTET_STREAM: 'binary/octet-stream',
GENERIC_AUDIO_PATTERN: 'audio',
PLAIN_TEXT: 'text/plain',
HTML: 'text/html',
GENERIC_IMAGE_PATTERN: 'image/',
};
export const MULTIPART_FORM_DATA_ENDPOINTS: endpointStrings[] = [
'createTranscription',
'createTranslation',
'uploadFile',
];
export const fileExtensionMimeTypeMap = {
mp4: 'video/mp4',
jpeg: 'image/jpeg',
jpg: 'image/jpeg',
png: 'image/png',
bmp: 'image/bmp',
tiff: 'image/tiff',
webp: 'image/webp',
pdf: 'application/pdf',
csv: 'text/csv',
doc: 'application/msword',
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
xls: 'application/vnd.ms-excel',
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
html: 'text/html',
md: 'text/markdown',
mp3: 'audio/mp3',
wav: 'audio/wav',
txt: 'text/plain',
mov: 'video/mov',
mpeg: 'video/mpeg',
mpg: 'video/mpg',
avi: 'video/avi',
wmv: 'video/wmv',
mpegps: 'video/mpegps',
flv: 'video/flv',
webm: 'video/webm',
mkv: 'video/mkv',
threegpp: 'video/three_gpp',
};
export const imagesMimeTypes = [
fileExtensionMimeTypeMap.jpeg,
fileExtensionMimeTypeMap.jpg,
fileExtensionMimeTypeMap.png,
fileExtensionMimeTypeMap.bmp,
fileExtensionMimeTypeMap.tiff,
fileExtensionMimeTypeMap.webp,
];
export const documentMimeTypes = [
fileExtensionMimeTypeMap.pdf,
fileExtensionMimeTypeMap.csv,
fileExtensionMimeTypeMap.doc,
fileExtensionMimeTypeMap.docx,
fileExtensionMimeTypeMap.xls,
fileExtensionMimeTypeMap.xlsx,
fileExtensionMimeTypeMap.html,
fileExtensionMimeTypeMap.md,
fileExtensionMimeTypeMap.txt,
];
export const videoMimeTypes = [
fileExtensionMimeTypeMap.mkv,
fileExtensionMimeTypeMap.mov,
fileExtensionMimeTypeMap.mp4,
fileExtensionMimeTypeMap.webm,
fileExtensionMimeTypeMap.flv,
fileExtensionMimeTypeMap.mpeg,
fileExtensionMimeTypeMap.mpg,
fileExtensionMimeTypeMap.wmv,
fileExtensionMimeTypeMap.threegpp,
fileExtensionMimeTypeMap.avi,
];
export enum BatchEndpoints {
CHAT_COMPLETIONS = '/v1/chat/completions',
COMPLETIONS = '/v1/completions',
EMBEDDINGS = '/v1/embeddings',
}
export const AtomicOperations = {
GET: 'GET',
RESET: 'RESET',
INCREMENT: 'INCREMENT',
DECREMENT: 'DECREMENT',
};
export enum RateLimiterKeyTypes {
VIRTUAL_KEY = 'VIRTUAL_KEY',
API_KEY = 'API_KEY',
WORKSPACE = 'WORKSPACE',
INTEGRATION_WORKSPACE = 'INTEGRATION_WORKSPACE',
}
export const METRICS_KEYS = {
AUTH_N_MIDDLEWARE_START: 'authNMiddlewareStart',
AUTH_N_MIDDLEWARE_END: 'authNMiddlewareEnd',
API_KEY_RATE_LIMIT_CHECK_START: 'apiKeyRateLimitCheckStart',
API_KEY_RATE_LIMIT_CHECK_END: 'apiKeyRateLimitCheckEnd',
PORTKEY_MIDDLEWARE_PRE_REQUEST_START: 'portkeyMiddlewarePreRequestStart',
PORTKEY_MIDDLEWARE_PRE_REQUEST_END: 'portkeyMiddlewarePreRequestEnd',
PORTKEY_MIDDLEWARE_POST_REQUEST_START: 'portkeyMiddlewarePostRequestStart',
PORTKEY_MIDDLEWARE_POST_REQUEST_END: 'portkeyMiddlewarePostRequestEnd',
LLM_CACHE_GET_START: 'llmCacheGetStart',
LLM_CACHE_GET_END: 'llmCacheGetEnd',
};