librechat-data-provider 0.7.41 → 0.7.52
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 +575 -29
- package/specs/openapiSpecs.ts +127 -0
- package/src/actions.ts +207 -61
- package/src/api-endpoints.ts +22 -2
- package/src/artifacts.ts +3104 -0
- package/src/bedrock.ts +147 -0
- package/src/config.ts +174 -22
- package/src/data-service.ts +218 -75
- package/src/file-config.ts +4 -1
- package/src/generate.ts +30 -1
- package/src/index.ts +5 -0
- package/src/keys.ts +10 -0
- package/src/parsers.ts +85 -27
- package/src/react-query/react-query-service.ts +32 -7
- package/src/request.ts +3 -0
- package/src/roles.ts +59 -2
- package/src/schemas.ts +293 -184
- package/src/types/agents.ts +220 -0
- package/src/types/assistants.ts +152 -27
- package/src/types/files.ts +6 -0
- package/src/types/mutations.ts +72 -0
- package/src/types/queries.ts +14 -11
- package/src/types/runs.ts +22 -0
- package/src/types.ts +35 -4
package/src/schemas.ts
CHANGED
|
@@ -8,7 +8,7 @@ export const isUUID = z.string().uuid();
|
|
|
8
8
|
export enum AuthType {
|
|
9
9
|
OVERRIDE_AUTH = 'override_auth',
|
|
10
10
|
USER_PROVIDED = 'user_provided',
|
|
11
|
-
SYSTEM_DEFINED = '
|
|
11
|
+
SYSTEM_DEFINED = 'system_defined',
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const authTypeSchema = z.nativeEnum(AuthType);
|
|
@@ -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,7 +232,7 @@ 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
|
};
|
|
@@ -160,7 +241,7 @@ const ANTHROPIC_MAX_OUTPUT = 8192;
|
|
|
160
241
|
const LEGACY_ANTHROPIC_MAX_OUTPUT = 4096;
|
|
161
242
|
export const anthropicSettings = {
|
|
162
243
|
model: {
|
|
163
|
-
default: 'claude-3-5-sonnet-
|
|
244
|
+
default: 'claude-3-5-sonnet-20241022',
|
|
164
245
|
},
|
|
165
246
|
temperature: {
|
|
166
247
|
min: 0,
|
|
@@ -168,6 +249,9 @@ export const anthropicSettings = {
|
|
|
168
249
|
step: 0.01,
|
|
169
250
|
default: 1,
|
|
170
251
|
},
|
|
252
|
+
promptCache: {
|
|
253
|
+
default: true,
|
|
254
|
+
},
|
|
171
255
|
maxOutputTokens: {
|
|
172
256
|
min: 1,
|
|
173
257
|
max: ANTHROPIC_MAX_OUTPUT,
|
|
@@ -216,10 +300,54 @@ export const anthropicSettings = {
|
|
|
216
300
|
},
|
|
217
301
|
};
|
|
218
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
|
+
|
|
219
345
|
export const endpointSettings = {
|
|
220
346
|
[EModelEndpoint.openAI]: openAISettings,
|
|
221
347
|
[EModelEndpoint.google]: googleSettings,
|
|
222
348
|
[EModelEndpoint.anthropic]: anthropicSettings,
|
|
349
|
+
[EModelEndpoint.agents]: agentsSettings,
|
|
350
|
+
[EModelEndpoint.bedrock]: agentsSettings,
|
|
223
351
|
};
|
|
224
352
|
|
|
225
353
|
const google = endpointSettings[EModelEndpoint.google];
|
|
@@ -241,7 +369,7 @@ export const tPluginSchema = z.object({
|
|
|
241
369
|
pluginKey: z.string(),
|
|
242
370
|
description: z.string(),
|
|
243
371
|
icon: z.string(),
|
|
244
|
-
authConfig: z.array(tPluginAuthConfigSchema),
|
|
372
|
+
authConfig: z.array(tPluginAuthConfigSchema).optional(),
|
|
245
373
|
authenticated: z.boolean().optional(),
|
|
246
374
|
isButton: z.boolean().optional(),
|
|
247
375
|
});
|
|
@@ -341,6 +469,13 @@ export const tMessageSchema = z.object({
|
|
|
341
469
|
iconURL: z.string().optional(),
|
|
342
470
|
});
|
|
343
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
|
+
|
|
344
479
|
export type TMessage = z.input<typeof tMessageSchema> & {
|
|
345
480
|
children?: TMessage[];
|
|
346
481
|
plugin?: TResPlugin | null;
|
|
@@ -349,6 +484,7 @@ export type TMessage = z.input<typeof tMessageSchema> & {
|
|
|
349
484
|
files?: Partial<TFile>[];
|
|
350
485
|
depth?: number;
|
|
351
486
|
siblingIndex?: number;
|
|
487
|
+
attachments?: TAttachment[];
|
|
352
488
|
};
|
|
353
489
|
|
|
354
490
|
export const coerceNumber = z.union([z.number(), z.string()]).transform((val) => {
|
|
@@ -358,44 +494,76 @@ export const coerceNumber = z.union([z.number(), z.string()]).transform((val) =>
|
|
|
358
494
|
return val;
|
|
359
495
|
});
|
|
360
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
|
+
|
|
361
516
|
export const tConversationSchema = z.object({
|
|
362
517
|
conversationId: z.string().nullable(),
|
|
363
|
-
title: z.string().nullable().or(z.literal('New Chat')).default('New Chat'),
|
|
364
|
-
user: z.string().optional(),
|
|
365
518
|
endpoint: eModelEndpointSchema.nullable(),
|
|
366
519
|
endpointType: eModelEndpointSchema.optional(),
|
|
367
|
-
|
|
520
|
+
isArchived: z.boolean().optional(),
|
|
521
|
+
title: z.string().nullable().or(z.literal('New Chat')).default('New Chat'),
|
|
522
|
+
user: z.string().optional(),
|
|
368
523
|
messages: z.array(z.string()).optional(),
|
|
369
524
|
tools: z.union([z.array(tPluginSchema), z.array(z.string())]).optional(),
|
|
370
|
-
createdAt: z.string(),
|
|
371
|
-
updatedAt: z.string(),
|
|
372
525
|
modelLabel: z.string().nullable().optional(),
|
|
373
|
-
examples: z.array(tExampleSchema).optional(),
|
|
374
|
-
tags: z.array(z.string()).optional(),
|
|
375
|
-
/* Prefer modelLabel over chatGptLabel */
|
|
376
|
-
chatGptLabel: z.string().nullable().optional(),
|
|
377
526
|
userLabel: z.string().optional(),
|
|
378
527
|
model: z.string().nullable().optional(),
|
|
379
528
|
promptPrefix: z.string().nullable().optional(),
|
|
380
529
|
temperature: z.number().optional(),
|
|
381
530
|
topP: z.number().optional(),
|
|
382
531
|
topK: z.number().optional(),
|
|
383
|
-
context: z.string().nullable().optional(),
|
|
384
532
|
top_p: z.number().optional(),
|
|
385
533
|
frequency_penalty: z.number().optional(),
|
|
386
534
|
presence_penalty: z.number().optional(),
|
|
387
535
|
parentMessageId: z.string().optional(),
|
|
388
|
-
maxOutputTokens:
|
|
389
|
-
agentOptions: tAgentOptionsSchema.nullable().optional(),
|
|
390
|
-
file_ids: z.array(z.string()).optional(),
|
|
536
|
+
maxOutputTokens: coerceNumber.optional(),
|
|
391
537
|
maxContextTokens: coerceNumber.optional(),
|
|
392
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(),
|
|
393
553
|
/* vision */
|
|
394
554
|
resendFiles: z.boolean().optional(),
|
|
395
555
|
imageDetail: eImageDetailSchema.optional(),
|
|
396
556
|
/* assistant */
|
|
397
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 */
|
|
398
565
|
instructions: z.string().optional(),
|
|
566
|
+
additional_instructions: z.string().optional(),
|
|
399
567
|
/** Used to overwrite active conversation settings when saving a Preset */
|
|
400
568
|
presetOverride: z.record(z.unknown()).optional(),
|
|
401
569
|
stop: z.array(z.string()).optional(),
|
|
@@ -407,6 +575,8 @@ export const tConversationSchema = z.object({
|
|
|
407
575
|
Deprecated fields
|
|
408
576
|
*/
|
|
409
577
|
/** @deprecated */
|
|
578
|
+
suggestions: z.array(z.string()).optional(),
|
|
579
|
+
/** @deprecated */
|
|
410
580
|
systemMessage: z.string().nullable().optional(),
|
|
411
581
|
/** @deprecated */
|
|
412
582
|
jailbreak: z.boolean().optional(),
|
|
@@ -422,6 +592,10 @@ export const tConversationSchema = z.object({
|
|
|
422
592
|
toneStyle: z.string().nullable().optional(),
|
|
423
593
|
/** @deprecated */
|
|
424
594
|
resendImages: z.boolean().optional(),
|
|
595
|
+
/** @deprecated */
|
|
596
|
+
agentOptions: tAgentOptionsSchema.nullable().optional(),
|
|
597
|
+
/** @deprecated Prefer `modelLabel` over `chatGptLabel` */
|
|
598
|
+
chatGptLabel: z.string().nullable().optional(),
|
|
425
599
|
});
|
|
426
600
|
|
|
427
601
|
export const tPresetSchema = tConversationSchema
|
|
@@ -478,6 +652,7 @@ export const tSharedLinkSchema = z.object({
|
|
|
478
652
|
export type TSharedLink = z.infer<typeof tSharedLinkSchema>;
|
|
479
653
|
|
|
480
654
|
export const tConversationTagSchema = z.object({
|
|
655
|
+
_id: z.string(),
|
|
481
656
|
user: z.string(),
|
|
482
657
|
tag: z.string(),
|
|
483
658
|
description: z.string().optional(),
|
|
@@ -488,70 +663,6 @@ export const tConversationTagSchema = z.object({
|
|
|
488
663
|
});
|
|
489
664
|
export type TConversationTag = z.infer<typeof tConversationTagSchema>;
|
|
490
665
|
|
|
491
|
-
export const openAISchema = tConversationSchema
|
|
492
|
-
.pick({
|
|
493
|
-
model: true,
|
|
494
|
-
modelLabel: true,
|
|
495
|
-
chatGptLabel: true,
|
|
496
|
-
promptPrefix: true,
|
|
497
|
-
temperature: true,
|
|
498
|
-
top_p: true,
|
|
499
|
-
presence_penalty: true,
|
|
500
|
-
frequency_penalty: true,
|
|
501
|
-
resendFiles: true,
|
|
502
|
-
imageDetail: true,
|
|
503
|
-
stop: true,
|
|
504
|
-
iconURL: true,
|
|
505
|
-
greeting: true,
|
|
506
|
-
spec: true,
|
|
507
|
-
maxContextTokens: true,
|
|
508
|
-
max_tokens: true,
|
|
509
|
-
})
|
|
510
|
-
.transform((obj) => {
|
|
511
|
-
const result = {
|
|
512
|
-
...obj,
|
|
513
|
-
model: obj.model ?? openAISettings.model.default,
|
|
514
|
-
chatGptLabel: obj.chatGptLabel ?? obj.modelLabel ?? null,
|
|
515
|
-
promptPrefix: obj.promptPrefix ?? null,
|
|
516
|
-
temperature: obj.temperature ?? openAISettings.temperature.default,
|
|
517
|
-
top_p: obj.top_p ?? openAISettings.top_p.default,
|
|
518
|
-
presence_penalty: obj.presence_penalty ?? openAISettings.presence_penalty.default,
|
|
519
|
-
frequency_penalty: obj.frequency_penalty ?? openAISettings.frequency_penalty.default,
|
|
520
|
-
resendFiles:
|
|
521
|
-
typeof obj.resendFiles === 'boolean' ? obj.resendFiles : openAISettings.resendFiles.default,
|
|
522
|
-
imageDetail: obj.imageDetail ?? openAISettings.imageDetail.default,
|
|
523
|
-
stop: obj.stop ?? undefined,
|
|
524
|
-
iconURL: obj.iconURL ?? undefined,
|
|
525
|
-
greeting: obj.greeting ?? undefined,
|
|
526
|
-
spec: obj.spec ?? undefined,
|
|
527
|
-
maxContextTokens: obj.maxContextTokens ?? undefined,
|
|
528
|
-
max_tokens: obj.max_tokens ?? undefined,
|
|
529
|
-
};
|
|
530
|
-
|
|
531
|
-
if (obj.modelLabel) {
|
|
532
|
-
result.modelLabel = null;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
return result;
|
|
536
|
-
})
|
|
537
|
-
.catch(() => ({
|
|
538
|
-
model: openAISettings.model.default,
|
|
539
|
-
chatGptLabel: null,
|
|
540
|
-
promptPrefix: null,
|
|
541
|
-
temperature: openAISettings.temperature.default,
|
|
542
|
-
top_p: openAISettings.top_p.default,
|
|
543
|
-
presence_penalty: openAISettings.presence_penalty.default,
|
|
544
|
-
frequency_penalty: openAISettings.frequency_penalty.default,
|
|
545
|
-
resendFiles: openAISettings.resendFiles.default,
|
|
546
|
-
imageDetail: openAISettings.imageDetail.default,
|
|
547
|
-
stop: undefined,
|
|
548
|
-
iconURL: undefined,
|
|
549
|
-
greeting: undefined,
|
|
550
|
-
spec: undefined,
|
|
551
|
-
maxContextTokens: undefined,
|
|
552
|
-
max_tokens: undefined,
|
|
553
|
-
}));
|
|
554
|
-
|
|
555
666
|
export const googleSchema = tConversationSchema
|
|
556
667
|
.pick({
|
|
557
668
|
model: true,
|
|
@@ -560,6 +671,7 @@ export const googleSchema = tConversationSchema
|
|
|
560
671
|
examples: true,
|
|
561
672
|
temperature: true,
|
|
562
673
|
maxOutputTokens: true,
|
|
674
|
+
artifacts: true,
|
|
563
675
|
topP: true,
|
|
564
676
|
topK: true,
|
|
565
677
|
iconURL: true,
|
|
@@ -634,57 +746,6 @@ export const bingAISchema = tConversationSchema
|
|
|
634
746
|
invocationId: 1,
|
|
635
747
|
}));
|
|
636
748
|
|
|
637
|
-
export const anthropicSchema = tConversationSchema
|
|
638
|
-
.pick({
|
|
639
|
-
model: true,
|
|
640
|
-
modelLabel: true,
|
|
641
|
-
promptPrefix: true,
|
|
642
|
-
temperature: true,
|
|
643
|
-
maxOutputTokens: true,
|
|
644
|
-
topP: true,
|
|
645
|
-
topK: true,
|
|
646
|
-
resendFiles: true,
|
|
647
|
-
iconURL: true,
|
|
648
|
-
greeting: true,
|
|
649
|
-
spec: true,
|
|
650
|
-
maxContextTokens: true,
|
|
651
|
-
})
|
|
652
|
-
.transform((obj) => {
|
|
653
|
-
const model = obj.model ?? anthropicSettings.model.default;
|
|
654
|
-
return {
|
|
655
|
-
...obj,
|
|
656
|
-
model,
|
|
657
|
-
modelLabel: obj.modelLabel ?? null,
|
|
658
|
-
promptPrefix: obj.promptPrefix ?? null,
|
|
659
|
-
temperature: obj.temperature ?? anthropicSettings.temperature.default,
|
|
660
|
-
maxOutputTokens: obj.maxOutputTokens ?? anthropicSettings.maxOutputTokens.reset(model),
|
|
661
|
-
topP: obj.topP ?? anthropicSettings.topP.default,
|
|
662
|
-
topK: obj.topK ?? anthropicSettings.topK.default,
|
|
663
|
-
resendFiles:
|
|
664
|
-
typeof obj.resendFiles === 'boolean'
|
|
665
|
-
? obj.resendFiles
|
|
666
|
-
: anthropicSettings.resendFiles.default,
|
|
667
|
-
iconURL: obj.iconURL ?? undefined,
|
|
668
|
-
greeting: obj.greeting ?? undefined,
|
|
669
|
-
spec: obj.spec ?? undefined,
|
|
670
|
-
maxContextTokens: obj.maxContextTokens ?? anthropicSettings.maxContextTokens.default,
|
|
671
|
-
};
|
|
672
|
-
})
|
|
673
|
-
.catch(() => ({
|
|
674
|
-
model: anthropicSettings.model.default,
|
|
675
|
-
modelLabel: null,
|
|
676
|
-
promptPrefix: null,
|
|
677
|
-
temperature: anthropicSettings.temperature.default,
|
|
678
|
-
maxOutputTokens: anthropicSettings.maxOutputTokens.default,
|
|
679
|
-
topP: anthropicSettings.topP.default,
|
|
680
|
-
topK: anthropicSettings.topK.default,
|
|
681
|
-
resendFiles: anthropicSettings.resendFiles.default,
|
|
682
|
-
iconURL: undefined,
|
|
683
|
-
greeting: undefined,
|
|
684
|
-
spec: undefined,
|
|
685
|
-
maxContextTokens: anthropicSettings.maxContextTokens.default,
|
|
686
|
-
}));
|
|
687
|
-
|
|
688
749
|
export const chatGPTBrowserSchema = tConversationSchema
|
|
689
750
|
.pick({
|
|
690
751
|
model: true,
|
|
@@ -704,6 +765,7 @@ export const gptPluginsSchema = tConversationSchema
|
|
|
704
765
|
chatGptLabel: true,
|
|
705
766
|
promptPrefix: true,
|
|
706
767
|
temperature: true,
|
|
768
|
+
artifacts: true,
|
|
707
769
|
top_p: true,
|
|
708
770
|
presence_penalty: true,
|
|
709
771
|
frequency_penalty: true,
|
|
@@ -737,7 +799,7 @@ export const gptPluginsSchema = tConversationSchema
|
|
|
737
799
|
maxContextTokens: obj.maxContextTokens ?? undefined,
|
|
738
800
|
};
|
|
739
801
|
|
|
740
|
-
if (obj.modelLabel) {
|
|
802
|
+
if (obj.modelLabel != null && obj.modelLabel !== '') {
|
|
741
803
|
result.modelLabel = null;
|
|
742
804
|
}
|
|
743
805
|
|
|
@@ -764,16 +826,17 @@ export const gptPluginsSchema = tConversationSchema
|
|
|
764
826
|
maxContextTokens: undefined,
|
|
765
827
|
}));
|
|
766
828
|
|
|
767
|
-
export function removeNullishValues<T extends
|
|
829
|
+
export function removeNullishValues<T extends Record<string, unknown>>(obj: T): Partial<T> {
|
|
768
830
|
const newObj: Partial<T> = { ...obj };
|
|
769
831
|
|
|
770
832
|
(Object.keys(newObj) as Array<keyof T>).forEach((key) => {
|
|
771
|
-
|
|
833
|
+
const value = newObj[key];
|
|
834
|
+
if (value === undefined || value === null) {
|
|
772
835
|
delete newObj[key];
|
|
773
836
|
}
|
|
774
837
|
});
|
|
775
838
|
|
|
776
|
-
return newObj
|
|
839
|
+
return newObj;
|
|
777
840
|
}
|
|
778
841
|
|
|
779
842
|
export const assistantSchema = tConversationSchema
|
|
@@ -781,6 +844,7 @@ export const assistantSchema = tConversationSchema
|
|
|
781
844
|
model: true,
|
|
782
845
|
assistant_id: true,
|
|
783
846
|
instructions: true,
|
|
847
|
+
artifacts: true,
|
|
784
848
|
promptPrefix: true,
|
|
785
849
|
iconURL: true,
|
|
786
850
|
greeting: true,
|
|
@@ -812,6 +876,7 @@ export const compactAssistantSchema = tConversationSchema
|
|
|
812
876
|
assistant_id: true,
|
|
813
877
|
instructions: true,
|
|
814
878
|
promptPrefix: true,
|
|
879
|
+
artifacts: true,
|
|
815
880
|
iconURL: true,
|
|
816
881
|
greeting: true,
|
|
817
882
|
spec: true,
|
|
@@ -820,9 +885,62 @@ export const compactAssistantSchema = tConversationSchema
|
|
|
820
885
|
.transform(removeNullishValues)
|
|
821
886
|
.catch(() => ({}));
|
|
822
887
|
|
|
823
|
-
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
|
|
824
941
|
.pick({
|
|
825
942
|
model: true,
|
|
943
|
+
modelLabel: true,
|
|
826
944
|
chatGptLabel: true,
|
|
827
945
|
promptPrefix: true,
|
|
828
946
|
temperature: true,
|
|
@@ -830,6 +948,7 @@ export const compactOpenAISchema = tConversationSchema
|
|
|
830
948
|
presence_penalty: true,
|
|
831
949
|
frequency_penalty: true,
|
|
832
950
|
resendFiles: true,
|
|
951
|
+
artifacts: true,
|
|
833
952
|
imageDetail: true,
|
|
834
953
|
stop: true,
|
|
835
954
|
iconURL: true,
|
|
@@ -838,29 +957,7 @@ export const compactOpenAISchema = tConversationSchema
|
|
|
838
957
|
maxContextTokens: true,
|
|
839
958
|
max_tokens: true,
|
|
840
959
|
})
|
|
841
|
-
.transform((obj: Partial<TConversation>) =>
|
|
842
|
-
const newObj: Partial<TConversation> = { ...obj };
|
|
843
|
-
if (newObj.temperature === 1) {
|
|
844
|
-
delete newObj.temperature;
|
|
845
|
-
}
|
|
846
|
-
if (newObj.top_p === 1) {
|
|
847
|
-
delete newObj.top_p;
|
|
848
|
-
}
|
|
849
|
-
if (newObj.presence_penalty === 0) {
|
|
850
|
-
delete newObj.presence_penalty;
|
|
851
|
-
}
|
|
852
|
-
if (newObj.frequency_penalty === 0) {
|
|
853
|
-
delete newObj.frequency_penalty;
|
|
854
|
-
}
|
|
855
|
-
if (newObj.resendFiles === true) {
|
|
856
|
-
delete newObj.resendFiles;
|
|
857
|
-
}
|
|
858
|
-
if (newObj.imageDetail === ImageDetail.auto) {
|
|
859
|
-
delete newObj.imageDetail;
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
return removeNullishValues(newObj);
|
|
863
|
-
})
|
|
960
|
+
.transform((obj: Partial<TConversation>) => removeNullishValues(obj))
|
|
864
961
|
.catch(() => ({}));
|
|
865
962
|
|
|
866
963
|
export const compactGoogleSchema = tConversationSchema
|
|
@@ -871,6 +968,7 @@ export const compactGoogleSchema = tConversationSchema
|
|
|
871
968
|
examples: true,
|
|
872
969
|
temperature: true,
|
|
873
970
|
maxOutputTokens: true,
|
|
971
|
+
artifacts: true,
|
|
874
972
|
topP: true,
|
|
875
973
|
topK: true,
|
|
876
974
|
iconURL: true,
|
|
@@ -897,7 +995,7 @@ export const compactGoogleSchema = tConversationSchema
|
|
|
897
995
|
})
|
|
898
996
|
.catch(() => ({}));
|
|
899
997
|
|
|
900
|
-
export const
|
|
998
|
+
export const anthropicSchema = tConversationSchema
|
|
901
999
|
.pick({
|
|
902
1000
|
model: true,
|
|
903
1001
|
modelLabel: true,
|
|
@@ -907,31 +1005,14 @@ export const compactAnthropicSchema = tConversationSchema
|
|
|
907
1005
|
topP: true,
|
|
908
1006
|
topK: true,
|
|
909
1007
|
resendFiles: true,
|
|
1008
|
+
promptCache: true,
|
|
1009
|
+
artifacts: true,
|
|
910
1010
|
iconURL: true,
|
|
911
1011
|
greeting: true,
|
|
912
1012
|
spec: true,
|
|
913
1013
|
maxContextTokens: true,
|
|
914
1014
|
})
|
|
915
|
-
.transform((obj) =>
|
|
916
|
-
const newObj: Partial<TConversation> = { ...obj };
|
|
917
|
-
if (newObj.temperature === anthropicSettings.temperature.default) {
|
|
918
|
-
delete newObj.temperature;
|
|
919
|
-
}
|
|
920
|
-
if (newObj.maxOutputTokens === anthropicSettings.legacy.maxOutputTokens.default) {
|
|
921
|
-
delete newObj.maxOutputTokens;
|
|
922
|
-
}
|
|
923
|
-
if (newObj.topP === anthropicSettings.topP.default) {
|
|
924
|
-
delete newObj.topP;
|
|
925
|
-
}
|
|
926
|
-
if (newObj.topK === anthropicSettings.topK.default) {
|
|
927
|
-
delete newObj.topK;
|
|
928
|
-
}
|
|
929
|
-
if (newObj.resendFiles === anthropicSettings.resendFiles.default) {
|
|
930
|
-
delete newObj.resendFiles;
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
return removeNullishValues(newObj);
|
|
934
|
-
})
|
|
1015
|
+
.transform((obj) => removeNullishValues(obj))
|
|
935
1016
|
.catch(() => ({}));
|
|
936
1017
|
|
|
937
1018
|
export const compactChatGPTSchema = tConversationSchema
|
|
@@ -947,6 +1028,7 @@ export const compactChatGPTSchema = tConversationSchema
|
|
|
947
1028
|
export const compactPluginsSchema = tConversationSchema
|
|
948
1029
|
.pick({
|
|
949
1030
|
model: true,
|
|
1031
|
+
modelLabel: true,
|
|
950
1032
|
chatGptLabel: true,
|
|
951
1033
|
promptPrefix: true,
|
|
952
1034
|
temperature: true,
|
|
@@ -962,6 +1044,9 @@ export const compactPluginsSchema = tConversationSchema
|
|
|
962
1044
|
})
|
|
963
1045
|
.transform((obj) => {
|
|
964
1046
|
const newObj: Partial<TConversation> = { ...obj };
|
|
1047
|
+
if (newObj.modelLabel === null) {
|
|
1048
|
+
delete newObj.modelLabel;
|
|
1049
|
+
}
|
|
965
1050
|
if (newObj.chatGptLabel === null) {
|
|
966
1051
|
delete newObj.chatGptLabel;
|
|
967
1052
|
}
|
|
@@ -997,3 +1082,27 @@ export const compactPluginsSchema = tConversationSchema
|
|
|
997
1082
|
return removeNullishValues(newObj);
|
|
998
1083
|
})
|
|
999
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(() => ({}));
|