librechat-data-provider 0.8.401 → 0.8.403

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/index.es.js +1 -1
  2. package/dist/index.es.js.map +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/react-query/index.es.js +1 -1
  6. package/dist/react-query/index.es.js.map +1 -1
  7. package/dist/types/accessPermissions.d.ts +744 -0
  8. package/dist/types/actions.d.ts +118 -0
  9. package/dist/types/api-endpoints.d.ts +149 -0
  10. package/dist/types/artifacts.d.ts +97 -0
  11. package/dist/types/azure.d.ts +22 -0
  12. package/dist/types/bedrock.d.ts +1220 -0
  13. package/dist/types/config.d.ts +13916 -0
  14. package/dist/types/config.spec.d.ts +1 -0
  15. package/dist/types/createPayload.d.ts +5 -0
  16. package/dist/types/data-service.d.ts +284 -0
  17. package/dist/types/feedback.d.ts +36 -0
  18. package/dist/types/file-config.d.ts +263 -0
  19. package/dist/types/file-config.spec.d.ts +1 -0
  20. package/dist/types/generate.d.ts +597 -0
  21. package/dist/types/headers-helpers.d.ts +2 -0
  22. package/{src/index.ts → dist/types/index.d.ts} +0 -15
  23. package/dist/types/keys.d.ts +92 -0
  24. package/dist/types/mcp.d.ts +2760 -0
  25. package/dist/types/messages.d.ts +10 -0
  26. package/dist/types/models.d.ts +1677 -0
  27. package/dist/types/parameterSettings.d.ts +69 -0
  28. package/dist/types/parsers.d.ts +110 -0
  29. package/dist/types/permissions.d.ts +522 -0
  30. package/dist/types/react-query/react-query-service.d.ts +85 -0
  31. package/dist/types/request.d.ts +25 -0
  32. package/dist/types/roles.d.ts +554 -0
  33. package/dist/types/roles.spec.d.ts +1 -0
  34. package/dist/types/schemas.d.ts +4815 -0
  35. package/dist/types/schemas.spec.d.ts +1 -0
  36. package/dist/types/types/agents.d.ts +433 -0
  37. package/dist/types/types/assistants.d.ts +547 -0
  38. package/dist/types/types/files.d.ts +172 -0
  39. package/dist/types/types/graph.d.ts +135 -0
  40. package/{src/types/mcpServers.ts → dist/types/types/mcpServers.d.ts} +12 -18
  41. package/dist/types/types/mutations.d.ts +209 -0
  42. package/dist/types/types/queries.d.ts +169 -0
  43. package/dist/types/types/runs.d.ts +36 -0
  44. package/dist/types/types/web.d.ts +520 -0
  45. package/dist/types/types.d.ts +503 -0
  46. package/dist/types/utils.d.ts +12 -0
  47. package/package.json +4 -1
  48. package/babel.config.js +0 -4
  49. package/check_updates.sh +0 -52
  50. package/jest.config.js +0 -19
  51. package/react-query/package-lock.json +0 -292
  52. package/react-query/package.json +0 -10
  53. package/rollup.config.js +0 -74
  54. package/server-rollup.config.js +0 -40
  55. package/specs/actions.spec.ts +0 -2533
  56. package/specs/api-endpoints-subdir.spec.ts +0 -140
  57. package/specs/api-endpoints.spec.ts +0 -74
  58. package/specs/azure.spec.ts +0 -844
  59. package/specs/bedrock.spec.ts +0 -862
  60. package/specs/filetypes.spec.ts +0 -175
  61. package/specs/generate.spec.ts +0 -770
  62. package/specs/headers-helpers.spec.ts +0 -24
  63. package/specs/mcp.spec.ts +0 -147
  64. package/specs/openapiSpecs.ts +0 -524
  65. package/specs/parsers.spec.ts +0 -601
  66. package/specs/request-interceptor.spec.ts +0 -304
  67. package/specs/utils.spec.ts +0 -196
  68. package/src/accessPermissions.ts +0 -346
  69. package/src/actions.ts +0 -813
  70. package/src/api-endpoints.ts +0 -440
  71. package/src/artifacts.ts +0 -3104
  72. package/src/azure.ts +0 -328
  73. package/src/bedrock.ts +0 -425
  74. package/src/config.spec.ts +0 -315
  75. package/src/config.ts +0 -1978
  76. package/src/createPayload.ts +0 -46
  77. package/src/data-service.ts +0 -1087
  78. package/src/feedback.ts +0 -141
  79. package/src/file-config.spec.ts +0 -1248
  80. package/src/file-config.ts +0 -764
  81. package/src/generate.ts +0 -634
  82. package/src/headers-helpers.ts +0 -13
  83. package/src/keys.ts +0 -99
  84. package/src/mcp.ts +0 -271
  85. package/src/messages.ts +0 -50
  86. package/src/models.ts +0 -69
  87. package/src/parameterSettings.ts +0 -1111
  88. package/src/parsers.ts +0 -563
  89. package/src/permissions.ts +0 -188
  90. package/src/react-query/react-query-service.ts +0 -566
  91. package/src/request.ts +0 -171
  92. package/src/roles.spec.ts +0 -132
  93. package/src/roles.ts +0 -225
  94. package/src/schemas.spec.ts +0 -355
  95. package/src/schemas.ts +0 -1225
  96. package/src/types/agents.ts +0 -445
  97. package/src/types/assistants.ts +0 -644
  98. package/src/types/files.ts +0 -191
  99. package/src/types/graph.ts +0 -145
  100. package/src/types/mutations.ts +0 -422
  101. package/src/types/queries.ts +0 -208
  102. package/src/types/runs.ts +0 -26
  103. package/src/types/web.ts +0 -588
  104. package/src/types.ts +0 -679
  105. package/src/utils.ts +0 -85
  106. package/tsconfig.json +0 -28
  107. package/tsconfig.spec.json +0 -10
  108. /package/{src/react-query/index.ts → dist/types/react-query/index.d.ts} +0 -0
  109. /package/{src/types/index.ts → dist/types/types/index.d.ts} +0 -0
package/src/config.ts DELETED
@@ -1,1978 +0,0 @@
1
- import { z } from 'zod';
2
- import type { ZodError } from 'zod';
3
- import type { TEndpointsConfig, TModelsConfig, TConfig } from './types';
4
- import { EModelEndpoint, eModelEndpointSchema, isAgentsEndpoint } from './schemas';
5
- import { specsConfigSchema, TSpecsConfig } from './models';
6
- import { fileConfigSchema } from './file-config';
7
- import { apiBaseUrl } from './api-endpoints';
8
- import { FileSources } from './types/files';
9
- import { MCPServersSchema } from './mcp';
10
-
11
- export const defaultSocialLogins = ['google', 'facebook', 'openid', 'github', 'discord', 'saml'];
12
-
13
- export const defaultRetrievalModels = [
14
- 'gpt-4o',
15
- 'o1-preview-2024-09-12',
16
- 'o1-preview',
17
- 'o1-mini-2024-09-12',
18
- 'o1-mini',
19
- 'o3-mini',
20
- 'chatgpt-4o-latest',
21
- 'gpt-4o-2024-05-13',
22
- 'gpt-4o-2024-08-06',
23
- 'gpt-4o-mini',
24
- 'gpt-4o-mini-2024-07-18',
25
- 'gpt-4-turbo-preview',
26
- 'gpt-3.5-turbo-0125',
27
- 'gpt-4-0125-preview',
28
- 'gpt-4-1106-preview',
29
- 'gpt-3.5-turbo-1106',
30
- 'gpt-3.5-turbo-0125',
31
- 'gpt-4-turbo',
32
- 'gpt-4-0125',
33
- 'gpt-4-1106',
34
- ];
35
-
36
- export const excludedKeys = new Set([
37
- 'conversationId',
38
- 'title',
39
- 'iconURL',
40
- 'greeting',
41
- 'endpoint',
42
- 'endpointType',
43
- 'createdAt',
44
- 'updatedAt',
45
- 'expiredAt',
46
- 'messages',
47
- 'isArchived',
48
- 'tags',
49
- 'user',
50
- '__v',
51
- '_id',
52
- 'tools',
53
- 'model',
54
- 'files',
55
- 'spec',
56
- 'disableParams',
57
- ]);
58
-
59
- export enum SettingsViews {
60
- default = 'default',
61
- advanced = 'advanced',
62
- }
63
-
64
- export const fileSourceSchema = z.nativeEnum(FileSources);
65
-
66
- export const fileStrategiesSchema = z
67
- .object({
68
- default: fileSourceSchema.optional(),
69
- avatar: fileSourceSchema.optional(),
70
- image: fileSourceSchema.optional(),
71
- document: fileSourceSchema.optional(),
72
- })
73
- .optional();
74
-
75
- // Helper type to extract the shape of the Zod object schema
76
- type SchemaShape<T> = T extends z.ZodObject<infer U> ? U : never;
77
-
78
- // Helper type to determine the default value or undefined based on whether the field has a default
79
- type DefaultValue<T> =
80
- T extends z.ZodDefault<z.ZodTypeAny> ? ReturnType<T['_def']['defaultValue']> : undefined;
81
-
82
- // Extract default values or undefined from the schema shape
83
- type ExtractDefaults<T> = {
84
- [P in keyof T]: DefaultValue<T[P]>;
85
- };
86
-
87
- export type SchemaDefaults<T> = ExtractDefaults<SchemaShape<T>>;
88
-
89
- export type TConfigDefaults = SchemaDefaults<typeof configSchema>;
90
-
91
- export function getSchemaDefaults<Schema extends z.AnyZodObject>(
92
- schema: Schema,
93
- ): ExtractDefaults<SchemaShape<Schema>> {
94
- const shape = schema.shape;
95
- const entries = Object.entries(shape).map(([key, value]) => {
96
- if (value instanceof z.ZodDefault) {
97
- // Extract default value if it exists
98
- return [key, value._def.defaultValue()];
99
- }
100
- return [key, undefined];
101
- });
102
-
103
- // Create the object with the right types
104
- return Object.fromEntries(entries) as ExtractDefaults<SchemaShape<Schema>>;
105
- }
106
-
107
- export const modelConfigSchema = z
108
- .object({
109
- deploymentName: z.string().optional(),
110
- version: z.string().optional(),
111
- assistants: z.boolean().optional(),
112
- })
113
- .or(z.boolean());
114
-
115
- export type TAzureModelConfig = z.infer<typeof modelConfigSchema>;
116
-
117
- export const azureBaseSchema = z.object({
118
- apiKey: z.string(),
119
- serverless: z.boolean().optional(),
120
- instanceName: z.string().optional(),
121
- deploymentName: z.string().optional(),
122
- assistants: z.boolean().optional(),
123
- addParams: z.record(z.any()).optional(),
124
- dropParams: z.array(z.string()).optional(),
125
- version: z.string().optional(),
126
- baseURL: z.string().optional(),
127
- additionalHeaders: z.record(z.any()).optional(),
128
- });
129
-
130
- export type TAzureBaseSchema = z.infer<typeof azureBaseSchema>;
131
-
132
- export const azureGroupSchema = z
133
- .object({
134
- group: z.string(),
135
- models: z.record(z.string(), modelConfigSchema),
136
- })
137
- .required()
138
- .and(azureBaseSchema);
139
-
140
- export const azureGroupConfigsSchema = z.array(azureGroupSchema).min(1);
141
- export type TAzureGroup = z.infer<typeof azureGroupSchema>;
142
- export type TAzureGroups = z.infer<typeof azureGroupConfigsSchema>;
143
- export type TAzureModelMapSchema = {
144
- // deploymentName?: string;
145
- // version?: string;
146
- group: string;
147
- };
148
-
149
- export type TAzureModelGroupMap = Record<string, TAzureModelMapSchema | undefined>;
150
- export type TAzureGroupMap = Record<
151
- string,
152
- (TAzureBaseSchema & { models: Record<string, TAzureModelConfig | undefined> }) | undefined
153
- >;
154
-
155
- export type TValidatedAzureConfig = {
156
- modelNames: string[];
157
- groupMap: TAzureGroupMap;
158
- assistantModels?: string[];
159
- assistantGroups?: string[];
160
- modelGroupMap: TAzureModelGroupMap;
161
- };
162
-
163
- export type TAzureConfigValidationResult = TValidatedAzureConfig & {
164
- isValid: boolean;
165
- errors: (ZodError | string)[];
166
- };
167
-
168
- export enum Capabilities {
169
- code_interpreter = 'code_interpreter',
170
- image_vision = 'image_vision',
171
- retrieval = 'retrieval',
172
- actions = 'actions',
173
- tools = 'tools',
174
- }
175
-
176
- export enum AgentCapabilities {
177
- hide_sequential_outputs = 'hide_sequential_outputs',
178
- programmatic_tools = 'programmatic_tools',
179
- end_after_tools = 'end_after_tools',
180
- deferred_tools = 'deferred_tools',
181
- execute_code = 'execute_code',
182
- file_search = 'file_search',
183
- web_search = 'web_search',
184
- artifacts = 'artifacts',
185
- actions = 'actions',
186
- context = 'context',
187
- tools = 'tools',
188
- chain = 'chain',
189
- ocr = 'ocr',
190
- }
191
-
192
- export const defaultAssistantsVersion = {
193
- [EModelEndpoint.assistants]: 2,
194
- [EModelEndpoint.azureAssistants]: 1,
195
- };
196
-
197
- export const baseEndpointSchema = z.object({
198
- streamRate: z.number().optional(),
199
- baseURL: z.string().optional(),
200
- titlePrompt: z.string().optional(),
201
- titleModel: z.string().optional(),
202
- titleConvo: z.boolean().optional(),
203
- titleMethod: z
204
- .union([z.literal('completion'), z.literal('functions'), z.literal('structured')])
205
- .optional(),
206
- titleEndpoint: z.string().optional(),
207
- titlePromptTemplate: z.string().optional(),
208
- });
209
-
210
- export type TBaseEndpoint = z.infer<typeof baseEndpointSchema>;
211
-
212
- export const bedrockEndpointSchema = baseEndpointSchema.merge(
213
- z.object({
214
- availableRegions: z.array(z.string()).optional(),
215
- models: z.array(z.string()).optional(),
216
- inferenceProfiles: z.record(z.string(), z.string()).optional(),
217
- }),
218
- );
219
-
220
- const modelItemSchema = z.union([
221
- z.string(),
222
- z.object({
223
- name: z.string(),
224
- description: z.string().optional(),
225
- }),
226
- ]);
227
-
228
- export const assistantEndpointSchema = baseEndpointSchema.merge(
229
- z.object({
230
- /* assistants specific */
231
- disableBuilder: z.boolean().optional(),
232
- pollIntervalMs: z.number().optional(),
233
- timeoutMs: z.number().optional(),
234
- version: z.union([z.string(), z.number()]).default(2),
235
- supportedIds: z.array(z.string()).min(1).optional(),
236
- excludedIds: z.array(z.string()).min(1).optional(),
237
- privateAssistants: z.boolean().optional(),
238
- retrievalModels: z.array(z.string()).min(1).optional().default(defaultRetrievalModels),
239
- capabilities: z
240
- .array(z.nativeEnum(Capabilities))
241
- .optional()
242
- .default([
243
- Capabilities.code_interpreter,
244
- Capabilities.image_vision,
245
- Capabilities.retrieval,
246
- Capabilities.actions,
247
- Capabilities.tools,
248
- ]),
249
- /* general */
250
- apiKey: z.string().optional(),
251
- models: z
252
- .object({
253
- default: z.array(modelItemSchema).min(1),
254
- fetch: z.boolean().optional(),
255
- userIdQuery: z.boolean().optional(),
256
- })
257
- .optional(),
258
- headers: z.record(z.any()).optional(),
259
- }),
260
- );
261
-
262
- export type TAssistantEndpoint = z.infer<typeof assistantEndpointSchema>;
263
-
264
- export const defaultAgentCapabilities = [
265
- // Commented as requires latest Code Interpreter API
266
- // AgentCapabilities.programmatic_tools,
267
- AgentCapabilities.deferred_tools,
268
- AgentCapabilities.execute_code,
269
- AgentCapabilities.file_search,
270
- AgentCapabilities.web_search,
271
- AgentCapabilities.artifacts,
272
- AgentCapabilities.actions,
273
- AgentCapabilities.context,
274
- AgentCapabilities.tools,
275
- AgentCapabilities.chain,
276
- AgentCapabilities.ocr,
277
- ];
278
-
279
- export const agentsEndpointSchema = baseEndpointSchema
280
- .merge(
281
- z.object({
282
- /* agents specific */
283
- recursionLimit: z.number().optional(),
284
- disableBuilder: z.boolean().optional().default(false),
285
- maxRecursionLimit: z.number().optional(),
286
- maxCitations: z.number().min(1).max(50).optional().default(30),
287
- maxCitationsPerFile: z.number().min(1).max(10).optional().default(7),
288
- minRelevanceScore: z.number().min(0.0).max(1.0).optional().default(0.45),
289
- allowedProviders: z.array(z.union([z.string(), eModelEndpointSchema])).optional(),
290
- capabilities: z
291
- .array(z.nativeEnum(AgentCapabilities))
292
- .optional()
293
- .default(defaultAgentCapabilities),
294
- }),
295
- )
296
- .default({
297
- disableBuilder: false,
298
- capabilities: defaultAgentCapabilities,
299
- maxCitations: 30,
300
- maxCitationsPerFile: 7,
301
- minRelevanceScore: 0.45,
302
- });
303
-
304
- export type TAgentsEndpoint = z.infer<typeof agentsEndpointSchema>;
305
-
306
- export const endpointSchema = baseEndpointSchema.merge(
307
- z.object({
308
- name: z.string().refine((value) => !eModelEndpointSchema.safeParse(value).success, {
309
- message: `Value cannot be one of the default endpoint (EModelEndpoint) values: ${Object.values(
310
- EModelEndpoint,
311
- ).join(', ')}`,
312
- }),
313
- apiKey: z.string(),
314
- baseURL: z.string(),
315
- models: z.object({
316
- default: z.array(modelItemSchema).min(1),
317
- fetch: z.boolean().optional(),
318
- userIdQuery: z.boolean().optional(),
319
- }),
320
- summarize: z.boolean().optional(),
321
- summaryModel: z.string().optional(),
322
- iconURL: z.string().optional(),
323
- modelDisplayLabel: z.string().optional(),
324
- headers: z.record(z.any()).optional(),
325
- addParams: z.record(z.any()).optional(),
326
- dropParams: z.array(z.string()).optional(),
327
- customParams: z
328
- .object({
329
- defaultParamsEndpoint: z.string().default('custom'),
330
- paramDefinitions: z.array(z.record(z.any())).optional(),
331
- })
332
- .strict()
333
- .optional(),
334
- customOrder: z.number().optional(),
335
- directEndpoint: z.boolean().optional(),
336
- titleMessageRole: z.string().optional(),
337
- }),
338
- );
339
-
340
- export type TEndpoint = z.infer<typeof endpointSchema>;
341
-
342
- export const azureEndpointSchema = z
343
- .object({
344
- groups: azureGroupConfigsSchema,
345
- plugins: z.boolean().optional(),
346
- assistants: z.boolean().optional(),
347
- })
348
- .and(
349
- endpointSchema
350
- .pick({
351
- streamRate: true,
352
- titleConvo: true,
353
- titleMethod: true,
354
- titleModel: true,
355
- titlePrompt: true,
356
- titlePromptTemplate: true,
357
- summarize: true,
358
- summaryModel: true,
359
- customOrder: true,
360
- })
361
- .partial(),
362
- );
363
-
364
- export type TAzureConfig = Omit<z.infer<typeof azureEndpointSchema>, 'groups'> &
365
- TAzureConfigValidationResult;
366
-
367
- /**
368
- * Vertex AI model configuration - similar to Azure model config
369
- * Allows specifying deployment name for each model
370
- */
371
- export const vertexModelConfigSchema = z
372
- .object({
373
- /** The actual model ID/deployment name used by Vertex AI API */
374
- deploymentName: z.string().optional(),
375
- })
376
- .or(z.boolean());
377
-
378
- export type TVertexModelConfig = z.infer<typeof vertexModelConfigSchema>;
379
-
380
- /**
381
- * Vertex AI configuration schema for Anthropic models served via Google Cloud Vertex AI.
382
- * Similar to Azure configuration, this allows running Anthropic models through Google Cloud.
383
- */
384
- export const vertexAISchema = z.object({
385
- /** Enable Vertex AI mode for Anthropic (defaults to true when vertex config is present) */
386
- enabled: z.boolean().optional(),
387
- /** Google Cloud Project ID (optional - auto-detected from service key file if not provided) */
388
- projectId: z.string().optional(),
389
- /** Vertex AI region (e.g., 'us-east5', 'europe-west1') */
390
- region: z.string().default('us-east5'),
391
- /** Optional: Path to service account key file */
392
- serviceKeyFile: z.string().optional(),
393
- /** Optional: Default deployment name for all models (can be overridden per model) */
394
- deploymentName: z.string().optional(),
395
- /** Optional: Available models - can be string array or object with deploymentName mapping */
396
- models: z.union([z.array(z.string()), z.record(z.string(), vertexModelConfigSchema)]).optional(),
397
- });
398
-
399
- export type TVertexAISchema = z.infer<typeof vertexAISchema>;
400
-
401
- export type TVertexModelMap = Record<string, string>;
402
-
403
- /**
404
- * Validated Vertex AI configuration result
405
- */
406
- export type TVertexAIConfig = TVertexAISchema & {
407
- isValid: boolean;
408
- errors: string[];
409
- modelNames?: string[];
410
- modelDeploymentMap?: TVertexModelMap;
411
- };
412
-
413
- /**
414
- * Anthropic endpoint schema with optional Vertex AI configuration.
415
- * Extends baseEndpointSchema with Vertex AI support.
416
- */
417
- export const anthropicEndpointSchema = baseEndpointSchema.merge(
418
- z.object({
419
- /** Vertex AI configuration for running Anthropic models on Google Cloud */
420
- vertex: vertexAISchema.optional(),
421
- /** Optional: List of available models */
422
- models: z.array(z.string()).optional(),
423
- }),
424
- );
425
-
426
- export type TAnthropicEndpoint = z.infer<typeof anthropicEndpointSchema>;
427
-
428
- const ttsOpenaiSchema = z.object({
429
- url: z.string().optional(),
430
- apiKey: z.string(),
431
- model: z.string(),
432
- voices: z.array(z.string()),
433
- });
434
-
435
- const ttsAzureOpenAISchema = z.object({
436
- instanceName: z.string(),
437
- apiKey: z.string(),
438
- deploymentName: z.string(),
439
- apiVersion: z.string(),
440
- model: z.string(),
441
- voices: z.array(z.string()),
442
- });
443
-
444
- const ttsElevenLabsSchema = z.object({
445
- url: z.string().optional(),
446
- websocketUrl: z.string().optional(),
447
- apiKey: z.string(),
448
- model: z.string(),
449
- voices: z.array(z.string()),
450
- voice_settings: z
451
- .object({
452
- similarity_boost: z.number().optional(),
453
- stability: z.number().optional(),
454
- style: z.number().optional(),
455
- use_speaker_boost: z.boolean().optional(),
456
- })
457
- .optional(),
458
- pronunciation_dictionary_locators: z.array(z.string()).optional(),
459
- });
460
-
461
- const ttsLocalaiSchema = z.object({
462
- url: z.string(),
463
- apiKey: z.string().optional(),
464
- voices: z.array(z.string()),
465
- backend: z.string(),
466
- });
467
-
468
- const ttsSchema = z.object({
469
- openai: ttsOpenaiSchema.optional(),
470
- azureOpenAI: ttsAzureOpenAISchema.optional(),
471
- elevenlabs: ttsElevenLabsSchema.optional(),
472
- localai: ttsLocalaiSchema.optional(),
473
- });
474
-
475
- const sttOpenaiSchema = z.object({
476
- url: z.string().optional(),
477
- apiKey: z.string(),
478
- model: z.string(),
479
- });
480
-
481
- const sttAzureOpenAISchema = z.object({
482
- instanceName: z.string(),
483
- apiKey: z.string(),
484
- deploymentName: z.string(),
485
- apiVersion: z.string(),
486
- });
487
-
488
- const sttSchema = z.object({
489
- openai: sttOpenaiSchema.optional(),
490
- azureOpenAI: sttAzureOpenAISchema.optional(),
491
- });
492
-
493
- const speechTab = z
494
- .object({
495
- conversationMode: z.boolean().optional(),
496
- advancedMode: z.boolean().optional(),
497
- speechToText: z
498
- .boolean()
499
- .optional()
500
- .or(
501
- z.object({
502
- engineSTT: z.string().optional(),
503
- languageSTT: z.string().optional(),
504
- autoTranscribeAudio: z.boolean().optional(),
505
- decibelValue: z.number().optional(),
506
- autoSendText: z.number().optional(),
507
- }),
508
- )
509
- .optional(),
510
- textToSpeech: z
511
- .boolean()
512
- .optional()
513
- .or(
514
- z.object({
515
- engineTTS: z.string().optional(),
516
- voice: z.string().optional(),
517
- languageTTS: z.string().optional(),
518
- automaticPlayback: z.boolean().optional(),
519
- playbackRate: z.number().optional(),
520
- cacheTTS: z.boolean().optional(),
521
- }),
522
- )
523
- .optional(),
524
- })
525
- .optional();
526
-
527
- export enum RateLimitPrefix {
528
- FILE_UPLOAD = 'FILE_UPLOAD',
529
- IMPORT = 'IMPORT',
530
- TTS = 'TTS',
531
- STT = 'STT',
532
- }
533
-
534
- export const rateLimitSchema = z.object({
535
- fileUploads: z
536
- .object({
537
- ipMax: z.number().optional(),
538
- ipWindowInMinutes: z.number().optional(),
539
- userMax: z.number().optional(),
540
- userWindowInMinutes: z.number().optional(),
541
- })
542
- .optional(),
543
- conversationsImport: z
544
- .object({
545
- ipMax: z.number().optional(),
546
- ipWindowInMinutes: z.number().optional(),
547
- userMax: z.number().optional(),
548
- userWindowInMinutes: z.number().optional(),
549
- })
550
- .optional(),
551
- tts: z
552
- .object({
553
- ipMax: z.number().optional(),
554
- ipWindowInMinutes: z.number().optional(),
555
- userMax: z.number().optional(),
556
- userWindowInMinutes: z.number().optional(),
557
- })
558
- .optional(),
559
- stt: z
560
- .object({
561
- ipMax: z.number().optional(),
562
- ipWindowInMinutes: z.number().optional(),
563
- userMax: z.number().optional(),
564
- userWindowInMinutes: z.number().optional(),
565
- })
566
- .optional(),
567
- });
568
-
569
- export enum EImageOutputType {
570
- PNG = 'png',
571
- WEBP = 'webp',
572
- JPEG = 'jpeg',
573
- }
574
-
575
- const termsOfServiceSchema = z.object({
576
- externalUrl: z.string().optional(),
577
- openNewTab: z.boolean().optional(),
578
- modalAcceptance: z.boolean().optional(),
579
- modalTitle: z.string().optional(),
580
- modalContent: z.string().or(z.array(z.string())).optional(),
581
- });
582
-
583
- export type TTermsOfService = z.infer<typeof termsOfServiceSchema>;
584
-
585
- // Schema for localized string (either simple string or language-keyed object)
586
- const localizedStringSchema = z.union([z.string(), z.record(z.string())]);
587
- export type LocalizedString = z.infer<typeof localizedStringSchema>;
588
-
589
- const mcpServersSchema = z
590
- .object({
591
- placeholder: z.string().optional(),
592
- use: z.boolean().optional(),
593
- create: z.boolean().optional(),
594
- share: z.boolean().optional(),
595
- public: z.boolean().optional(),
596
- trustCheckbox: z
597
- .object({
598
- label: localizedStringSchema.optional(),
599
- subLabel: localizedStringSchema.optional(),
600
- })
601
- .optional(),
602
- })
603
- .optional();
604
-
605
- export type TMcpServersConfig = z.infer<typeof mcpServersSchema>;
606
-
607
- export const interfaceSchema = z
608
- .object({
609
- privacyPolicy: z
610
- .object({
611
- externalUrl: z.string().optional(),
612
- openNewTab: z.boolean().optional(),
613
- })
614
- .optional(),
615
- termsOfService: termsOfServiceSchema.optional(),
616
- customWelcome: z.string().optional(),
617
- mcpServers: mcpServersSchema.optional(),
618
- endpointsMenu: z.boolean().optional(),
619
- modelSelect: z.boolean().optional(),
620
- parameters: z.boolean().optional(),
621
- sidePanel: z.boolean().optional(),
622
- multiConvo: z.boolean().optional(),
623
- bookmarks: z.boolean().optional(),
624
- memories: z.boolean().optional(),
625
- presets: z.boolean().optional(),
626
- prompts: z
627
- .union([
628
- z.boolean(),
629
- z.object({
630
- use: z.boolean().optional(),
631
- create: z.boolean().optional(),
632
- share: z.boolean().optional(),
633
- public: z.boolean().optional(),
634
- }),
635
- ])
636
- .optional(),
637
- agents: z
638
- .union([
639
- z.boolean(),
640
- z.object({
641
- use: z.boolean().optional(),
642
- create: z.boolean().optional(),
643
- share: z.boolean().optional(),
644
- public: z.boolean().optional(),
645
- }),
646
- ])
647
- .optional(),
648
- temporaryChat: z.boolean().optional(),
649
- temporaryChatRetention: z.number().min(1).max(8760).optional(),
650
- runCode: z.boolean().optional(),
651
- webSearch: z.boolean().optional(),
652
- peoplePicker: z
653
- .object({
654
- users: z.boolean().optional(),
655
- groups: z.boolean().optional(),
656
- roles: z.boolean().optional(),
657
- })
658
- .optional(),
659
- marketplace: z
660
- .object({
661
- use: z.boolean().optional(),
662
- })
663
- .optional(),
664
- fileSearch: z.boolean().optional(),
665
- fileCitations: z.boolean().optional(),
666
- remoteAgents: z
667
- .object({
668
- use: z.boolean().optional(),
669
- create: z.boolean().optional(),
670
- share: z.boolean().optional(),
671
- public: z.boolean().optional(),
672
- })
673
- .optional(),
674
- })
675
- .default({
676
- endpointsMenu: true,
677
- modelSelect: true,
678
- parameters: true,
679
- sidePanel: true,
680
- presets: true,
681
- multiConvo: true,
682
- bookmarks: true,
683
- memories: true,
684
- prompts: {
685
- use: true,
686
- create: true,
687
- share: false,
688
- public: false,
689
- },
690
- agents: {
691
- use: true,
692
- create: true,
693
- share: false,
694
- public: false,
695
- },
696
- temporaryChat: true,
697
- runCode: true,
698
- webSearch: true,
699
- peoplePicker: {
700
- users: true,
701
- groups: true,
702
- roles: true,
703
- },
704
- marketplace: {
705
- use: false,
706
- },
707
- mcpServers: {
708
- use: true,
709
- create: true,
710
- share: false,
711
- public: false,
712
- },
713
- fileSearch: true,
714
- fileCitations: true,
715
- remoteAgents: {
716
- use: false,
717
- create: false,
718
- share: false,
719
- public: false,
720
- },
721
- });
722
-
723
- export type TInterfaceConfig = z.infer<typeof interfaceSchema>;
724
- export type TBalanceConfig = z.infer<typeof balanceSchema>;
725
- export type TTransactionsConfig = z.infer<typeof transactionsSchema>;
726
-
727
- export const turnstileOptionsSchema = z
728
- .object({
729
- language: z.string().default('auto'),
730
- size: z.enum(['normal', 'compact', 'flexible', 'invisible']).default('normal'),
731
- })
732
- .default({
733
- language: 'auto',
734
- size: 'normal',
735
- });
736
-
737
- export const turnstileSchema = z.object({
738
- siteKey: z.string(),
739
- options: turnstileOptionsSchema.optional(),
740
- });
741
-
742
- export type TTurnstileConfig = z.infer<typeof turnstileSchema>;
743
-
744
- export type TStartupConfig = {
745
- appTitle: string;
746
- socialLogins?: string[];
747
- interface?: TInterfaceConfig;
748
- turnstile?: TTurnstileConfig;
749
- balance?: TBalanceConfig;
750
- transactions?: TTransactionsConfig;
751
- discordLoginEnabled: boolean;
752
- facebookLoginEnabled: boolean;
753
- githubLoginEnabled: boolean;
754
- googleLoginEnabled: boolean;
755
- openidLoginEnabled: boolean;
756
- appleLoginEnabled: boolean;
757
- samlLoginEnabled: boolean;
758
- openidLabel: string;
759
- openidImageUrl: string;
760
- openidAutoRedirect: boolean;
761
- samlLabel: string;
762
- samlImageUrl: string;
763
- /** LDAP Auth Configuration */
764
- ldap?: {
765
- /** LDAP enabled */
766
- enabled: boolean;
767
- /** Whether LDAP uses username vs. email */
768
- username?: boolean;
769
- };
770
- serverDomain: string;
771
- emailLoginEnabled: boolean;
772
- registrationEnabled: boolean;
773
- socialLoginEnabled: boolean;
774
- passwordResetEnabled: boolean;
775
- emailEnabled: boolean;
776
- showBirthdayIcon: boolean;
777
- helpAndFaqURL: string;
778
- customFooter?: string;
779
- modelSpecs?: TSpecsConfig;
780
- modelDescriptions?: Record<string, Record<string, string>>;
781
- sharedLinksEnabled: boolean;
782
- publicSharedLinksEnabled: boolean;
783
- analyticsGtmId?: string;
784
- instanceProjectId: string;
785
- bundlerURL?: string;
786
- staticBundlerURL?: string;
787
- sharePointFilePickerEnabled?: boolean;
788
- sharePointBaseUrl?: string;
789
- sharePointPickerGraphScope?: string;
790
- sharePointPickerSharePointScope?: string;
791
- openidReuseTokens?: boolean;
792
- minPasswordLength?: number;
793
- webSearch?: {
794
- searchProvider?: SearchProviders;
795
- scraperProvider?: ScraperProviders;
796
- rerankerType?: RerankerTypes;
797
- };
798
- mcpServers?: Record<
799
- string,
800
- {
801
- customUserVars: Record<
802
- string,
803
- {
804
- title: string;
805
- description: string;
806
- }
807
- >;
808
- chatMenu?: boolean;
809
- isOAuth?: boolean;
810
- startup?: boolean;
811
- iconPath?: string;
812
- }
813
- >;
814
- mcpPlaceholder?: string;
815
- conversationImportMaxFileSize?: number;
816
- };
817
-
818
- export enum OCRStrategy {
819
- MISTRAL_OCR = 'mistral_ocr',
820
- CUSTOM_OCR = 'custom_ocr',
821
- AZURE_MISTRAL_OCR = 'azure_mistral_ocr',
822
- VERTEXAI_MISTRAL_OCR = 'vertexai_mistral_ocr',
823
- DOCUMENT_PARSER = 'document_parser',
824
- }
825
-
826
- export enum SearchCategories {
827
- PROVIDERS = 'providers',
828
- SCRAPERS = 'scrapers',
829
- RERANKERS = 'rerankers',
830
- }
831
-
832
- export enum SearchProviders {
833
- SERPER = 'serper',
834
- SEARXNG = 'searxng',
835
- }
836
-
837
- export enum ScraperProviders {
838
- FIRECRAWL = 'firecrawl',
839
- SERPER = 'serper',
840
- }
841
-
842
- export enum RerankerTypes {
843
- JINA = 'jina',
844
- COHERE = 'cohere',
845
- }
846
-
847
- export enum SafeSearchTypes {
848
- OFF = 0,
849
- MODERATE = 1,
850
- STRICT = 2,
851
- }
852
-
853
- export const webSearchSchema = z.object({
854
- serperApiKey: z.string().optional().default('${SERPER_API_KEY}'),
855
- searxngInstanceUrl: z.string().optional().default('${SEARXNG_INSTANCE_URL}'),
856
- searxngApiKey: z.string().optional().default('${SEARXNG_API_KEY}'),
857
- firecrawlApiKey: z.string().optional().default('${FIRECRAWL_API_KEY}'),
858
- firecrawlApiUrl: z.string().optional().default('${FIRECRAWL_API_URL}'),
859
- firecrawlVersion: z.string().optional().default('${FIRECRAWL_VERSION}'),
860
- jinaApiKey: z.string().optional().default('${JINA_API_KEY}'),
861
- jinaApiUrl: z.string().optional().default('${JINA_API_URL}'),
862
- cohereApiKey: z.string().optional().default('${COHERE_API_KEY}'),
863
- searchProvider: z.nativeEnum(SearchProviders).optional(),
864
- scraperProvider: z.nativeEnum(ScraperProviders).optional(),
865
- rerankerType: z.nativeEnum(RerankerTypes).optional(),
866
- scraperTimeout: z.number().optional(),
867
- safeSearch: z.nativeEnum(SafeSearchTypes).default(SafeSearchTypes.MODERATE),
868
- firecrawlOptions: z
869
- .object({
870
- formats: z.array(z.string()).optional(),
871
- includeTags: z.array(z.string()).optional(),
872
- excludeTags: z.array(z.string()).optional(),
873
- headers: z.record(z.string()).optional(),
874
- waitFor: z.number().optional(),
875
- timeout: z.number().optional(),
876
- maxAge: z.number().optional(),
877
- mobile: z.boolean().optional(),
878
- skipTlsVerification: z.boolean().optional(),
879
- blockAds: z.boolean().optional(),
880
- removeBase64Images: z.boolean().optional(),
881
- parsePDF: z.boolean().optional(),
882
- storeInCache: z.boolean().optional(),
883
- zeroDataRetention: z.boolean().optional(),
884
- location: z
885
- .object({
886
- country: z.string().optional(),
887
- languages: z.array(z.string()).optional(),
888
- })
889
- .optional(),
890
- onlyMainContent: z.boolean().optional(),
891
- changeTrackingOptions: z
892
- .object({
893
- modes: z.array(z.string()).optional(),
894
- schema: z.record(z.unknown()).optional(),
895
- prompt: z.string().optional(),
896
- tag: z.string().nullable().optional(),
897
- })
898
- .optional(),
899
- })
900
- .optional(),
901
- });
902
-
903
- export type TWebSearchConfig = DeepPartial<z.infer<typeof webSearchSchema>>;
904
-
905
- export const ocrSchema = z.object({
906
- mistralModel: z.string().optional(),
907
- apiKey: z.string().optional().default('${OCR_API_KEY}'),
908
- baseURL: z.string().optional().default('${OCR_BASEURL}'),
909
- strategy: z.nativeEnum(OCRStrategy).default(OCRStrategy.MISTRAL_OCR),
910
- });
911
-
912
- export const balanceSchema = z.object({
913
- enabled: z.boolean().optional().default(false),
914
- startBalance: z.number().optional().default(20000),
915
- autoRefillEnabled: z.boolean().optional().default(false),
916
- refillIntervalValue: z.number().optional().default(30),
917
- refillIntervalUnit: z
918
- .enum(['seconds', 'minutes', 'hours', 'days', 'weeks', 'months'])
919
- .optional()
920
- .default('days'),
921
- refillAmount: z.number().optional().default(10000),
922
- });
923
-
924
- export const transactionsSchema = z.object({
925
- enabled: z.boolean().optional().default(true),
926
- });
927
-
928
- export const memorySchema = z.object({
929
- disabled: z.boolean().optional(),
930
- validKeys: z.array(z.string()).optional(),
931
- tokenLimit: z.number().optional(),
932
- charLimit: z.number().optional().default(10000),
933
- personalize: z.boolean().default(true),
934
- messageWindowSize: z.number().optional().default(5),
935
- agent: z
936
- .union([
937
- z.object({
938
- id: z.string(),
939
- }),
940
- z.object({
941
- provider: z.string(),
942
- model: z.string(),
943
- instructions: z.string().optional(),
944
- model_parameters: z.record(z.any()).optional(),
945
- }),
946
- ])
947
- .optional(),
948
- });
949
-
950
- export type TMemoryConfig = DeepPartial<z.infer<typeof memorySchema>>;
951
-
952
- const customEndpointsSchema = z.array(endpointSchema.partial()).optional();
953
-
954
- export const configSchema = z.object({
955
- version: z.string(),
956
- cache: z.boolean().default(true),
957
- ocr: ocrSchema.optional(),
958
- webSearch: webSearchSchema.optional(),
959
- memory: memorySchema.optional(),
960
- secureImageLinks: z.boolean().optional(),
961
- imageOutputType: z.nativeEnum(EImageOutputType).default(EImageOutputType.PNG),
962
- includedTools: z.array(z.string()).optional(),
963
- filteredTools: z.array(z.string()).optional(),
964
- mcpServers: MCPServersSchema.optional(),
965
- mcpSettings: z
966
- .object({
967
- allowedDomains: z.array(z.string()).optional(),
968
- })
969
- .optional(),
970
- interface: interfaceSchema,
971
- turnstile: turnstileSchema.optional(),
972
- fileStrategy: fileSourceSchema.default(FileSources.local),
973
- fileStrategies: fileStrategiesSchema,
974
- actions: z
975
- .object({
976
- allowedDomains: z.array(z.string()).optional(),
977
- })
978
- .optional(),
979
- registration: z
980
- .object({
981
- socialLogins: z.array(z.string()).optional(),
982
- allowedDomains: z.array(z.string()).optional(),
983
- })
984
- .default({ socialLogins: defaultSocialLogins }),
985
- balance: balanceSchema.optional(),
986
- transactions: transactionsSchema.optional(),
987
- speech: z
988
- .object({
989
- tts: ttsSchema.optional(),
990
- stt: sttSchema.optional(),
991
- speechTab: speechTab.optional(),
992
- })
993
- .optional(),
994
- rateLimits: rateLimitSchema.optional(),
995
- fileConfig: fileConfigSchema.optional(),
996
- modelSpecs: specsConfigSchema.optional(),
997
- endpoints: z
998
- .object({
999
- all: baseEndpointSchema.optional(),
1000
- [EModelEndpoint.openAI]: baseEndpointSchema.optional(),
1001
- [EModelEndpoint.google]: baseEndpointSchema.optional(),
1002
- [EModelEndpoint.anthropic]: anthropicEndpointSchema.optional(),
1003
- [EModelEndpoint.azureOpenAI]: azureEndpointSchema.optional(),
1004
- [EModelEndpoint.azureAssistants]: assistantEndpointSchema.optional(),
1005
- [EModelEndpoint.assistants]: assistantEndpointSchema.optional(),
1006
- [EModelEndpoint.agents]: agentsEndpointSchema.optional(),
1007
- [EModelEndpoint.custom]: customEndpointsSchema.optional(),
1008
- [EModelEndpoint.bedrock]: bedrockEndpointSchema.optional(),
1009
- })
1010
- .strict()
1011
- .refine((data) => Object.keys(data).length > 0, {
1012
- message: 'At least one `endpoints` field must be provided.',
1013
- })
1014
- .optional(),
1015
- });
1016
-
1017
- /**
1018
- * Recursively makes all properties of T optional, including nested objects.
1019
- * Handles arrays, primitives, functions, and Date objects correctly.
1020
- */
1021
- export type DeepPartial<T> = T extends (infer U)[]
1022
- ? DeepPartial<U>[]
1023
- : T extends ReadonlyArray<infer U>
1024
- ? ReadonlyArray<DeepPartial<U>>
1025
- : // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
1026
- T extends Function
1027
- ? T
1028
- : T extends Date
1029
- ? T
1030
- : T extends object
1031
- ? {
1032
- [P in keyof T]?: DeepPartial<T[P]>;
1033
- }
1034
- : T;
1035
-
1036
- export const getConfigDefaults = () => getSchemaDefaults(configSchema);
1037
- export type TCustomConfig = DeepPartial<z.infer<typeof configSchema>>;
1038
- export type TCustomEndpoints = z.infer<typeof customEndpointsSchema>;
1039
-
1040
- export type TProviderSchema =
1041
- | z.infer<typeof ttsOpenaiSchema>
1042
- | z.infer<typeof ttsElevenLabsSchema>
1043
- | z.infer<typeof ttsLocalaiSchema>
1044
- | undefined;
1045
-
1046
- export enum KnownEndpoints {
1047
- anyscale = 'anyscale',
1048
- apipie = 'apipie',
1049
- cohere = 'cohere',
1050
- fireworks = 'fireworks',
1051
- deepseek = 'deepseek',
1052
- moonshot = 'moonshot',
1053
- groq = 'groq',
1054
- helicone = 'helicone',
1055
- huggingface = 'huggingface',
1056
- mistral = 'mistral',
1057
- mlx = 'mlx',
1058
- ollama = 'ollama',
1059
- openrouter = 'openrouter',
1060
- perplexity = 'perplexity',
1061
- shuttleai = 'shuttleai',
1062
- 'together.ai' = 'together.ai',
1063
- unify = 'unify',
1064
- vercel = 'vercel',
1065
- xai = 'xai',
1066
- }
1067
-
1068
- export enum FetchTokenConfig {
1069
- openrouter = KnownEndpoints.openrouter,
1070
- helicone = KnownEndpoints.helicone,
1071
- }
1072
-
1073
- export const defaultEndpoints: EModelEndpoint[] = [
1074
- EModelEndpoint.openAI,
1075
- EModelEndpoint.assistants,
1076
- EModelEndpoint.azureAssistants,
1077
- EModelEndpoint.azureOpenAI,
1078
- EModelEndpoint.agents,
1079
- EModelEndpoint.google,
1080
- EModelEndpoint.anthropic,
1081
- EModelEndpoint.custom,
1082
- EModelEndpoint.bedrock,
1083
- ];
1084
-
1085
- export const alternateName = {
1086
- [EModelEndpoint.openAI]: 'OpenAI',
1087
- [EModelEndpoint.assistants]: 'Assistants',
1088
- [EModelEndpoint.agents]: 'My Agents',
1089
- [EModelEndpoint.azureAssistants]: 'Azure Assistants',
1090
- [EModelEndpoint.azureOpenAI]: 'Azure OpenAI',
1091
- [EModelEndpoint.google]: 'Google',
1092
- [EModelEndpoint.anthropic]: 'Anthropic',
1093
- [EModelEndpoint.custom]: 'Custom',
1094
- [EModelEndpoint.bedrock]: 'AWS Bedrock',
1095
- [KnownEndpoints.ollama]: 'Ollama',
1096
- [KnownEndpoints.deepseek]: 'DeepSeek',
1097
- [KnownEndpoints.moonshot]: 'Moonshot',
1098
- [KnownEndpoints.xai]: 'xAI',
1099
- [KnownEndpoints.vercel]: 'Vercel',
1100
- [KnownEndpoints.helicone]: 'Helicone',
1101
- };
1102
-
1103
- const sharedOpenAIModels = [
1104
- 'gpt-5.4',
1105
- // TODO: gpt-5.4-thinking may have separate reasoning token pricing — verify before release
1106
- 'gpt-5.4-thinking',
1107
- 'gpt-5.4-pro',
1108
- 'gpt-5.1',
1109
- 'gpt-5.1-chat-latest',
1110
- 'gpt-5.1-codex',
1111
- 'gpt-5.1-codex-mini',
1112
- 'gpt-5',
1113
- 'gpt-5-mini',
1114
- 'gpt-5-nano',
1115
- 'gpt-5-chat-latest',
1116
- 'gpt-4.1',
1117
- 'gpt-4.1-mini',
1118
- 'gpt-4.1-nano',
1119
- 'gpt-4o-mini',
1120
- 'gpt-4o',
1121
- 'gpt-4.5-preview',
1122
- 'gpt-4.5-preview-2025-02-27',
1123
- 'gpt-3.5-turbo',
1124
- 'gpt-3.5-turbo-0125',
1125
- 'gpt-4-turbo',
1126
- 'gpt-4-turbo-2024-04-09',
1127
- 'gpt-4-0125-preview',
1128
- 'gpt-4-turbo-preview',
1129
- 'gpt-4-1106-preview',
1130
- 'gpt-3.5-turbo-1106',
1131
- 'gpt-3.5-turbo-16k-0613',
1132
- 'gpt-3.5-turbo-16k',
1133
- 'gpt-4',
1134
- 'gpt-4-0314',
1135
- 'gpt-4-32k-0314',
1136
- 'gpt-4-0613',
1137
- 'gpt-3.5-turbo-0613',
1138
- ];
1139
-
1140
- const sharedAnthropicModels = [
1141
- 'claude-sonnet-4-6',
1142
- 'claude-opus-4-6',
1143
- 'claude-sonnet-4-5',
1144
- 'claude-sonnet-4-5-20250929',
1145
- 'claude-haiku-4-5',
1146
- 'claude-haiku-4-5-20251001',
1147
- 'claude-opus-4-1',
1148
- 'claude-opus-4-1-20250805',
1149
- 'claude-opus-4-5',
1150
- 'claude-sonnet-4-20250514',
1151
- 'claude-sonnet-4-0',
1152
- 'claude-opus-4-20250514',
1153
- 'claude-opus-4-0',
1154
- 'claude-3-7-sonnet-latest',
1155
- 'claude-3-7-sonnet-20250219',
1156
- 'claude-3-5-haiku-20241022',
1157
- 'claude-3-5-sonnet-20241022',
1158
- 'claude-3-5-sonnet-20240620',
1159
- 'claude-3-5-sonnet-latest',
1160
- ];
1161
-
1162
- export const bedrockModels = [
1163
- 'anthropic.claude-sonnet-4-6',
1164
- 'anthropic.claude-opus-4-6-v1',
1165
- 'anthropic.claude-sonnet-4-5-20250929-v1:0',
1166
- 'anthropic.claude-haiku-4-5-20251001-v1:0',
1167
- 'anthropic.claude-opus-4-1-20250805-v1:0',
1168
- 'anthropic.claude-3-5-sonnet-20241022-v2:0',
1169
- 'anthropic.claude-3-5-sonnet-20240620-v1:0',
1170
- 'anthropic.claude-3-5-haiku-20241022-v1:0',
1171
- // 'cohere.command-text-v14', // no conversation history
1172
- // 'cohere.command-light-text-v14', // no conversation history
1173
- 'cohere.command-r-v1:0',
1174
- 'cohere.command-r-plus-v1:0',
1175
- 'meta.llama2-13b-chat-v1',
1176
- 'meta.llama2-70b-chat-v1',
1177
- 'meta.llama3-8b-instruct-v1:0',
1178
- 'meta.llama3-70b-instruct-v1:0',
1179
- 'meta.llama3-1-8b-instruct-v1:0',
1180
- 'meta.llama3-1-70b-instruct-v1:0',
1181
- 'meta.llama3-1-405b-instruct-v1:0',
1182
- 'mistral.mistral-7b-instruct-v0:2',
1183
- 'mistral.mixtral-8x7b-instruct-v0:1',
1184
- 'mistral.mistral-large-2402-v1:0',
1185
- 'mistral.mistral-large-2407-v1:0',
1186
- 'mistral.mistral-small-2402-v1:0',
1187
- 'ai21.jamba-instruct-v1:0',
1188
- // 'ai21.j2-mid-v1', // no streaming
1189
- // 'ai21.j2-ultra-v1', no conversation history
1190
- 'amazon.titan-text-lite-v1',
1191
- 'amazon.titan-text-express-v1',
1192
- 'amazon.titan-text-premier-v1:0',
1193
- ];
1194
-
1195
- export const defaultModels = {
1196
- [EModelEndpoint.azureAssistants]: sharedOpenAIModels,
1197
- [EModelEndpoint.assistants]: [...sharedOpenAIModels, 'chatgpt-4o-latest'],
1198
- [EModelEndpoint.agents]: sharedOpenAIModels, // TODO: Add agent models (agentsModels)
1199
- [EModelEndpoint.google]: [
1200
- // Gemini 3.1 Models
1201
- 'gemini-3.1-pro-preview',
1202
- 'gemini-3.1-pro-preview-customtools',
1203
- 'gemini-3.1-flash-lite-preview',
1204
- // Gemini 3 Models
1205
- 'gemini-3-pro-preview',
1206
- 'gemini-3-flash-preview',
1207
- // Gemini 2.5 Models
1208
- 'gemini-2.5-pro',
1209
- 'gemini-2.5-flash',
1210
- 'gemini-2.5-flash-lite',
1211
- // Gemini 2.0 Models
1212
- 'gemini-2.0-flash-001',
1213
- 'gemini-2.0-flash-lite',
1214
- ],
1215
- [EModelEndpoint.anthropic]: sharedAnthropicModels,
1216
- [EModelEndpoint.openAI]: [
1217
- ...sharedOpenAIModels,
1218
- 'chatgpt-4o-latest',
1219
- 'gpt-4-vision-preview',
1220
- 'gpt-3.5-turbo-instruct-0914',
1221
- 'gpt-3.5-turbo-instruct',
1222
- ],
1223
- [EModelEndpoint.bedrock]: bedrockModels,
1224
- };
1225
-
1226
- const fitlerAssistantModels = (str: string) => {
1227
- return /gpt-4|gpt-3\\.5/i.test(str) && !/vision|instruct/i.test(str);
1228
- };
1229
-
1230
- const openAIModels = defaultModels[EModelEndpoint.openAI];
1231
-
1232
- export const initialModelsConfig: TModelsConfig = {
1233
- initial: [],
1234
- [EModelEndpoint.openAI]: openAIModels,
1235
- [EModelEndpoint.assistants]: openAIModels.filter(fitlerAssistantModels),
1236
- [EModelEndpoint.agents]: openAIModels, // TODO: Add agent models (agentsModels)
1237
- [EModelEndpoint.azureOpenAI]: openAIModels,
1238
- [EModelEndpoint.google]: defaultModels[EModelEndpoint.google],
1239
- [EModelEndpoint.anthropic]: defaultModels[EModelEndpoint.anthropic],
1240
- [EModelEndpoint.bedrock]: defaultModels[EModelEndpoint.bedrock],
1241
- };
1242
-
1243
- export const EndpointURLs = {
1244
- [EModelEndpoint.assistants]: `${apiBaseUrl()}/api/assistants/v2/chat`,
1245
- [EModelEndpoint.azureAssistants]: `${apiBaseUrl()}/api/assistants/v1/chat`,
1246
- [EModelEndpoint.agents]: `${apiBaseUrl()}/api/${EModelEndpoint.agents}/chat`,
1247
- } as const;
1248
-
1249
- export const modularEndpoints = new Set<EModelEndpoint | string>([
1250
- EModelEndpoint.anthropic,
1251
- EModelEndpoint.google,
1252
- EModelEndpoint.openAI,
1253
- EModelEndpoint.azureOpenAI,
1254
- EModelEndpoint.custom,
1255
- EModelEndpoint.agents,
1256
- EModelEndpoint.bedrock,
1257
- ]);
1258
-
1259
- export const supportsBalanceCheck = {
1260
- [EModelEndpoint.custom]: true,
1261
- [EModelEndpoint.openAI]: true,
1262
- [EModelEndpoint.anthropic]: true,
1263
- [EModelEndpoint.assistants]: true,
1264
- [EModelEndpoint.agents]: true,
1265
- [EModelEndpoint.azureAssistants]: true,
1266
- [EModelEndpoint.azureOpenAI]: true,
1267
- [EModelEndpoint.bedrock]: true,
1268
- [EModelEndpoint.google]: true,
1269
- };
1270
-
1271
- export const visionModels = [
1272
- 'qwen-vl',
1273
- 'grok-vision',
1274
- 'grok-2-vision',
1275
- 'grok-3',
1276
- 'gpt-4o-mini',
1277
- 'gpt-4o',
1278
- 'gpt-4-turbo',
1279
- 'gpt-4-vision',
1280
- 'o4-mini',
1281
- 'o3',
1282
- 'o1',
1283
- 'gpt-5',
1284
- 'gpt-4.1',
1285
- 'gpt-4.5',
1286
- 'llava',
1287
- 'llava-13b',
1288
- 'gemini-pro-vision',
1289
- 'claude-3',
1290
- 'gemma',
1291
- 'gemini-exp',
1292
- 'gemini-1.5',
1293
- 'gemini-2',
1294
- 'gemini-2.5',
1295
- 'gemini-3',
1296
- 'moondream',
1297
- 'llama3.2-vision',
1298
- 'llama-3.2-11b-vision',
1299
- 'llama-3-2-11b-vision',
1300
- 'llama-3.2-90b-vision',
1301
- 'llama-3-2-90b-vision',
1302
- 'llama-4',
1303
- 'claude-opus-4',
1304
- 'claude-sonnet-4',
1305
- 'claude-haiku-4',
1306
- ];
1307
- export enum VisionModes {
1308
- generative = 'generative',
1309
- agents = 'agents',
1310
- }
1311
-
1312
- export function validateVisionModel({
1313
- model,
1314
- additionalModels = [],
1315
- availableModels,
1316
- }: {
1317
- model: string;
1318
- additionalModels?: string[];
1319
- availableModels?: string[];
1320
- }) {
1321
- if (!model) {
1322
- return false;
1323
- }
1324
-
1325
- if (model.includes('gpt-4-turbo-preview') || model.includes('o1-mini')) {
1326
- return false;
1327
- }
1328
-
1329
- if (availableModels && !availableModels.includes(model)) {
1330
- return false;
1331
- }
1332
-
1333
- return visionModels.concat(additionalModels).some((visionModel) => model.includes(visionModel));
1334
- }
1335
-
1336
- export const imageGenTools = new Set([
1337
- 'dalle',
1338
- 'dall-e',
1339
- 'stable-diffusion',
1340
- 'flux',
1341
- 'gemini_image_gen',
1342
- ]);
1343
-
1344
- /**
1345
- * Enum for collections using infinite queries
1346
- */
1347
- export enum InfiniteCollections {
1348
- /**
1349
- * Collection for Prompt Groups
1350
- */
1351
- PROMPT_GROUPS = 'promptGroups',
1352
- /**
1353
- * Collection for Shared Links
1354
- */
1355
- SHARED_LINKS = 'sharedLinks',
1356
- }
1357
-
1358
- /**
1359
- * Enum for time intervals
1360
- */
1361
- export enum Time {
1362
- ONE_DAY = 86400000,
1363
- TWELVE_HOURS = 43200000,
1364
- ONE_HOUR = 3600000,
1365
- THIRTY_MINUTES = 1800000,
1366
- TEN_MINUTES = 600000,
1367
- FIVE_MINUTES = 300000,
1368
- THREE_MINUTES = 180000,
1369
- TWO_MINUTES = 120000,
1370
- ONE_MINUTE = 60000,
1371
- THIRTY_SECONDS = 30000,
1372
- }
1373
-
1374
- /**
1375
- * Enum for cache keys.
1376
- */
1377
- export enum CacheKeys {
1378
- /**
1379
- * Key for the config store namespace.
1380
- */
1381
- CONFIG_STORE = 'CONFIG_STORE',
1382
- /**
1383
- * Key for the tool cache namespace (plugins, MCP tools, tool definitions).
1384
- */
1385
- TOOL_CACHE = 'TOOL_CACHE',
1386
- /**
1387
- * Key for the roles cache.
1388
- */
1389
- ROLES = 'ROLES',
1390
- /**
1391
- * Key for the title generation cache.
1392
- */
1393
- GEN_TITLE = 'GEN_TITLE',
1394
- /**
1395
- * Key for the tools cache.
1396
- */
1397
- TOOLS = 'TOOLS',
1398
- /**
1399
- * Key for the model config cache.
1400
- */
1401
- MODELS_CONFIG = 'MODELS_CONFIG',
1402
- /**
1403
- * Key for the model queries cache.
1404
- */
1405
- MODEL_QUERIES = 'MODEL_QUERIES',
1406
- /**
1407
- * Key for the default startup config cache.
1408
- */
1409
- STARTUP_CONFIG = 'STARTUP_CONFIG',
1410
- /**
1411
- * Key for the default endpoint config cache.
1412
- */
1413
- ENDPOINT_CONFIG = 'ENDPOINT_CONFIG',
1414
- /**
1415
- * Key for accessing the model token config cache.
1416
- */
1417
- TOKEN_CONFIG = 'TOKEN_CONFIG',
1418
- /**
1419
- * Key for the app config namespace.
1420
- */
1421
- APP_CONFIG = 'APP_CONFIG',
1422
- /**
1423
- * Key for accessing Abort Keys
1424
- */
1425
- ABORT_KEYS = 'ABORT_KEYS',
1426
- /**
1427
- * Key for the bans cache.
1428
- */
1429
- BANS = 'BANS',
1430
- /**
1431
- * Key for the encoded domains cache.
1432
- * Used by Azure OpenAI Assistants.
1433
- */
1434
- ENCODED_DOMAINS = 'ENCODED_DOMAINS',
1435
- /**
1436
- * Key for the cached audio run Ids.
1437
- */
1438
- AUDIO_RUNS = 'AUDIO_RUNS',
1439
- /**
1440
- * Key for in-progress messages.
1441
- */
1442
- MESSAGES = 'MESSAGES',
1443
- /**
1444
- * Key for in-progress flow states.
1445
- */
1446
- FLOWS = 'FLOWS',
1447
- /**
1448
- * Key for pending chat requests (concurrency check)
1449
- */
1450
- PENDING_REQ = 'PENDING_REQ',
1451
- /**
1452
- * Key for s3 check intervals per user
1453
- */
1454
- S3_EXPIRY_INTERVAL = 'S3_EXPIRY_INTERVAL',
1455
- /**
1456
- * key for open id exchanged tokens
1457
- */
1458
- OPENID_EXCHANGED_TOKENS = 'OPENID_EXCHANGED_TOKENS',
1459
- /**
1460
- * Key for OpenID session.
1461
- */
1462
- OPENID_SESSION = 'OPENID_SESSION',
1463
- /**
1464
- * Key for SAML session.
1465
- */
1466
- SAML_SESSION = 'SAML_SESSION',
1467
- /**
1468
- * Key for admin panel OAuth exchange codes (one-time-use, short TTL).
1469
- */
1470
- ADMIN_OAUTH_EXCHANGE = 'ADMIN_OAUTH_EXCHANGE',
1471
- }
1472
-
1473
- /**
1474
- * Enum for violation types, used to identify, log, and cache violations.
1475
- */
1476
- export enum ViolationTypes {
1477
- /**
1478
- * File Upload Violations (exceeding limit).
1479
- */
1480
- FILE_UPLOAD_LIMIT = 'file_upload_limit',
1481
- /**
1482
- * Illegal Model Request (not available).
1483
- */
1484
- ILLEGAL_MODEL_REQUEST = 'illegal_model_request',
1485
- /**
1486
- * Token Limit Violation.
1487
- */
1488
- TOKEN_BALANCE = 'token_balance',
1489
- /**
1490
- * An issued ban.
1491
- */
1492
- BAN = 'ban',
1493
- /**
1494
- * TTS Request Limit Violation.
1495
- */
1496
- TTS_LIMIT = 'tts_limit',
1497
- /**
1498
- * STT Request Limit Violation.
1499
- */
1500
- STT_LIMIT = 'stt_limit',
1501
- /**
1502
- * Reset Password Limit Violation.
1503
- */
1504
- RESET_PASSWORD_LIMIT = 'reset_password_limit',
1505
- /**
1506
- * Verify Email Limit Violation.
1507
- */
1508
- VERIFY_EMAIL_LIMIT = 'verify_email_limit',
1509
- /**
1510
- * Verify Conversation Access violation.
1511
- */
1512
- CONVO_ACCESS = 'convo_access',
1513
- /**
1514
- * Tool Call Limit Violation.
1515
- */
1516
- TOOL_CALL_LIMIT = 'tool_call_limit',
1517
- /**
1518
- * General violation (catch-all).
1519
- */
1520
- GENERAL = 'general',
1521
- /**
1522
- * Login attempt violations.
1523
- */
1524
- LOGINS = 'logins',
1525
- /**
1526
- * Concurrent request violations.
1527
- */
1528
- CONCURRENT = 'concurrent',
1529
- /**
1530
- * Non-browser access violations.
1531
- */
1532
- NON_BROWSER = 'non_browser',
1533
- /**
1534
- * Message limit violations.
1535
- */
1536
- MESSAGE_LIMIT = 'message_limit',
1537
- /**
1538
- * Registration violations.
1539
- */
1540
- REGISTRATIONS = 'registrations',
1541
- }
1542
-
1543
- /**
1544
- * Enum for error message types that are not "violations" as above, used to identify client-facing errors.
1545
- */
1546
- export enum ErrorTypes {
1547
- /**
1548
- * No User-provided Key.
1549
- */
1550
- NO_USER_KEY = 'no_user_key',
1551
- /**
1552
- * Expired User-provided Key.
1553
- */
1554
- EXPIRED_USER_KEY = 'expired_user_key',
1555
- /**
1556
- * Invalid User-provided Key.
1557
- */
1558
- INVALID_USER_KEY = 'invalid_user_key',
1559
- /**
1560
- * No Base URL Provided.
1561
- */
1562
- NO_BASE_URL = 'no_base_url',
1563
- /**
1564
- * Base URL targets a restricted or invalid address (SSRF protection).
1565
- */
1566
- INVALID_BASE_URL = 'invalid_base_url',
1567
- /**
1568
- * Moderation error
1569
- */
1570
- MODERATION = 'moderation',
1571
- /**
1572
- * Prompt exceeds max length
1573
- */
1574
- INPUT_LENGTH = 'INPUT_LENGTH',
1575
- /**
1576
- * Invalid request error, API rejected request
1577
- */
1578
- INVALID_REQUEST = 'invalid_request_error',
1579
- /**
1580
- * Invalid action request error, likely not on list of allowed domains
1581
- */
1582
- INVALID_ACTION = 'invalid_action_error',
1583
- /**
1584
- * Invalid request error, API rejected request
1585
- */
1586
- NO_SYSTEM_MESSAGES = 'no_system_messages',
1587
- /**
1588
- * Google provider returned an error
1589
- */
1590
- GOOGLE_ERROR = 'google_error',
1591
- /**
1592
- * Google provider does not allow custom tools with built-in tools
1593
- */
1594
- GOOGLE_TOOL_CONFLICT = 'google_tool_conflict',
1595
- /**
1596
- * Invalid Agent Provider (excluded by Admin)
1597
- */
1598
- INVALID_AGENT_PROVIDER = 'invalid_agent_provider',
1599
- /**
1600
- * Missing model selection
1601
- */
1602
- MISSING_MODEL = 'missing_model',
1603
- /**
1604
- * Models configuration not loaded
1605
- */
1606
- MODELS_NOT_LOADED = 'models_not_loaded',
1607
- /**
1608
- * Endpoint models not loaded
1609
- */
1610
- ENDPOINT_MODELS_NOT_LOADED = 'endpoint_models_not_loaded',
1611
- /**
1612
- * Generic Authentication failure
1613
- */
1614
- AUTH_FAILED = 'auth_failed',
1615
- /**
1616
- * Model refused to respond (content policy violation)
1617
- */
1618
- REFUSAL = 'refusal',
1619
- /**
1620
- * SSE stream 404 — job completed, expired, or was deleted before the subscriber connected
1621
- */
1622
- STREAM_EXPIRED = 'stream_expired',
1623
- }
1624
-
1625
- /**
1626
- * Enum for authentication keys.
1627
- */
1628
- export enum AuthKeys {
1629
- /**
1630
- * Key for the Service Account to use Vertex AI.
1631
- */
1632
- GOOGLE_SERVICE_KEY = 'GOOGLE_SERVICE_KEY',
1633
- /**
1634
- * API key to use Google Generative AI.
1635
- *
1636
- * Note: this is not for Environment Variables, but to access encrypted object values.
1637
- */
1638
- GOOGLE_API_KEY = 'GOOGLE_API_KEY',
1639
- /**
1640
- * API key to use Anthropic.
1641
- *
1642
- * Note: this is not for Environment Variables, but to access encrypted object values.
1643
- */
1644
- ANTHROPIC_API_KEY = 'ANTHROPIC_API_KEY',
1645
- }
1646
-
1647
- /**
1648
- * Enum for Image Detail Cost.
1649
- *
1650
- * **Low Res Fixed Cost:** `85`
1651
- *
1652
- * **High Res Calculation:**
1653
- *
1654
- * Number of `512px` Tiles * `170` + `85` (Additional Cost)
1655
- */
1656
- export enum ImageDetailCost {
1657
- /**
1658
- * Low resolution is a fixed value.
1659
- */
1660
- LOW = 85,
1661
- /**
1662
- * High resolution Cost Per Tile
1663
- */
1664
- HIGH = 170,
1665
- /**
1666
- * Additional Cost added to High Resolution Total Cost
1667
- */
1668
- // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
1669
- ADDITIONAL = 85,
1670
- }
1671
-
1672
- /**
1673
- * Tab values for Settings Dialog
1674
- */
1675
- export enum SettingsTabValues {
1676
- /**
1677
- * Tab for General Settings
1678
- */
1679
- GENERAL = 'general',
1680
- /**
1681
- * Tab for Chat Settings
1682
- */
1683
- CHAT = 'chat',
1684
- /**
1685
- * Tab for Speech Settings
1686
- */
1687
- SPEECH = 'speech',
1688
- /**
1689
- * Tab for Beta Features
1690
- */
1691
- BETA = 'beta',
1692
- /**
1693
- * Tab for Data Controls
1694
- */
1695
- DATA = 'data',
1696
- /**
1697
- * Tab for Balance Settings
1698
- */
1699
- BALANCE = 'balance',
1700
- /**
1701
- * Tab for Account Settings
1702
- */
1703
- ACCOUNT = 'account',
1704
- /**
1705
- * Chat input commands
1706
- */
1707
- COMMANDS = 'commands',
1708
- /**
1709
- * Tab for Personalization Settings
1710
- */
1711
- PERSONALIZATION = 'personalization',
1712
- }
1713
-
1714
- export enum STTProviders {
1715
- /**
1716
- * Provider for OpenAI STT
1717
- */
1718
- OPENAI = 'openai',
1719
- /**
1720
- * Provider for Microsoft Azure STT
1721
- */
1722
- AZURE_OPENAI = 'azureOpenAI',
1723
- }
1724
-
1725
- export enum TTSProviders {
1726
- /**
1727
- * Provider for OpenAI TTS
1728
- */
1729
- OPENAI = 'openai',
1730
- /**
1731
- * Provider for Microsoft Azure OpenAI TTS
1732
- */
1733
- AZURE_OPENAI = 'azureOpenAI',
1734
- /**
1735
- * Provider for ElevenLabs TTS
1736
- */
1737
- ELEVENLABS = 'elevenlabs',
1738
- /**
1739
- * Provider for LocalAI TTS
1740
- */
1741
- LOCALAI = 'localai',
1742
- }
1743
-
1744
- /** Enum for app-wide constants */
1745
- export enum Constants {
1746
- /** Key for the app's version. */
1747
- VERSION = 'v0.8.4',
1748
- /** Key for the Custom Config's version (librechat.yaml). */
1749
- CONFIG_VERSION = '1.3.6',
1750
- /** Standard value for the first message's `parentMessageId` value, to indicate no parent exists. */
1751
- NO_PARENT = '00000000-0000-0000-0000-000000000000',
1752
- /** Standard value to use whatever the submission prelim. `responseMessageId` is */
1753
- USE_PRELIM_RESPONSE_MESSAGE_ID = 'USE_PRELIM_RESPONSE_MESSAGE_ID',
1754
- /** Standard value for the initial conversationId before a request is sent */
1755
- NEW_CONVO = 'new',
1756
- /** Standard value for the temporary conversationId after a request is sent and before the server responds */
1757
- PENDING_CONVO = 'PENDING',
1758
- /** Standard value for the conversationId used for search queries */
1759
- SEARCH = 'search',
1760
- /** Fixed, encoded domain length for Azure OpenAI Assistants Function name parsing. */
1761
- ENCODED_DOMAIN_LENGTH = 10,
1762
- /** Identifier for using current_model in multi-model requests. */
1763
- CURRENT_MODEL = 'current_model',
1764
- /** Common divider for text values */
1765
- COMMON_DIVIDER = '__',
1766
- /** Max length for commands */
1767
- COMMANDS_MAX_LENGTH = 56,
1768
- /** Default Stream Rate (ms) */
1769
- DEFAULT_STREAM_RATE = 1,
1770
- /** Saved Tag */
1771
- SAVED_TAG = 'Saved',
1772
- /** Max number of Conversation starters for Agents/Assistants */
1773
- MAX_CONVO_STARTERS = 4,
1774
- /** Global/instance Project Name */
1775
- GLOBAL_PROJECT_NAME = 'instance',
1776
- /** Delimiter for MCP tools */
1777
- mcp_delimiter = '_mcp_',
1778
- /** Prefix for MCP plugins */
1779
- mcp_prefix = 'mcp_',
1780
- /** Unique value to indicate all MCP servers. For backend use only. */
1781
- mcp_all = 'sys__all__sys',
1782
- /** Unique value to indicate clearing MCP servers from UI state. For frontend use only. */
1783
- mcp_clear = 'sys__clear__sys',
1784
- /** Key suffix for non-spec user default tool storage */
1785
- spec_defaults_key = '__defaults__',
1786
- /**
1787
- * Unique value to indicate the MCP tool was added to an agent.
1788
- * This helps inform the UI if the mcp server was previously added.
1789
- * */
1790
- mcp_server = 'sys__server__sys',
1791
- /**
1792
- * Handoff Tool Name Prefix
1793
- */
1794
- LC_TRANSFER_TO_ = 'lc_transfer_to_',
1795
- /** Placeholder Agent ID for Ephemeral Agents */
1796
- EPHEMERAL_AGENT_ID = 'ephemeral',
1797
- /** Programmatic Tool Calling tool name */
1798
- PROGRAMMATIC_TOOL_CALLING = 'run_tools_with_code',
1799
- }
1800
-
1801
- export enum LocalStorageKeys {
1802
- /** Key for the admin defined App Title */
1803
- APP_TITLE = 'appTitle',
1804
- /** Key for the last conversation setup. */
1805
- LAST_CONVO_SETUP = 'lastConversationSetup',
1806
- /** Key for the last selected model. */
1807
- LAST_MODEL = 'lastSelectedModel',
1808
- /** Key for the last selected tools. */
1809
- LAST_TOOLS = 'lastSelectedTools',
1810
- /** Key for the last selected spec by name*/
1811
- LAST_SPEC = 'lastSelectedSpec',
1812
- /** Key for temporary files to delete */
1813
- FILES_TO_DELETE = 'filesToDelete',
1814
- /** Prefix key for the last selected assistant ID by index */
1815
- ASST_ID_PREFIX = 'assistant_id__',
1816
- /** Prefix key for the last selected agent ID by index */
1817
- AGENT_ID_PREFIX = 'agent_id__',
1818
- /** Key for the last selected fork setting */
1819
- FORK_SETTING = 'forkSetting',
1820
- /** Key for remembering the last selected option, instead of manually selecting */
1821
- REMEMBER_FORK_OPTION = 'rememberDefaultFork',
1822
- /** Key for remembering the split at target fork option modifier */
1823
- FORK_SPLIT_AT_TARGET = 'splitAtTarget',
1824
- /** Key for saving text drafts */
1825
- TEXT_DRAFT = 'textDraft_',
1826
- /** Key for saving file drafts */
1827
- FILES_DRAFT = 'filesDraft_',
1828
- /** Key for last Selected Prompt Category */
1829
- LAST_PROMPT_CATEGORY = 'lastPromptCategory',
1830
- /** Key for rendering User Messages as Markdown */
1831
- ENABLE_USER_MSG_MARKDOWN = 'enableUserMsgMarkdown',
1832
- /** Key for displaying analysis tool code input */
1833
- SHOW_ANALYSIS_CODE = 'showAnalysisCode',
1834
- /** Last selected MCP values per conversation ID */
1835
- LAST_MCP_ = 'LAST_MCP_',
1836
- /** Last checked toggle for Code Interpreter API per conversation ID */
1837
- LAST_CODE_TOGGLE_ = 'LAST_CODE_TOGGLE_',
1838
- /** Last checked toggle for Web Search per conversation ID */
1839
- LAST_WEB_SEARCH_TOGGLE_ = 'LAST_WEB_SEARCH_TOGGLE_',
1840
- /** Last checked toggle for File Search per conversation ID */
1841
- LAST_FILE_SEARCH_TOGGLE_ = 'LAST_FILE_SEARCH_TOGGLE_',
1842
- /** Last checked toggle for Artifacts per conversation ID */
1843
- LAST_ARTIFACTS_TOGGLE_ = 'LAST_ARTIFACTS_TOGGLE_',
1844
- /** Key for the last selected agent provider */
1845
- LAST_AGENT_PROVIDER = 'lastAgentProvider',
1846
- /** Key for the last selected agent model */
1847
- LAST_AGENT_MODEL = 'lastAgentModel',
1848
- /** Pin state for MCP tools per conversation ID */
1849
- PIN_MCP_ = 'PIN_MCP_',
1850
- /** Pin state for Web Search per conversation ID */
1851
- PIN_WEB_SEARCH_ = 'PIN_WEB_SEARCH_',
1852
- /** Pin state for Code Interpreter per conversation ID */
1853
- PIN_CODE_INTERPRETER_ = 'PIN_CODE_INTERPRETER_',
1854
- }
1855
-
1856
- export enum ForkOptions {
1857
- /** Key for direct path option */
1858
- DIRECT_PATH = 'directPath',
1859
- /** Key for including branches */
1860
- INCLUDE_BRANCHES = 'includeBranches',
1861
- /** Key for target level fork (default) */
1862
- TARGET_LEVEL = 'targetLevel',
1863
- /** Default option */
1864
- DEFAULT = 'default',
1865
- }
1866
-
1867
- /**
1868
- * Enum for Cohere related constants
1869
- */
1870
- export enum CohereConstants {
1871
- /**
1872
- * Cohere API Endpoint, for special handling
1873
- */
1874
- API_URL = 'https://api.cohere.ai/v1',
1875
- /**
1876
- * Role for "USER" messages
1877
- */
1878
- ROLE_USER = 'USER',
1879
- /**
1880
- * Role for "SYSTEM" messages
1881
- */
1882
- ROLE_SYSTEM = 'SYSTEM',
1883
- /**
1884
- * Role for "CHATBOT" messages
1885
- */
1886
- ROLE_CHATBOT = 'CHATBOT',
1887
- /**
1888
- * Title message as required by Cohere
1889
- */
1890
- TITLE_MESSAGE = 'TITLE:',
1891
- }
1892
-
1893
- export enum SystemCategories {
1894
- ALL = 'sys__all__sys',
1895
- MY_PROMPTS = 'sys__my__prompts__sys',
1896
- NO_CATEGORY = 'sys__no__category__sys',
1897
- SHARED_PROMPTS = 'sys__shared__prompts__sys',
1898
- }
1899
-
1900
- export const providerEndpointMap = {
1901
- [EModelEndpoint.openAI]: EModelEndpoint.openAI,
1902
- [EModelEndpoint.bedrock]: EModelEndpoint.bedrock,
1903
- [EModelEndpoint.anthropic]: EModelEndpoint.anthropic,
1904
- [EModelEndpoint.azureOpenAI]: EModelEndpoint.azureOpenAI,
1905
- };
1906
-
1907
- export const specialVariables = {
1908
- current_date: true,
1909
- current_user: true,
1910
- iso_datetime: true,
1911
- current_datetime: true,
1912
- };
1913
-
1914
- export type TSpecialVarLabel = `com_ui_special_var_${keyof typeof specialVariables}`;
1915
-
1916
- /**
1917
- * Retrieves a specific field from the endpoints configuration for a given endpoint key.
1918
- * Does not infer or default any endpoint type when absent.
1919
- */
1920
- export function getEndpointField<
1921
- K extends TConfig[keyof TConfig] extends never ? never : keyof TConfig,
1922
- >(
1923
- endpointsConfig: TEndpointsConfig | undefined | null,
1924
- endpoint: EModelEndpoint | string | null | undefined,
1925
- property: K,
1926
- ): TConfig[K] | undefined {
1927
- if (!endpointsConfig || endpoint === null || endpoint === undefined) {
1928
- return undefined;
1929
- }
1930
- const config = endpointsConfig[endpoint];
1931
- if (!config) {
1932
- return undefined;
1933
- }
1934
- return config[property];
1935
- }
1936
-
1937
- /**
1938
- * Resolves the effective endpoint type:
1939
- * - Non-agents endpoint: config.type || endpoint
1940
- * - Agents + provider: config[provider].type || provider
1941
- * - Agents, no provider: EModelEndpoint.agents
1942
- *
1943
- * Returns `undefined` when endpoint is null/undefined.
1944
- */
1945
- export function resolveEndpointType(
1946
- endpointsConfig: TEndpointsConfig | undefined | null,
1947
- endpoint: string | null | undefined,
1948
- agentProvider?: string | null,
1949
- ): EModelEndpoint | string | undefined {
1950
- if (!endpoint) {
1951
- return undefined;
1952
- }
1953
-
1954
- if (!isAgentsEndpoint(endpoint)) {
1955
- return getEndpointField(endpointsConfig, endpoint, 'type') || endpoint;
1956
- }
1957
-
1958
- if (agentProvider) {
1959
- const providerType = getEndpointField(endpointsConfig, agentProvider, 'type');
1960
- if (providerType) {
1961
- return providerType;
1962
- }
1963
- return agentProvider;
1964
- }
1965
-
1966
- return EModelEndpoint.agents;
1967
- }
1968
-
1969
- /** Resolves the `defaultParamsEndpoint` for a given endpoint from its custom params config */
1970
- export function getDefaultParamsEndpoint(
1971
- endpointsConfig: TEndpointsConfig | undefined | null,
1972
- endpoint: string | null | undefined,
1973
- ): string | undefined {
1974
- if (!endpointsConfig || !endpoint) {
1975
- return undefined;
1976
- }
1977
- return endpointsConfig[endpoint]?.customParams?.defaultParamsEndpoint;
1978
- }