librechat-data-provider 0.7.3 → 0.7.5
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/react-query/package.json +1 -1
- package/package.json +3 -3
- package/react-query/package.json +1 -1
- package/specs/actions.spec.ts +276 -1
- package/specs/openapiSpecs.ts +127 -0
- package/src/actions.ts +108 -25
- package/src/api-endpoints.ts +36 -2
- package/src/artifacts.ts +3104 -0
- package/src/bedrock.ts +147 -0
- package/src/config.ts +185 -23
- package/src/data-service.ts +247 -78
- package/src/file-config.ts +4 -1
- package/src/generate.ts +30 -1
- package/src/index.ts +5 -0
- package/src/keys.ts +11 -0
- package/src/parsers.ts +85 -27
- package/src/react-query/react-query-service.ts +25 -0
- package/src/request.ts +3 -0
- package/src/roles.ts +59 -2
- package/src/schemas.ts +361 -173
- package/src/types/agents.ts +220 -0
- package/src/types/assistants.ts +150 -27
- package/src/types/files.ts +5 -0
- package/src/types/mutations.ts +75 -0
- package/src/types/queries.ts +6 -2
- package/src/types/runs.ts +22 -0
- package/src/types.ts +59 -3
package/src/schemas.ts
CHANGED
|
@@ -23,18 +23,79 @@ export enum EModelEndpoint {
|
|
|
23
23
|
anthropic = 'anthropic',
|
|
24
24
|
assistants = 'assistants',
|
|
25
25
|
azureAssistants = 'azureAssistants',
|
|
26
|
+
agents = 'agents',
|
|
26
27
|
custom = 'custom',
|
|
28
|
+
bedrock = 'bedrock',
|
|
27
29
|
}
|
|
28
30
|
|
|
31
|
+
export const paramEndpoints = new Set<EModelEndpoint | string>([
|
|
32
|
+
EModelEndpoint.agents,
|
|
33
|
+
EModelEndpoint.openAI,
|
|
34
|
+
EModelEndpoint.bedrock,
|
|
35
|
+
EModelEndpoint.azureOpenAI,
|
|
36
|
+
EModelEndpoint.anthropic,
|
|
37
|
+
EModelEndpoint.custom,
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
export enum BedrockProviders {
|
|
41
|
+
AI21 = 'ai21',
|
|
42
|
+
Amazon = 'amazon',
|
|
43
|
+
Anthropic = 'anthropic',
|
|
44
|
+
Cohere = 'cohere',
|
|
45
|
+
Meta = 'meta',
|
|
46
|
+
MistralAI = 'mistral',
|
|
47
|
+
StabilityAI = 'stability',
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const getModelKey = (endpoint: EModelEndpoint | string, model: string) => {
|
|
51
|
+
if (endpoint === EModelEndpoint.bedrock) {
|
|
52
|
+
return model.split('.')[0] as BedrockProviders;
|
|
53
|
+
}
|
|
54
|
+
return model;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const getSettingsKeys = (endpoint: EModelEndpoint | string, model: string) => {
|
|
58
|
+
const endpointKey = endpoint;
|
|
59
|
+
const modelKey = getModelKey(endpointKey, model);
|
|
60
|
+
const combinedKey = `${endpointKey}-${modelKey}`;
|
|
61
|
+
return [combinedKey, endpointKey];
|
|
62
|
+
};
|
|
63
|
+
|
|
29
64
|
export type AssistantsEndpoint = EModelEndpoint.assistants | EModelEndpoint.azureAssistants;
|
|
30
65
|
|
|
31
|
-
export const isAssistantsEndpoint = (
|
|
66
|
+
export const isAssistantsEndpoint = (_endpoint?: AssistantsEndpoint | null | string): boolean => {
|
|
67
|
+
const endpoint = _endpoint ?? '';
|
|
32
68
|
if (!endpoint) {
|
|
33
69
|
return false;
|
|
34
70
|
}
|
|
35
71
|
return endpoint.toLowerCase().endsWith(EModelEndpoint.assistants);
|
|
36
72
|
};
|
|
37
73
|
|
|
74
|
+
export type AgentProvider = Exclude<keyof typeof EModelEndpoint, EModelEndpoint.agents> | string;
|
|
75
|
+
|
|
76
|
+
export const isAgentsEndpoint = (_endpoint?: EModelEndpoint.agents | null | string): boolean => {
|
|
77
|
+
const endpoint = _endpoint ?? '';
|
|
78
|
+
if (!endpoint) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
return endpoint === EModelEndpoint.agents;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const isParamEndpoint = (
|
|
85
|
+
endpoint: EModelEndpoint | string,
|
|
86
|
+
endpointType?: EModelEndpoint | string,
|
|
87
|
+
): boolean => {
|
|
88
|
+
if (paramEndpoints.has(endpoint)) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (endpointType != null) {
|
|
93
|
+
return paramEndpoints.has(endpointType);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return false;
|
|
97
|
+
};
|
|
98
|
+
|
|
38
99
|
export enum ImageDetail {
|
|
39
100
|
low = 'low',
|
|
40
101
|
auto = 'auto',
|
|
@@ -61,6 +122,7 @@ export const defaultAssistantFormValues = {
|
|
|
61
122
|
name: '',
|
|
62
123
|
description: '',
|
|
63
124
|
instructions: '',
|
|
125
|
+
conversation_starters: [],
|
|
64
126
|
model: '',
|
|
65
127
|
functions: [],
|
|
66
128
|
code_interpreter: false,
|
|
@@ -68,6 +130,22 @@ export const defaultAssistantFormValues = {
|
|
|
68
130
|
retrieval: false,
|
|
69
131
|
};
|
|
70
132
|
|
|
133
|
+
export const defaultAgentFormValues = {
|
|
134
|
+
agent: {},
|
|
135
|
+
id: '',
|
|
136
|
+
name: '',
|
|
137
|
+
description: '',
|
|
138
|
+
instructions: '',
|
|
139
|
+
model: '',
|
|
140
|
+
model_parameters: {},
|
|
141
|
+
tools: [],
|
|
142
|
+
provider: {},
|
|
143
|
+
projectIds: [],
|
|
144
|
+
isCollaborative: false,
|
|
145
|
+
[Tools.execute_code]: false,
|
|
146
|
+
[Tools.file_search]: false,
|
|
147
|
+
};
|
|
148
|
+
|
|
71
149
|
export const ImageVisionTool: FunctionTool = {
|
|
72
150
|
type: Tools.function,
|
|
73
151
|
[Tools.function]: {
|
|
@@ -82,7 +160,7 @@ export const ImageVisionTool: FunctionTool = {
|
|
|
82
160
|
};
|
|
83
161
|
|
|
84
162
|
export const isImageVisionTool = (tool: FunctionTool | FunctionToolCall) =>
|
|
85
|
-
tool.type === 'function' && tool.function?.name === ImageVisionTool
|
|
163
|
+
tool.type === 'function' && tool.function?.name === ImageVisionTool.function?.name;
|
|
86
164
|
|
|
87
165
|
export const openAISettings = {
|
|
88
166
|
model: {
|
|
@@ -90,7 +168,7 @@ export const openAISettings = {
|
|
|
90
168
|
},
|
|
91
169
|
temperature: {
|
|
92
170
|
min: 0,
|
|
93
|
-
max:
|
|
171
|
+
max: 2,
|
|
94
172
|
step: 0.01,
|
|
95
173
|
default: 1,
|
|
96
174
|
},
|
|
@@ -123,6 +201,9 @@ export const openAISettings = {
|
|
|
123
201
|
},
|
|
124
202
|
imageDetail: {
|
|
125
203
|
default: ImageDetail.auto,
|
|
204
|
+
min: 0,
|
|
205
|
+
max: 2,
|
|
206
|
+
step: 1,
|
|
126
207
|
},
|
|
127
208
|
};
|
|
128
209
|
|
|
@@ -151,14 +232,122 @@ export const googleSettings = {
|
|
|
151
232
|
topK: {
|
|
152
233
|
min: 1,
|
|
153
234
|
max: 40,
|
|
154
|
-
step:
|
|
235
|
+
step: 1,
|
|
155
236
|
default: 40,
|
|
156
237
|
},
|
|
157
238
|
};
|
|
158
239
|
|
|
240
|
+
const ANTHROPIC_MAX_OUTPUT = 8192;
|
|
241
|
+
const LEGACY_ANTHROPIC_MAX_OUTPUT = 4096;
|
|
242
|
+
export const anthropicSettings = {
|
|
243
|
+
model: {
|
|
244
|
+
default: 'claude-3-5-sonnet-20241022',
|
|
245
|
+
},
|
|
246
|
+
temperature: {
|
|
247
|
+
min: 0,
|
|
248
|
+
max: 1,
|
|
249
|
+
step: 0.01,
|
|
250
|
+
default: 1,
|
|
251
|
+
},
|
|
252
|
+
promptCache: {
|
|
253
|
+
default: true,
|
|
254
|
+
},
|
|
255
|
+
maxOutputTokens: {
|
|
256
|
+
min: 1,
|
|
257
|
+
max: ANTHROPIC_MAX_OUTPUT,
|
|
258
|
+
step: 1,
|
|
259
|
+
default: ANTHROPIC_MAX_OUTPUT,
|
|
260
|
+
reset: (modelName: string) => {
|
|
261
|
+
if (modelName.includes('claude-3-5-sonnet')) {
|
|
262
|
+
return ANTHROPIC_MAX_OUTPUT;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return 4096;
|
|
266
|
+
},
|
|
267
|
+
set: (value: number, modelName: string) => {
|
|
268
|
+
if (!modelName.includes('claude-3-5-sonnet') && value > LEGACY_ANTHROPIC_MAX_OUTPUT) {
|
|
269
|
+
return LEGACY_ANTHROPIC_MAX_OUTPUT;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return value;
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
topP: {
|
|
276
|
+
min: 0,
|
|
277
|
+
max: 1,
|
|
278
|
+
step: 0.01,
|
|
279
|
+
default: 0.7,
|
|
280
|
+
},
|
|
281
|
+
topK: {
|
|
282
|
+
min: 1,
|
|
283
|
+
max: 40,
|
|
284
|
+
step: 1,
|
|
285
|
+
default: 5,
|
|
286
|
+
},
|
|
287
|
+
resendFiles: {
|
|
288
|
+
default: true,
|
|
289
|
+
},
|
|
290
|
+
maxContextTokens: {
|
|
291
|
+
default: undefined,
|
|
292
|
+
},
|
|
293
|
+
legacy: {
|
|
294
|
+
maxOutputTokens: {
|
|
295
|
+
min: 1,
|
|
296
|
+
max: LEGACY_ANTHROPIC_MAX_OUTPUT,
|
|
297
|
+
step: 1,
|
|
298
|
+
default: LEGACY_ANTHROPIC_MAX_OUTPUT,
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
export const agentsSettings = {
|
|
304
|
+
model: {
|
|
305
|
+
default: 'gpt-3.5-turbo-test',
|
|
306
|
+
},
|
|
307
|
+
temperature: {
|
|
308
|
+
min: 0,
|
|
309
|
+
max: 1,
|
|
310
|
+
step: 0.01,
|
|
311
|
+
default: 1,
|
|
312
|
+
},
|
|
313
|
+
top_p: {
|
|
314
|
+
min: 0,
|
|
315
|
+
max: 1,
|
|
316
|
+
step: 0.01,
|
|
317
|
+
default: 1,
|
|
318
|
+
},
|
|
319
|
+
presence_penalty: {
|
|
320
|
+
min: 0,
|
|
321
|
+
max: 2,
|
|
322
|
+
step: 0.01,
|
|
323
|
+
default: 0,
|
|
324
|
+
},
|
|
325
|
+
frequency_penalty: {
|
|
326
|
+
min: 0,
|
|
327
|
+
max: 2,
|
|
328
|
+
step: 0.01,
|
|
329
|
+
default: 0,
|
|
330
|
+
},
|
|
331
|
+
resendFiles: {
|
|
332
|
+
default: true,
|
|
333
|
+
},
|
|
334
|
+
maxContextTokens: {
|
|
335
|
+
default: undefined,
|
|
336
|
+
},
|
|
337
|
+
max_tokens: {
|
|
338
|
+
default: undefined,
|
|
339
|
+
},
|
|
340
|
+
imageDetail: {
|
|
341
|
+
default: ImageDetail.auto,
|
|
342
|
+
},
|
|
343
|
+
};
|
|
344
|
+
|
|
159
345
|
export const endpointSettings = {
|
|
160
346
|
[EModelEndpoint.openAI]: openAISettings,
|
|
161
347
|
[EModelEndpoint.google]: googleSettings,
|
|
348
|
+
[EModelEndpoint.anthropic]: anthropicSettings,
|
|
349
|
+
[EModelEndpoint.agents]: agentsSettings,
|
|
350
|
+
[EModelEndpoint.bedrock]: agentsSettings,
|
|
162
351
|
};
|
|
163
352
|
|
|
164
353
|
const google = endpointSettings[EModelEndpoint.google];
|
|
@@ -280,6 +469,13 @@ export const tMessageSchema = z.object({
|
|
|
280
469
|
iconURL: z.string().optional(),
|
|
281
470
|
});
|
|
282
471
|
|
|
472
|
+
export type TAttachmentMetadata = { messageId: string; toolCallId: string };
|
|
473
|
+
export type TAttachment =
|
|
474
|
+
| (TFile & TAttachmentMetadata)
|
|
475
|
+
| (Pick<TFile, 'filename' | 'filepath' | 'conversationId'> & {
|
|
476
|
+
expiresAt: number;
|
|
477
|
+
} & TAttachmentMetadata);
|
|
478
|
+
|
|
283
479
|
export type TMessage = z.input<typeof tMessageSchema> & {
|
|
284
480
|
children?: TMessage[];
|
|
285
481
|
plugin?: TResPlugin | null;
|
|
@@ -288,6 +484,7 @@ export type TMessage = z.input<typeof tMessageSchema> & {
|
|
|
288
484
|
files?: Partial<TFile>[];
|
|
289
485
|
depth?: number;
|
|
290
486
|
siblingIndex?: number;
|
|
487
|
+
attachments?: TAttachment[];
|
|
291
488
|
};
|
|
292
489
|
|
|
293
490
|
export const coerceNumber = z.union([z.number(), z.string()]).transform((val) => {
|
|
@@ -297,43 +494,76 @@ export const coerceNumber = z.union([z.number(), z.string()]).transform((val) =>
|
|
|
297
494
|
return val;
|
|
298
495
|
});
|
|
299
496
|
|
|
497
|
+
type DocumentTypeValue =
|
|
498
|
+
| null
|
|
499
|
+
| boolean
|
|
500
|
+
| number
|
|
501
|
+
| string
|
|
502
|
+
| DocumentTypeValue[]
|
|
503
|
+
| { [key: string]: DocumentTypeValue };
|
|
504
|
+
|
|
505
|
+
const DocumentType: z.ZodType<DocumentTypeValue> = z.lazy(() =>
|
|
506
|
+
z.union([
|
|
507
|
+
z.null(),
|
|
508
|
+
z.boolean(),
|
|
509
|
+
z.number(),
|
|
510
|
+
z.string(),
|
|
511
|
+
z.array(z.lazy(() => DocumentType)),
|
|
512
|
+
z.record(z.lazy(() => DocumentType)),
|
|
513
|
+
]),
|
|
514
|
+
);
|
|
515
|
+
|
|
300
516
|
export const tConversationSchema = z.object({
|
|
301
517
|
conversationId: z.string().nullable(),
|
|
302
|
-
title: z.string().nullable().or(z.literal('New Chat')).default('New Chat'),
|
|
303
|
-
user: z.string().optional(),
|
|
304
518
|
endpoint: eModelEndpointSchema.nullable(),
|
|
305
519
|
endpointType: eModelEndpointSchema.optional(),
|
|
306
|
-
|
|
520
|
+
isArchived: z.boolean().optional(),
|
|
521
|
+
title: z.string().nullable().or(z.literal('New Chat')).default('New Chat'),
|
|
522
|
+
user: z.string().optional(),
|
|
307
523
|
messages: z.array(z.string()).optional(),
|
|
308
524
|
tools: z.union([z.array(tPluginSchema), z.array(z.string())]).optional(),
|
|
309
|
-
createdAt: z.string(),
|
|
310
|
-
updatedAt: z.string(),
|
|
311
525
|
modelLabel: z.string().nullable().optional(),
|
|
312
|
-
examples: z.array(tExampleSchema).optional(),
|
|
313
|
-
/* Prefer modelLabel over chatGptLabel */
|
|
314
|
-
chatGptLabel: z.string().nullable().optional(),
|
|
315
526
|
userLabel: z.string().optional(),
|
|
316
527
|
model: z.string().nullable().optional(),
|
|
317
528
|
promptPrefix: z.string().nullable().optional(),
|
|
318
529
|
temperature: z.number().optional(),
|
|
319
530
|
topP: z.number().optional(),
|
|
320
531
|
topK: z.number().optional(),
|
|
321
|
-
context: z.string().nullable().optional(),
|
|
322
532
|
top_p: z.number().optional(),
|
|
323
533
|
frequency_penalty: z.number().optional(),
|
|
324
534
|
presence_penalty: z.number().optional(),
|
|
325
535
|
parentMessageId: z.string().optional(),
|
|
326
|
-
maxOutputTokens:
|
|
327
|
-
agentOptions: tAgentOptionsSchema.nullable().optional(),
|
|
328
|
-
file_ids: z.array(z.string()).optional(),
|
|
536
|
+
maxOutputTokens: coerceNumber.optional(),
|
|
329
537
|
maxContextTokens: coerceNumber.optional(),
|
|
330
538
|
max_tokens: coerceNumber.optional(),
|
|
539
|
+
/* Anthropic */
|
|
540
|
+
promptCache: z.boolean().optional(),
|
|
541
|
+
system: z.string().optional(),
|
|
542
|
+
/* artifacts */
|
|
543
|
+
artifacts: z.string().optional(),
|
|
544
|
+
/* google */
|
|
545
|
+
context: z.string().nullable().optional(),
|
|
546
|
+
examples: z.array(tExampleSchema).optional(),
|
|
547
|
+
/* DB */
|
|
548
|
+
tags: z.array(z.string()).optional(),
|
|
549
|
+
createdAt: z.string(),
|
|
550
|
+
updatedAt: z.string(),
|
|
551
|
+
/* Files */
|
|
552
|
+
file_ids: z.array(z.string()).optional(),
|
|
331
553
|
/* vision */
|
|
332
554
|
resendFiles: z.boolean().optional(),
|
|
333
555
|
imageDetail: eImageDetailSchema.optional(),
|
|
334
556
|
/* assistant */
|
|
335
557
|
assistant_id: z.string().optional(),
|
|
558
|
+
/* agents */
|
|
559
|
+
agent_id: z.string().optional(),
|
|
560
|
+
/* AWS Bedrock */
|
|
561
|
+
region: z.string().optional(),
|
|
562
|
+
maxTokens: coerceNumber.optional(),
|
|
563
|
+
additionalModelRequestFields: DocumentType.optional(),
|
|
564
|
+
/* assistant + agents */
|
|
336
565
|
instructions: z.string().optional(),
|
|
566
|
+
additional_instructions: z.string().optional(),
|
|
337
567
|
/** Used to overwrite active conversation settings when saving a Preset */
|
|
338
568
|
presetOverride: z.record(z.unknown()).optional(),
|
|
339
569
|
stop: z.array(z.string()).optional(),
|
|
@@ -345,6 +575,8 @@ export const tConversationSchema = z.object({
|
|
|
345
575
|
Deprecated fields
|
|
346
576
|
*/
|
|
347
577
|
/** @deprecated */
|
|
578
|
+
suggestions: z.array(z.string()).optional(),
|
|
579
|
+
/** @deprecated */
|
|
348
580
|
systemMessage: z.string().nullable().optional(),
|
|
349
581
|
/** @deprecated */
|
|
350
582
|
jailbreak: z.boolean().optional(),
|
|
@@ -360,6 +592,10 @@ export const tConversationSchema = z.object({
|
|
|
360
592
|
toneStyle: z.string().nullable().optional(),
|
|
361
593
|
/** @deprecated */
|
|
362
594
|
resendImages: z.boolean().optional(),
|
|
595
|
+
/** @deprecated */
|
|
596
|
+
agentOptions: tAgentOptionsSchema.nullable().optional(),
|
|
597
|
+
/** @deprecated Prefer `modelLabel` over `chatGptLabel` */
|
|
598
|
+
chatGptLabel: z.string().nullable().optional(),
|
|
363
599
|
});
|
|
364
600
|
|
|
365
601
|
export const tPresetSchema = tConversationSchema
|
|
@@ -415,69 +651,17 @@ export const tSharedLinkSchema = z.object({
|
|
|
415
651
|
});
|
|
416
652
|
export type TSharedLink = z.infer<typeof tSharedLinkSchema>;
|
|
417
653
|
|
|
418
|
-
export const
|
|
419
|
-
.
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
imageDetail: true,
|
|
430
|
-
stop: true,
|
|
431
|
-
iconURL: true,
|
|
432
|
-
greeting: true,
|
|
433
|
-
spec: true,
|
|
434
|
-
maxContextTokens: true,
|
|
435
|
-
max_tokens: true,
|
|
436
|
-
})
|
|
437
|
-
.transform((obj) => {
|
|
438
|
-
const result = {
|
|
439
|
-
...obj,
|
|
440
|
-
model: obj.model ?? openAISettings.model.default,
|
|
441
|
-
chatGptLabel: obj.chatGptLabel ?? obj.modelLabel ?? null,
|
|
442
|
-
promptPrefix: obj.promptPrefix ?? null,
|
|
443
|
-
temperature: obj.temperature ?? openAISettings.temperature.default,
|
|
444
|
-
top_p: obj.top_p ?? openAISettings.top_p.default,
|
|
445
|
-
presence_penalty: obj.presence_penalty ?? openAISettings.presence_penalty.default,
|
|
446
|
-
frequency_penalty: obj.frequency_penalty ?? openAISettings.frequency_penalty.default,
|
|
447
|
-
resendFiles:
|
|
448
|
-
typeof obj.resendFiles === 'boolean' ? obj.resendFiles : openAISettings.resendFiles.default,
|
|
449
|
-
imageDetail: obj.imageDetail ?? openAISettings.imageDetail.default,
|
|
450
|
-
stop: obj.stop ?? undefined,
|
|
451
|
-
iconURL: obj.iconURL ?? undefined,
|
|
452
|
-
greeting: obj.greeting ?? undefined,
|
|
453
|
-
spec: obj.spec ?? undefined,
|
|
454
|
-
maxContextTokens: obj.maxContextTokens ?? undefined,
|
|
455
|
-
max_tokens: obj.max_tokens ?? undefined,
|
|
456
|
-
};
|
|
457
|
-
|
|
458
|
-
if (obj.modelLabel) {
|
|
459
|
-
result.modelLabel = null;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
return result;
|
|
463
|
-
})
|
|
464
|
-
.catch(() => ({
|
|
465
|
-
model: openAISettings.model.default,
|
|
466
|
-
chatGptLabel: null,
|
|
467
|
-
promptPrefix: null,
|
|
468
|
-
temperature: openAISettings.temperature.default,
|
|
469
|
-
top_p: openAISettings.top_p.default,
|
|
470
|
-
presence_penalty: openAISettings.presence_penalty.default,
|
|
471
|
-
frequency_penalty: openAISettings.frequency_penalty.default,
|
|
472
|
-
resendFiles: openAISettings.resendFiles.default,
|
|
473
|
-
imageDetail: openAISettings.imageDetail.default,
|
|
474
|
-
stop: undefined,
|
|
475
|
-
iconURL: undefined,
|
|
476
|
-
greeting: undefined,
|
|
477
|
-
spec: undefined,
|
|
478
|
-
maxContextTokens: undefined,
|
|
479
|
-
max_tokens: undefined,
|
|
480
|
-
}));
|
|
654
|
+
export const tConversationTagSchema = z.object({
|
|
655
|
+
_id: z.string(),
|
|
656
|
+
user: z.string(),
|
|
657
|
+
tag: z.string(),
|
|
658
|
+
description: z.string().optional(),
|
|
659
|
+
createdAt: z.string(),
|
|
660
|
+
updatedAt: z.string(),
|
|
661
|
+
count: z.number(),
|
|
662
|
+
position: z.number(),
|
|
663
|
+
});
|
|
664
|
+
export type TConversationTag = z.infer<typeof tConversationTagSchema>;
|
|
481
665
|
|
|
482
666
|
export const googleSchema = tConversationSchema
|
|
483
667
|
.pick({
|
|
@@ -487,6 +671,7 @@ export const googleSchema = tConversationSchema
|
|
|
487
671
|
examples: true,
|
|
488
672
|
temperature: true,
|
|
489
673
|
maxOutputTokens: true,
|
|
674
|
+
artifacts: true,
|
|
490
675
|
topP: true,
|
|
491
676
|
topK: true,
|
|
492
677
|
iconURL: true,
|
|
@@ -561,51 +746,6 @@ export const bingAISchema = tConversationSchema
|
|
|
561
746
|
invocationId: 1,
|
|
562
747
|
}));
|
|
563
748
|
|
|
564
|
-
export const anthropicSchema = tConversationSchema
|
|
565
|
-
.pick({
|
|
566
|
-
model: true,
|
|
567
|
-
modelLabel: true,
|
|
568
|
-
promptPrefix: true,
|
|
569
|
-
temperature: true,
|
|
570
|
-
maxOutputTokens: true,
|
|
571
|
-
topP: true,
|
|
572
|
-
topK: true,
|
|
573
|
-
resendFiles: true,
|
|
574
|
-
iconURL: true,
|
|
575
|
-
greeting: true,
|
|
576
|
-
spec: true,
|
|
577
|
-
maxContextTokens: true,
|
|
578
|
-
})
|
|
579
|
-
.transform((obj) => ({
|
|
580
|
-
...obj,
|
|
581
|
-
model: obj.model ?? 'claude-1',
|
|
582
|
-
modelLabel: obj.modelLabel ?? null,
|
|
583
|
-
promptPrefix: obj.promptPrefix ?? null,
|
|
584
|
-
temperature: obj.temperature ?? 1,
|
|
585
|
-
maxOutputTokens: obj.maxOutputTokens ?? 4000,
|
|
586
|
-
topP: obj.topP ?? 0.7,
|
|
587
|
-
topK: obj.topK ?? 5,
|
|
588
|
-
resendFiles: typeof obj.resendFiles === 'boolean' ? obj.resendFiles : true,
|
|
589
|
-
iconURL: obj.iconURL ?? undefined,
|
|
590
|
-
greeting: obj.greeting ?? undefined,
|
|
591
|
-
spec: obj.spec ?? undefined,
|
|
592
|
-
maxContextTokens: obj.maxContextTokens ?? undefined,
|
|
593
|
-
}))
|
|
594
|
-
.catch(() => ({
|
|
595
|
-
model: 'claude-1',
|
|
596
|
-
modelLabel: null,
|
|
597
|
-
promptPrefix: null,
|
|
598
|
-
temperature: 1,
|
|
599
|
-
maxOutputTokens: 4000,
|
|
600
|
-
topP: 0.7,
|
|
601
|
-
topK: 5,
|
|
602
|
-
resendFiles: true,
|
|
603
|
-
iconURL: undefined,
|
|
604
|
-
greeting: undefined,
|
|
605
|
-
spec: undefined,
|
|
606
|
-
maxContextTokens: undefined,
|
|
607
|
-
}));
|
|
608
|
-
|
|
609
749
|
export const chatGPTBrowserSchema = tConversationSchema
|
|
610
750
|
.pick({
|
|
611
751
|
model: true,
|
|
@@ -625,6 +765,7 @@ export const gptPluginsSchema = tConversationSchema
|
|
|
625
765
|
chatGptLabel: true,
|
|
626
766
|
promptPrefix: true,
|
|
627
767
|
temperature: true,
|
|
768
|
+
artifacts: true,
|
|
628
769
|
top_p: true,
|
|
629
770
|
presence_penalty: true,
|
|
630
771
|
frequency_penalty: true,
|
|
@@ -658,7 +799,7 @@ export const gptPluginsSchema = tConversationSchema
|
|
|
658
799
|
maxContextTokens: obj.maxContextTokens ?? undefined,
|
|
659
800
|
};
|
|
660
801
|
|
|
661
|
-
if (obj.modelLabel) {
|
|
802
|
+
if (obj.modelLabel != null && obj.modelLabel !== '') {
|
|
662
803
|
result.modelLabel = null;
|
|
663
804
|
}
|
|
664
805
|
|
|
@@ -685,16 +826,17 @@ export const gptPluginsSchema = tConversationSchema
|
|
|
685
826
|
maxContextTokens: undefined,
|
|
686
827
|
}));
|
|
687
828
|
|
|
688
|
-
export function removeNullishValues<T extends
|
|
829
|
+
export function removeNullishValues<T extends Record<string, unknown>>(obj: T): Partial<T> {
|
|
689
830
|
const newObj: Partial<T> = { ...obj };
|
|
690
831
|
|
|
691
832
|
(Object.keys(newObj) as Array<keyof T>).forEach((key) => {
|
|
692
|
-
|
|
833
|
+
const value = newObj[key];
|
|
834
|
+
if (value === undefined || value === null) {
|
|
693
835
|
delete newObj[key];
|
|
694
836
|
}
|
|
695
837
|
});
|
|
696
838
|
|
|
697
|
-
return newObj
|
|
839
|
+
return newObj;
|
|
698
840
|
}
|
|
699
841
|
|
|
700
842
|
export const assistantSchema = tConversationSchema
|
|
@@ -702,6 +844,7 @@ export const assistantSchema = tConversationSchema
|
|
|
702
844
|
model: true,
|
|
703
845
|
assistant_id: true,
|
|
704
846
|
instructions: true,
|
|
847
|
+
artifacts: true,
|
|
705
848
|
promptPrefix: true,
|
|
706
849
|
iconURL: true,
|
|
707
850
|
greeting: true,
|
|
@@ -733,6 +876,7 @@ export const compactAssistantSchema = tConversationSchema
|
|
|
733
876
|
assistant_id: true,
|
|
734
877
|
instructions: true,
|
|
735
878
|
promptPrefix: true,
|
|
879
|
+
artifacts: true,
|
|
736
880
|
iconURL: true,
|
|
737
881
|
greeting: true,
|
|
738
882
|
spec: true,
|
|
@@ -741,9 +885,62 @@ export const compactAssistantSchema = tConversationSchema
|
|
|
741
885
|
.transform(removeNullishValues)
|
|
742
886
|
.catch(() => ({}));
|
|
743
887
|
|
|
744
|
-
export const
|
|
888
|
+
export const agentsSchema = tConversationSchema
|
|
889
|
+
.pick({
|
|
890
|
+
model: true,
|
|
891
|
+
modelLabel: true,
|
|
892
|
+
temperature: true,
|
|
893
|
+
top_p: true,
|
|
894
|
+
presence_penalty: true,
|
|
895
|
+
frequency_penalty: true,
|
|
896
|
+
resendFiles: true,
|
|
897
|
+
imageDetail: true,
|
|
898
|
+
agent_id: true,
|
|
899
|
+
instructions: true,
|
|
900
|
+
promptPrefix: true,
|
|
901
|
+
iconURL: true,
|
|
902
|
+
greeting: true,
|
|
903
|
+
maxContextTokens: true,
|
|
904
|
+
})
|
|
905
|
+
.transform((obj) => ({
|
|
906
|
+
...obj,
|
|
907
|
+
model: obj.model ?? agentsSettings.model.default,
|
|
908
|
+
modelLabel: obj.modelLabel ?? null,
|
|
909
|
+
temperature: obj.temperature ?? 1,
|
|
910
|
+
top_p: obj.top_p ?? 1,
|
|
911
|
+
presence_penalty: obj.presence_penalty ?? 0,
|
|
912
|
+
frequency_penalty: obj.frequency_penalty ?? 0,
|
|
913
|
+
resendFiles:
|
|
914
|
+
typeof obj.resendFiles === 'boolean' ? obj.resendFiles : agentsSettings.resendFiles.default,
|
|
915
|
+
imageDetail: obj.imageDetail ?? ImageDetail.auto,
|
|
916
|
+
agent_id: obj.agent_id ?? undefined,
|
|
917
|
+
instructions: obj.instructions ?? undefined,
|
|
918
|
+
promptPrefix: obj.promptPrefix ?? null,
|
|
919
|
+
iconURL: obj.iconURL ?? undefined,
|
|
920
|
+
greeting: obj.greeting ?? undefined,
|
|
921
|
+
maxContextTokens: obj.maxContextTokens ?? undefined,
|
|
922
|
+
}))
|
|
923
|
+
.catch(() => ({
|
|
924
|
+
model: agentsSettings.model.default,
|
|
925
|
+
modelLabel: null,
|
|
926
|
+
temperature: 1,
|
|
927
|
+
top_p: 1,
|
|
928
|
+
presence_penalty: 0,
|
|
929
|
+
frequency_penalty: 0,
|
|
930
|
+
resendFiles: agentsSettings.resendFiles.default,
|
|
931
|
+
imageDetail: ImageDetail.auto,
|
|
932
|
+
agent_id: undefined,
|
|
933
|
+
instructions: undefined,
|
|
934
|
+
promptPrefix: null,
|
|
935
|
+
iconURL: undefined,
|
|
936
|
+
greeting: undefined,
|
|
937
|
+
maxContextTokens: undefined,
|
|
938
|
+
}));
|
|
939
|
+
|
|
940
|
+
export const openAISchema = tConversationSchema
|
|
745
941
|
.pick({
|
|
746
942
|
model: true,
|
|
943
|
+
modelLabel: true,
|
|
747
944
|
chatGptLabel: true,
|
|
748
945
|
promptPrefix: true,
|
|
749
946
|
temperature: true,
|
|
@@ -751,6 +948,7 @@ export const compactOpenAISchema = tConversationSchema
|
|
|
751
948
|
presence_penalty: true,
|
|
752
949
|
frequency_penalty: true,
|
|
753
950
|
resendFiles: true,
|
|
951
|
+
artifacts: true,
|
|
754
952
|
imageDetail: true,
|
|
755
953
|
stop: true,
|
|
756
954
|
iconURL: true,
|
|
@@ -759,29 +957,7 @@ export const compactOpenAISchema = tConversationSchema
|
|
|
759
957
|
maxContextTokens: true,
|
|
760
958
|
max_tokens: true,
|
|
761
959
|
})
|
|
762
|
-
.transform((obj: Partial<TConversation>) =>
|
|
763
|
-
const newObj: Partial<TConversation> = { ...obj };
|
|
764
|
-
if (newObj.temperature === 1) {
|
|
765
|
-
delete newObj.temperature;
|
|
766
|
-
}
|
|
767
|
-
if (newObj.top_p === 1) {
|
|
768
|
-
delete newObj.top_p;
|
|
769
|
-
}
|
|
770
|
-
if (newObj.presence_penalty === 0) {
|
|
771
|
-
delete newObj.presence_penalty;
|
|
772
|
-
}
|
|
773
|
-
if (newObj.frequency_penalty === 0) {
|
|
774
|
-
delete newObj.frequency_penalty;
|
|
775
|
-
}
|
|
776
|
-
if (newObj.resendFiles === true) {
|
|
777
|
-
delete newObj.resendFiles;
|
|
778
|
-
}
|
|
779
|
-
if (newObj.imageDetail === ImageDetail.auto) {
|
|
780
|
-
delete newObj.imageDetail;
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
return removeNullishValues(newObj);
|
|
784
|
-
})
|
|
960
|
+
.transform((obj: Partial<TConversation>) => removeNullishValues(obj))
|
|
785
961
|
.catch(() => ({}));
|
|
786
962
|
|
|
787
963
|
export const compactGoogleSchema = tConversationSchema
|
|
@@ -792,6 +968,7 @@ export const compactGoogleSchema = tConversationSchema
|
|
|
792
968
|
examples: true,
|
|
793
969
|
temperature: true,
|
|
794
970
|
maxOutputTokens: true,
|
|
971
|
+
artifacts: true,
|
|
795
972
|
topP: true,
|
|
796
973
|
topK: true,
|
|
797
974
|
iconURL: true,
|
|
@@ -818,7 +995,7 @@ export const compactGoogleSchema = tConversationSchema
|
|
|
818
995
|
})
|
|
819
996
|
.catch(() => ({}));
|
|
820
997
|
|
|
821
|
-
export const
|
|
998
|
+
export const anthropicSchema = tConversationSchema
|
|
822
999
|
.pick({
|
|
823
1000
|
model: true,
|
|
824
1001
|
modelLabel: true,
|
|
@@ -828,31 +1005,14 @@ export const compactAnthropicSchema = tConversationSchema
|
|
|
828
1005
|
topP: true,
|
|
829
1006
|
topK: true,
|
|
830
1007
|
resendFiles: true,
|
|
1008
|
+
promptCache: true,
|
|
1009
|
+
artifacts: true,
|
|
831
1010
|
iconURL: true,
|
|
832
1011
|
greeting: true,
|
|
833
1012
|
spec: true,
|
|
834
1013
|
maxContextTokens: true,
|
|
835
1014
|
})
|
|
836
|
-
.transform((obj) =>
|
|
837
|
-
const newObj: Partial<TConversation> = { ...obj };
|
|
838
|
-
if (newObj.temperature === 1) {
|
|
839
|
-
delete newObj.temperature;
|
|
840
|
-
}
|
|
841
|
-
if (newObj.maxOutputTokens === 4000) {
|
|
842
|
-
delete newObj.maxOutputTokens;
|
|
843
|
-
}
|
|
844
|
-
if (newObj.topP === 0.7) {
|
|
845
|
-
delete newObj.topP;
|
|
846
|
-
}
|
|
847
|
-
if (newObj.topK === 5) {
|
|
848
|
-
delete newObj.topK;
|
|
849
|
-
}
|
|
850
|
-
if (newObj.resendFiles === true) {
|
|
851
|
-
delete newObj.resendFiles;
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
return removeNullishValues(newObj);
|
|
855
|
-
})
|
|
1015
|
+
.transform((obj) => removeNullishValues(obj))
|
|
856
1016
|
.catch(() => ({}));
|
|
857
1017
|
|
|
858
1018
|
export const compactChatGPTSchema = tConversationSchema
|
|
@@ -868,6 +1028,7 @@ export const compactChatGPTSchema = tConversationSchema
|
|
|
868
1028
|
export const compactPluginsSchema = tConversationSchema
|
|
869
1029
|
.pick({
|
|
870
1030
|
model: true,
|
|
1031
|
+
modelLabel: true,
|
|
871
1032
|
chatGptLabel: true,
|
|
872
1033
|
promptPrefix: true,
|
|
873
1034
|
temperature: true,
|
|
@@ -883,6 +1044,9 @@ export const compactPluginsSchema = tConversationSchema
|
|
|
883
1044
|
})
|
|
884
1045
|
.transform((obj) => {
|
|
885
1046
|
const newObj: Partial<TConversation> = { ...obj };
|
|
1047
|
+
if (newObj.modelLabel === null) {
|
|
1048
|
+
delete newObj.modelLabel;
|
|
1049
|
+
}
|
|
886
1050
|
if (newObj.chatGptLabel === null) {
|
|
887
1051
|
delete newObj.chatGptLabel;
|
|
888
1052
|
}
|
|
@@ -918,3 +1082,27 @@ export const compactPluginsSchema = tConversationSchema
|
|
|
918
1082
|
return removeNullishValues(newObj);
|
|
919
1083
|
})
|
|
920
1084
|
.catch(() => ({}));
|
|
1085
|
+
|
|
1086
|
+
const tBannerSchema = z.object({
|
|
1087
|
+
bannerId: z.string(),
|
|
1088
|
+
message: z.string(),
|
|
1089
|
+
displayFrom: z.string(),
|
|
1090
|
+
displayTo: z.string(),
|
|
1091
|
+
createdAt: z.string(),
|
|
1092
|
+
updatedAt: z.string(),
|
|
1093
|
+
isPublic: z.boolean(),
|
|
1094
|
+
});
|
|
1095
|
+
export type TBanner = z.infer<typeof tBannerSchema>;
|
|
1096
|
+
|
|
1097
|
+
export const compactAgentsSchema = tConversationSchema
|
|
1098
|
+
.pick({
|
|
1099
|
+
model: true,
|
|
1100
|
+
agent_id: true,
|
|
1101
|
+
instructions: true,
|
|
1102
|
+
additional_instructions: true,
|
|
1103
|
+
iconURL: true,
|
|
1104
|
+
greeting: true,
|
|
1105
|
+
spec: true,
|
|
1106
|
+
})
|
|
1107
|
+
.transform(removeNullishValues)
|
|
1108
|
+
.catch(() => ({}));
|