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