librechat-data-provider 0.7.4 → 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 +301 -180
- 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,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];
|
|
@@ -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,43 +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
|
-
/* Prefer modelLabel over chatGptLabel */
|
|
375
|
-
chatGptLabel: z.string().nullable().optional(),
|
|
376
526
|
userLabel: z.string().optional(),
|
|
377
527
|
model: z.string().nullable().optional(),
|
|
378
528
|
promptPrefix: z.string().nullable().optional(),
|
|
379
529
|
temperature: z.number().optional(),
|
|
380
530
|
topP: z.number().optional(),
|
|
381
531
|
topK: z.number().optional(),
|
|
382
|
-
context: z.string().nullable().optional(),
|
|
383
532
|
top_p: z.number().optional(),
|
|
384
533
|
frequency_penalty: z.number().optional(),
|
|
385
534
|
presence_penalty: z.number().optional(),
|
|
386
535
|
parentMessageId: z.string().optional(),
|
|
387
|
-
maxOutputTokens:
|
|
388
|
-
agentOptions: tAgentOptionsSchema.nullable().optional(),
|
|
389
|
-
file_ids: z.array(z.string()).optional(),
|
|
536
|
+
maxOutputTokens: coerceNumber.optional(),
|
|
390
537
|
maxContextTokens: coerceNumber.optional(),
|
|
391
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(),
|
|
392
553
|
/* vision */
|
|
393
554
|
resendFiles: z.boolean().optional(),
|
|
394
555
|
imageDetail: eImageDetailSchema.optional(),
|
|
395
556
|
/* assistant */
|
|
396
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 */
|
|
397
565
|
instructions: z.string().optional(),
|
|
566
|
+
additional_instructions: z.string().optional(),
|
|
398
567
|
/** Used to overwrite active conversation settings when saving a Preset */
|
|
399
568
|
presetOverride: z.record(z.unknown()).optional(),
|
|
400
569
|
stop: z.array(z.string()).optional(),
|
|
@@ -406,6 +575,8 @@ export const tConversationSchema = z.object({
|
|
|
406
575
|
Deprecated fields
|
|
407
576
|
*/
|
|
408
577
|
/** @deprecated */
|
|
578
|
+
suggestions: z.array(z.string()).optional(),
|
|
579
|
+
/** @deprecated */
|
|
409
580
|
systemMessage: z.string().nullable().optional(),
|
|
410
581
|
/** @deprecated */
|
|
411
582
|
jailbreak: z.boolean().optional(),
|
|
@@ -421,6 +592,10 @@ export const tConversationSchema = z.object({
|
|
|
421
592
|
toneStyle: z.string().nullable().optional(),
|
|
422
593
|
/** @deprecated */
|
|
423
594
|
resendImages: z.boolean().optional(),
|
|
595
|
+
/** @deprecated */
|
|
596
|
+
agentOptions: tAgentOptionsSchema.nullable().optional(),
|
|
597
|
+
/** @deprecated Prefer `modelLabel` over `chatGptLabel` */
|
|
598
|
+
chatGptLabel: z.string().nullable().optional(),
|
|
424
599
|
});
|
|
425
600
|
|
|
426
601
|
export const tPresetSchema = tConversationSchema
|
|
@@ -476,69 +651,17 @@ export const tSharedLinkSchema = z.object({
|
|
|
476
651
|
});
|
|
477
652
|
export type TSharedLink = z.infer<typeof tSharedLinkSchema>;
|
|
478
653
|
|
|
479
|
-
export const
|
|
480
|
-
.
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
imageDetail: true,
|
|
491
|
-
stop: true,
|
|
492
|
-
iconURL: true,
|
|
493
|
-
greeting: true,
|
|
494
|
-
spec: true,
|
|
495
|
-
maxContextTokens: true,
|
|
496
|
-
max_tokens: true,
|
|
497
|
-
})
|
|
498
|
-
.transform((obj) => {
|
|
499
|
-
const result = {
|
|
500
|
-
...obj,
|
|
501
|
-
model: obj.model ?? openAISettings.model.default,
|
|
502
|
-
chatGptLabel: obj.chatGptLabel ?? obj.modelLabel ?? null,
|
|
503
|
-
promptPrefix: obj.promptPrefix ?? null,
|
|
504
|
-
temperature: obj.temperature ?? openAISettings.temperature.default,
|
|
505
|
-
top_p: obj.top_p ?? openAISettings.top_p.default,
|
|
506
|
-
presence_penalty: obj.presence_penalty ?? openAISettings.presence_penalty.default,
|
|
507
|
-
frequency_penalty: obj.frequency_penalty ?? openAISettings.frequency_penalty.default,
|
|
508
|
-
resendFiles:
|
|
509
|
-
typeof obj.resendFiles === 'boolean' ? obj.resendFiles : openAISettings.resendFiles.default,
|
|
510
|
-
imageDetail: obj.imageDetail ?? openAISettings.imageDetail.default,
|
|
511
|
-
stop: obj.stop ?? undefined,
|
|
512
|
-
iconURL: obj.iconURL ?? undefined,
|
|
513
|
-
greeting: obj.greeting ?? undefined,
|
|
514
|
-
spec: obj.spec ?? undefined,
|
|
515
|
-
maxContextTokens: obj.maxContextTokens ?? undefined,
|
|
516
|
-
max_tokens: obj.max_tokens ?? undefined,
|
|
517
|
-
};
|
|
518
|
-
|
|
519
|
-
if (obj.modelLabel) {
|
|
520
|
-
result.modelLabel = null;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
return result;
|
|
524
|
-
})
|
|
525
|
-
.catch(() => ({
|
|
526
|
-
model: openAISettings.model.default,
|
|
527
|
-
chatGptLabel: null,
|
|
528
|
-
promptPrefix: null,
|
|
529
|
-
temperature: openAISettings.temperature.default,
|
|
530
|
-
top_p: openAISettings.top_p.default,
|
|
531
|
-
presence_penalty: openAISettings.presence_penalty.default,
|
|
532
|
-
frequency_penalty: openAISettings.frequency_penalty.default,
|
|
533
|
-
resendFiles: openAISettings.resendFiles.default,
|
|
534
|
-
imageDetail: openAISettings.imageDetail.default,
|
|
535
|
-
stop: undefined,
|
|
536
|
-
iconURL: undefined,
|
|
537
|
-
greeting: undefined,
|
|
538
|
-
spec: undefined,
|
|
539
|
-
maxContextTokens: undefined,
|
|
540
|
-
max_tokens: undefined,
|
|
541
|
-
}));
|
|
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>;
|
|
542
665
|
|
|
543
666
|
export const googleSchema = tConversationSchema
|
|
544
667
|
.pick({
|
|
@@ -548,6 +671,7 @@ export const googleSchema = tConversationSchema
|
|
|
548
671
|
examples: true,
|
|
549
672
|
temperature: true,
|
|
550
673
|
maxOutputTokens: true,
|
|
674
|
+
artifacts: true,
|
|
551
675
|
topP: true,
|
|
552
676
|
topK: true,
|
|
553
677
|
iconURL: true,
|
|
@@ -622,57 +746,6 @@ export const bingAISchema = tConversationSchema
|
|
|
622
746
|
invocationId: 1,
|
|
623
747
|
}));
|
|
624
748
|
|
|
625
|
-
export const anthropicSchema = tConversationSchema
|
|
626
|
-
.pick({
|
|
627
|
-
model: true,
|
|
628
|
-
modelLabel: true,
|
|
629
|
-
promptPrefix: true,
|
|
630
|
-
temperature: true,
|
|
631
|
-
maxOutputTokens: true,
|
|
632
|
-
topP: true,
|
|
633
|
-
topK: true,
|
|
634
|
-
resendFiles: true,
|
|
635
|
-
iconURL: true,
|
|
636
|
-
greeting: true,
|
|
637
|
-
spec: true,
|
|
638
|
-
maxContextTokens: true,
|
|
639
|
-
})
|
|
640
|
-
.transform((obj) => {
|
|
641
|
-
const model = obj.model ?? anthropicSettings.model.default;
|
|
642
|
-
return {
|
|
643
|
-
...obj,
|
|
644
|
-
model,
|
|
645
|
-
modelLabel: obj.modelLabel ?? null,
|
|
646
|
-
promptPrefix: obj.promptPrefix ?? null,
|
|
647
|
-
temperature: obj.temperature ?? anthropicSettings.temperature.default,
|
|
648
|
-
maxOutputTokens: obj.maxOutputTokens ?? anthropicSettings.maxOutputTokens.reset(model),
|
|
649
|
-
topP: obj.topP ?? anthropicSettings.topP.default,
|
|
650
|
-
topK: obj.topK ?? anthropicSettings.topK.default,
|
|
651
|
-
resendFiles:
|
|
652
|
-
typeof obj.resendFiles === 'boolean'
|
|
653
|
-
? obj.resendFiles
|
|
654
|
-
: anthropicSettings.resendFiles.default,
|
|
655
|
-
iconURL: obj.iconURL ?? undefined,
|
|
656
|
-
greeting: obj.greeting ?? undefined,
|
|
657
|
-
spec: obj.spec ?? undefined,
|
|
658
|
-
maxContextTokens: obj.maxContextTokens ?? anthropicSettings.maxContextTokens.default,
|
|
659
|
-
};
|
|
660
|
-
})
|
|
661
|
-
.catch(() => ({
|
|
662
|
-
model: anthropicSettings.model.default,
|
|
663
|
-
modelLabel: null,
|
|
664
|
-
promptPrefix: null,
|
|
665
|
-
temperature: anthropicSettings.temperature.default,
|
|
666
|
-
maxOutputTokens: anthropicSettings.maxOutputTokens.default,
|
|
667
|
-
topP: anthropicSettings.topP.default,
|
|
668
|
-
topK: anthropicSettings.topK.default,
|
|
669
|
-
resendFiles: anthropicSettings.resendFiles.default,
|
|
670
|
-
iconURL: undefined,
|
|
671
|
-
greeting: undefined,
|
|
672
|
-
spec: undefined,
|
|
673
|
-
maxContextTokens: anthropicSettings.maxContextTokens.default,
|
|
674
|
-
}));
|
|
675
|
-
|
|
676
749
|
export const chatGPTBrowserSchema = tConversationSchema
|
|
677
750
|
.pick({
|
|
678
751
|
model: true,
|
|
@@ -692,6 +765,7 @@ export const gptPluginsSchema = tConversationSchema
|
|
|
692
765
|
chatGptLabel: true,
|
|
693
766
|
promptPrefix: true,
|
|
694
767
|
temperature: true,
|
|
768
|
+
artifacts: true,
|
|
695
769
|
top_p: true,
|
|
696
770
|
presence_penalty: true,
|
|
697
771
|
frequency_penalty: true,
|
|
@@ -725,7 +799,7 @@ export const gptPluginsSchema = tConversationSchema
|
|
|
725
799
|
maxContextTokens: obj.maxContextTokens ?? undefined,
|
|
726
800
|
};
|
|
727
801
|
|
|
728
|
-
if (obj.modelLabel) {
|
|
802
|
+
if (obj.modelLabel != null && obj.modelLabel !== '') {
|
|
729
803
|
result.modelLabel = null;
|
|
730
804
|
}
|
|
731
805
|
|
|
@@ -752,16 +826,17 @@ export const gptPluginsSchema = tConversationSchema
|
|
|
752
826
|
maxContextTokens: undefined,
|
|
753
827
|
}));
|
|
754
828
|
|
|
755
|
-
export function removeNullishValues<T extends
|
|
829
|
+
export function removeNullishValues<T extends Record<string, unknown>>(obj: T): Partial<T> {
|
|
756
830
|
const newObj: Partial<T> = { ...obj };
|
|
757
831
|
|
|
758
832
|
(Object.keys(newObj) as Array<keyof T>).forEach((key) => {
|
|
759
|
-
|
|
833
|
+
const value = newObj[key];
|
|
834
|
+
if (value === undefined || value === null) {
|
|
760
835
|
delete newObj[key];
|
|
761
836
|
}
|
|
762
837
|
});
|
|
763
838
|
|
|
764
|
-
return newObj
|
|
839
|
+
return newObj;
|
|
765
840
|
}
|
|
766
841
|
|
|
767
842
|
export const assistantSchema = tConversationSchema
|
|
@@ -769,6 +844,7 @@ export const assistantSchema = tConversationSchema
|
|
|
769
844
|
model: true,
|
|
770
845
|
assistant_id: true,
|
|
771
846
|
instructions: true,
|
|
847
|
+
artifacts: true,
|
|
772
848
|
promptPrefix: true,
|
|
773
849
|
iconURL: true,
|
|
774
850
|
greeting: true,
|
|
@@ -800,6 +876,7 @@ export const compactAssistantSchema = tConversationSchema
|
|
|
800
876
|
assistant_id: true,
|
|
801
877
|
instructions: true,
|
|
802
878
|
promptPrefix: true,
|
|
879
|
+
artifacts: true,
|
|
803
880
|
iconURL: true,
|
|
804
881
|
greeting: true,
|
|
805
882
|
spec: true,
|
|
@@ -808,9 +885,62 @@ export const compactAssistantSchema = tConversationSchema
|
|
|
808
885
|
.transform(removeNullishValues)
|
|
809
886
|
.catch(() => ({}));
|
|
810
887
|
|
|
811
|
-
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
|
|
812
941
|
.pick({
|
|
813
942
|
model: true,
|
|
943
|
+
modelLabel: true,
|
|
814
944
|
chatGptLabel: true,
|
|
815
945
|
promptPrefix: true,
|
|
816
946
|
temperature: true,
|
|
@@ -818,6 +948,7 @@ export const compactOpenAISchema = tConversationSchema
|
|
|
818
948
|
presence_penalty: true,
|
|
819
949
|
frequency_penalty: true,
|
|
820
950
|
resendFiles: true,
|
|
951
|
+
artifacts: true,
|
|
821
952
|
imageDetail: true,
|
|
822
953
|
stop: true,
|
|
823
954
|
iconURL: true,
|
|
@@ -826,29 +957,7 @@ export const compactOpenAISchema = tConversationSchema
|
|
|
826
957
|
maxContextTokens: true,
|
|
827
958
|
max_tokens: true,
|
|
828
959
|
})
|
|
829
|
-
.transform((obj: Partial<TConversation>) =>
|
|
830
|
-
const newObj: Partial<TConversation> = { ...obj };
|
|
831
|
-
if (newObj.temperature === 1) {
|
|
832
|
-
delete newObj.temperature;
|
|
833
|
-
}
|
|
834
|
-
if (newObj.top_p === 1) {
|
|
835
|
-
delete newObj.top_p;
|
|
836
|
-
}
|
|
837
|
-
if (newObj.presence_penalty === 0) {
|
|
838
|
-
delete newObj.presence_penalty;
|
|
839
|
-
}
|
|
840
|
-
if (newObj.frequency_penalty === 0) {
|
|
841
|
-
delete newObj.frequency_penalty;
|
|
842
|
-
}
|
|
843
|
-
if (newObj.resendFiles === true) {
|
|
844
|
-
delete newObj.resendFiles;
|
|
845
|
-
}
|
|
846
|
-
if (newObj.imageDetail === ImageDetail.auto) {
|
|
847
|
-
delete newObj.imageDetail;
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
return removeNullishValues(newObj);
|
|
851
|
-
})
|
|
960
|
+
.transform((obj: Partial<TConversation>) => removeNullishValues(obj))
|
|
852
961
|
.catch(() => ({}));
|
|
853
962
|
|
|
854
963
|
export const compactGoogleSchema = tConversationSchema
|
|
@@ -859,6 +968,7 @@ export const compactGoogleSchema = tConversationSchema
|
|
|
859
968
|
examples: true,
|
|
860
969
|
temperature: true,
|
|
861
970
|
maxOutputTokens: true,
|
|
971
|
+
artifacts: true,
|
|
862
972
|
topP: true,
|
|
863
973
|
topK: true,
|
|
864
974
|
iconURL: true,
|
|
@@ -885,7 +995,7 @@ export const compactGoogleSchema = tConversationSchema
|
|
|
885
995
|
})
|
|
886
996
|
.catch(() => ({}));
|
|
887
997
|
|
|
888
|
-
export const
|
|
998
|
+
export const anthropicSchema = tConversationSchema
|
|
889
999
|
.pick({
|
|
890
1000
|
model: true,
|
|
891
1001
|
modelLabel: true,
|
|
@@ -895,31 +1005,14 @@ export const compactAnthropicSchema = tConversationSchema
|
|
|
895
1005
|
topP: true,
|
|
896
1006
|
topK: true,
|
|
897
1007
|
resendFiles: true,
|
|
1008
|
+
promptCache: true,
|
|
1009
|
+
artifacts: true,
|
|
898
1010
|
iconURL: true,
|
|
899
1011
|
greeting: true,
|
|
900
1012
|
spec: true,
|
|
901
1013
|
maxContextTokens: true,
|
|
902
1014
|
})
|
|
903
|
-
.transform((obj) =>
|
|
904
|
-
const newObj: Partial<TConversation> = { ...obj };
|
|
905
|
-
if (newObj.temperature === anthropicSettings.temperature.default) {
|
|
906
|
-
delete newObj.temperature;
|
|
907
|
-
}
|
|
908
|
-
if (newObj.maxOutputTokens === anthropicSettings.legacy.maxOutputTokens.default) {
|
|
909
|
-
delete newObj.maxOutputTokens;
|
|
910
|
-
}
|
|
911
|
-
if (newObj.topP === anthropicSettings.topP.default) {
|
|
912
|
-
delete newObj.topP;
|
|
913
|
-
}
|
|
914
|
-
if (newObj.topK === anthropicSettings.topK.default) {
|
|
915
|
-
delete newObj.topK;
|
|
916
|
-
}
|
|
917
|
-
if (newObj.resendFiles === anthropicSettings.resendFiles.default) {
|
|
918
|
-
delete newObj.resendFiles;
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
return removeNullishValues(newObj);
|
|
922
|
-
})
|
|
1015
|
+
.transform((obj) => removeNullishValues(obj))
|
|
923
1016
|
.catch(() => ({}));
|
|
924
1017
|
|
|
925
1018
|
export const compactChatGPTSchema = tConversationSchema
|
|
@@ -935,6 +1028,7 @@ export const compactChatGPTSchema = tConversationSchema
|
|
|
935
1028
|
export const compactPluginsSchema = tConversationSchema
|
|
936
1029
|
.pick({
|
|
937
1030
|
model: true,
|
|
1031
|
+
modelLabel: true,
|
|
938
1032
|
chatGptLabel: true,
|
|
939
1033
|
promptPrefix: true,
|
|
940
1034
|
temperature: true,
|
|
@@ -950,6 +1044,9 @@ export const compactPluginsSchema = tConversationSchema
|
|
|
950
1044
|
})
|
|
951
1045
|
.transform((obj) => {
|
|
952
1046
|
const newObj: Partial<TConversation> = { ...obj };
|
|
1047
|
+
if (newObj.modelLabel === null) {
|
|
1048
|
+
delete newObj.modelLabel;
|
|
1049
|
+
}
|
|
953
1050
|
if (newObj.chatGptLabel === null) {
|
|
954
1051
|
delete newObj.chatGptLabel;
|
|
955
1052
|
}
|
|
@@ -985,3 +1082,27 @@ export const compactPluginsSchema = tConversationSchema
|
|
|
985
1082
|
return removeNullishValues(newObj);
|
|
986
1083
|
})
|
|
987
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(() => ({}));
|