librechat-data-provider 0.7.68 → 0.7.71
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 +2 -2
- package/server-rollup.config.js +1 -1
- package/specs/actions.spec.ts +125 -7
- package/specs/filetypes.spec.ts +1 -7
- package/specs/mcp.spec.ts +52 -0
- package/specs/utils.spec.ts +129 -0
- package/src/actions.ts +100 -44
- package/src/api-endpoints.ts +23 -5
- package/src/azure.ts +2 -1
- package/src/bedrock.ts +84 -4
- package/src/config.ts +169 -69
- package/src/createPayload.ts +3 -1
- package/src/data-service.ts +54 -15
- package/src/file-config.ts +7 -0
- package/src/generate.ts +1 -1
- package/src/index.ts +2 -0
- package/src/keys.ts +4 -0
- package/src/mcp.ts +17 -1
- package/src/models.ts +1 -1
- package/src/ocr.ts +14 -0
- package/src/parsers.ts +43 -43
- package/src/react-query/react-query-service.ts +33 -119
- package/src/request.ts +7 -0
- package/src/roles.ts +33 -1
- package/src/schemas.ts +229 -190
- package/src/types/agents.ts +45 -1
- package/src/types/assistants.ts +20 -4
- package/src/types/files.ts +2 -0
- package/src/types/mutations.ts +41 -3
- package/src/types/queries.ts +24 -13
- package/src/types/runs.ts +1 -0
- package/src/types.ts +78 -77
- package/src/utils.ts +44 -0
- package/src/zod.spec.ts +86 -27
- package/src/zod.ts +22 -2
- package/tsconfig.json +1 -2
- package/specs/parsers.spec.ts +0 -48
package/src/schemas.ts
CHANGED
|
@@ -16,16 +16,17 @@ export const authTypeSchema = z.nativeEnum(AuthType);
|
|
|
16
16
|
export enum EModelEndpoint {
|
|
17
17
|
azureOpenAI = 'azureOpenAI',
|
|
18
18
|
openAI = 'openAI',
|
|
19
|
-
bingAI = 'bingAI',
|
|
20
|
-
chatGPTBrowser = 'chatGPTBrowser',
|
|
21
19
|
google = 'google',
|
|
22
|
-
gptPlugins = 'gptPlugins',
|
|
23
20
|
anthropic = 'anthropic',
|
|
24
21
|
assistants = 'assistants',
|
|
25
22
|
azureAssistants = 'azureAssistants',
|
|
26
23
|
agents = 'agents',
|
|
27
24
|
custom = 'custom',
|
|
28
25
|
bedrock = 'bedrock',
|
|
26
|
+
/** @deprecated */
|
|
27
|
+
chatGPTBrowser = 'chatGPTBrowser',
|
|
28
|
+
/** @deprecated */
|
|
29
|
+
gptPlugins = 'gptPlugins',
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
export const paramEndpoints = new Set<EModelEndpoint | string>([
|
|
@@ -35,6 +36,7 @@ export const paramEndpoints = new Set<EModelEndpoint | string>([
|
|
|
35
36
|
EModelEndpoint.azureOpenAI,
|
|
36
37
|
EModelEndpoint.anthropic,
|
|
37
38
|
EModelEndpoint.custom,
|
|
39
|
+
EModelEndpoint.google,
|
|
38
40
|
]);
|
|
39
41
|
|
|
40
42
|
export enum BedrockProviders {
|
|
@@ -106,6 +108,12 @@ export enum ImageDetail {
|
|
|
106
108
|
high = 'high',
|
|
107
109
|
}
|
|
108
110
|
|
|
111
|
+
export enum ReasoningEffort {
|
|
112
|
+
low = 'low',
|
|
113
|
+
medium = 'medium',
|
|
114
|
+
high = 'high',
|
|
115
|
+
}
|
|
116
|
+
|
|
109
117
|
export const imageDetailNumeric = {
|
|
110
118
|
[ImageDetail.low]: 0,
|
|
111
119
|
[ImageDetail.auto]: 1,
|
|
@@ -119,6 +127,7 @@ export const imageDetailValue = {
|
|
|
119
127
|
};
|
|
120
128
|
|
|
121
129
|
export const eImageDetailSchema = z.nativeEnum(ImageDetail);
|
|
130
|
+
export const eReasoningEffortSchema = z.nativeEnum(ReasoningEffort);
|
|
122
131
|
|
|
123
132
|
export const defaultAssistantFormValues = {
|
|
124
133
|
assistant: '',
|
|
@@ -146,6 +155,7 @@ export const defaultAgentFormValues = {
|
|
|
146
155
|
tools: [],
|
|
147
156
|
provider: {},
|
|
148
157
|
projectIds: [],
|
|
158
|
+
artifacts: '',
|
|
149
159
|
isCollaborative: false,
|
|
150
160
|
[Tools.execute_code]: false,
|
|
151
161
|
[Tools.file_search]: false,
|
|
@@ -169,34 +179,34 @@ export const isImageVisionTool = (tool: FunctionTool | FunctionToolCall) =>
|
|
|
169
179
|
|
|
170
180
|
export const openAISettings = {
|
|
171
181
|
model: {
|
|
172
|
-
default: 'gpt-4o',
|
|
182
|
+
default: 'gpt-4o-mini' as const,
|
|
173
183
|
},
|
|
174
184
|
temperature: {
|
|
175
|
-
min: 0,
|
|
176
|
-
max: 2,
|
|
177
|
-
step: 0.01,
|
|
178
|
-
default: 1,
|
|
185
|
+
min: 0 as const,
|
|
186
|
+
max: 2 as const,
|
|
187
|
+
step: 0.01 as const,
|
|
188
|
+
default: 1 as const,
|
|
179
189
|
},
|
|
180
190
|
top_p: {
|
|
181
|
-
min: 0,
|
|
182
|
-
max: 1,
|
|
183
|
-
step: 0.01,
|
|
184
|
-
default: 1,
|
|
191
|
+
min: 0 as const,
|
|
192
|
+
max: 1 as const,
|
|
193
|
+
step: 0.01 as const,
|
|
194
|
+
default: 1 as const,
|
|
185
195
|
},
|
|
186
196
|
presence_penalty: {
|
|
187
|
-
min: 0,
|
|
188
|
-
max: 2,
|
|
189
|
-
step: 0.01,
|
|
190
|
-
default: 0,
|
|
197
|
+
min: 0 as const,
|
|
198
|
+
max: 2 as const,
|
|
199
|
+
step: 0.01 as const,
|
|
200
|
+
default: 0 as const,
|
|
191
201
|
},
|
|
192
202
|
frequency_penalty: {
|
|
193
|
-
min: 0,
|
|
194
|
-
max: 2,
|
|
195
|
-
step: 0.01,
|
|
196
|
-
default: 0,
|
|
203
|
+
min: 0 as const,
|
|
204
|
+
max: 2 as const,
|
|
205
|
+
step: 0.01 as const,
|
|
206
|
+
default: 0 as const,
|
|
197
207
|
},
|
|
198
208
|
resendFiles: {
|
|
199
|
-
default: true,
|
|
209
|
+
default: true as const,
|
|
200
210
|
},
|
|
201
211
|
maxContextTokens: {
|
|
202
212
|
default: undefined,
|
|
@@ -205,72 +215,85 @@ export const openAISettings = {
|
|
|
205
215
|
default: undefined,
|
|
206
216
|
},
|
|
207
217
|
imageDetail: {
|
|
208
|
-
default: ImageDetail.auto,
|
|
209
|
-
min: 0,
|
|
210
|
-
max: 2,
|
|
211
|
-
step: 1,
|
|
218
|
+
default: ImageDetail.auto as const,
|
|
219
|
+
min: 0 as const,
|
|
220
|
+
max: 2 as const,
|
|
221
|
+
step: 1 as const,
|
|
212
222
|
},
|
|
213
223
|
};
|
|
214
224
|
|
|
215
225
|
export const googleSettings = {
|
|
216
226
|
model: {
|
|
217
|
-
default: 'gemini-1.5-flash-latest',
|
|
227
|
+
default: 'gemini-1.5-flash-latest' as const,
|
|
218
228
|
},
|
|
219
229
|
maxOutputTokens: {
|
|
220
|
-
min: 1,
|
|
221
|
-
max: 8192,
|
|
222
|
-
step: 1,
|
|
223
|
-
default: 8192,
|
|
230
|
+
min: 1 as const,
|
|
231
|
+
max: 8192 as const,
|
|
232
|
+
step: 1 as const,
|
|
233
|
+
default: 8192 as const,
|
|
224
234
|
},
|
|
225
235
|
temperature: {
|
|
226
|
-
min: 0,
|
|
227
|
-
max: 2,
|
|
228
|
-
step: 0.01,
|
|
229
|
-
default: 1,
|
|
236
|
+
min: 0 as const,
|
|
237
|
+
max: 2 as const,
|
|
238
|
+
step: 0.01 as const,
|
|
239
|
+
default: 1 as const,
|
|
230
240
|
},
|
|
231
241
|
topP: {
|
|
232
|
-
min: 0,
|
|
233
|
-
max: 1,
|
|
234
|
-
step: 0.01,
|
|
235
|
-
default: 0.95,
|
|
242
|
+
min: 0 as const,
|
|
243
|
+
max: 1 as const,
|
|
244
|
+
step: 0.01 as const,
|
|
245
|
+
default: 0.95 as const,
|
|
236
246
|
},
|
|
237
247
|
topK: {
|
|
238
|
-
min: 1,
|
|
239
|
-
max: 40,
|
|
240
|
-
step: 1,
|
|
241
|
-
default: 40,
|
|
248
|
+
min: 1 as const,
|
|
249
|
+
max: 40 as const,
|
|
250
|
+
step: 1 as const,
|
|
251
|
+
default: 40 as const,
|
|
242
252
|
},
|
|
243
253
|
};
|
|
244
254
|
|
|
245
|
-
const ANTHROPIC_MAX_OUTPUT =
|
|
246
|
-
const
|
|
255
|
+
const ANTHROPIC_MAX_OUTPUT = 128000 as const;
|
|
256
|
+
const DEFAULT_MAX_OUTPUT = 8192 as const;
|
|
257
|
+
const LEGACY_ANTHROPIC_MAX_OUTPUT = 4096 as const;
|
|
247
258
|
export const anthropicSettings = {
|
|
248
259
|
model: {
|
|
249
|
-
default: 'claude-3-5-sonnet-
|
|
260
|
+
default: 'claude-3-5-sonnet-latest' as const,
|
|
250
261
|
},
|
|
251
262
|
temperature: {
|
|
252
|
-
min: 0,
|
|
253
|
-
max: 1,
|
|
254
|
-
step: 0.01,
|
|
255
|
-
default: 1,
|
|
263
|
+
min: 0 as const,
|
|
264
|
+
max: 1 as const,
|
|
265
|
+
step: 0.01 as const,
|
|
266
|
+
default: 1 as const,
|
|
256
267
|
},
|
|
257
268
|
promptCache: {
|
|
258
|
-
default: true,
|
|
269
|
+
default: true as const,
|
|
270
|
+
},
|
|
271
|
+
thinking: {
|
|
272
|
+
default: true as const,
|
|
273
|
+
},
|
|
274
|
+
thinkingBudget: {
|
|
275
|
+
min: 1024 as const,
|
|
276
|
+
step: 100 as const,
|
|
277
|
+
max: 200000 as const,
|
|
278
|
+
default: 2000 as const,
|
|
259
279
|
},
|
|
260
280
|
maxOutputTokens: {
|
|
261
|
-
min: 1,
|
|
281
|
+
min: 1 as const,
|
|
262
282
|
max: ANTHROPIC_MAX_OUTPUT,
|
|
263
|
-
step: 1,
|
|
264
|
-
default:
|
|
283
|
+
step: 1 as const,
|
|
284
|
+
default: DEFAULT_MAX_OUTPUT,
|
|
265
285
|
reset: (modelName: string) => {
|
|
266
|
-
if (
|
|
267
|
-
return
|
|
286
|
+
if (/claude-3[-.]5-sonnet/.test(modelName) || /claude-3[-.]7/.test(modelName)) {
|
|
287
|
+
return DEFAULT_MAX_OUTPUT;
|
|
268
288
|
}
|
|
269
289
|
|
|
270
290
|
return 4096;
|
|
271
291
|
},
|
|
272
292
|
set: (value: number, modelName: string) => {
|
|
273
|
-
if (
|
|
293
|
+
if (
|
|
294
|
+
!(/claude-3[-.]5-sonnet/.test(modelName) || /claude-3[-.]7/.test(modelName)) &&
|
|
295
|
+
value > LEGACY_ANTHROPIC_MAX_OUTPUT
|
|
296
|
+
) {
|
|
274
297
|
return LEGACY_ANTHROPIC_MAX_OUTPUT;
|
|
275
298
|
}
|
|
276
299
|
|
|
@@ -278,28 +301,28 @@ export const anthropicSettings = {
|
|
|
278
301
|
},
|
|
279
302
|
},
|
|
280
303
|
topP: {
|
|
281
|
-
min: 0,
|
|
282
|
-
max: 1,
|
|
283
|
-
step: 0.01,
|
|
284
|
-
default: 0.7,
|
|
304
|
+
min: 0 as const,
|
|
305
|
+
max: 1 as const,
|
|
306
|
+
step: 0.01 as const,
|
|
307
|
+
default: 0.7 as const,
|
|
285
308
|
},
|
|
286
309
|
topK: {
|
|
287
|
-
min: 1,
|
|
288
|
-
max: 40,
|
|
289
|
-
step: 1,
|
|
290
|
-
default: 5,
|
|
310
|
+
min: 1 as const,
|
|
311
|
+
max: 40 as const,
|
|
312
|
+
step: 1 as const,
|
|
313
|
+
default: 5 as const,
|
|
291
314
|
},
|
|
292
315
|
resendFiles: {
|
|
293
|
-
default: true,
|
|
316
|
+
default: true as const,
|
|
294
317
|
},
|
|
295
318
|
maxContextTokens: {
|
|
296
319
|
default: undefined,
|
|
297
320
|
},
|
|
298
321
|
legacy: {
|
|
299
322
|
maxOutputTokens: {
|
|
300
|
-
min: 1,
|
|
323
|
+
min: 1 as const,
|
|
301
324
|
max: LEGACY_ANTHROPIC_MAX_OUTPUT,
|
|
302
|
-
step: 1,
|
|
325
|
+
step: 1 as const,
|
|
303
326
|
default: LEGACY_ANTHROPIC_MAX_OUTPUT,
|
|
304
327
|
},
|
|
305
328
|
},
|
|
@@ -307,34 +330,34 @@ export const anthropicSettings = {
|
|
|
307
330
|
|
|
308
331
|
export const agentsSettings = {
|
|
309
332
|
model: {
|
|
310
|
-
default: 'gpt-3.5-turbo-test',
|
|
333
|
+
default: 'gpt-3.5-turbo-test' as const,
|
|
311
334
|
},
|
|
312
335
|
temperature: {
|
|
313
|
-
min: 0,
|
|
314
|
-
max: 1,
|
|
315
|
-
step: 0.01,
|
|
316
|
-
default: 1,
|
|
336
|
+
min: 0 as const,
|
|
337
|
+
max: 1 as const,
|
|
338
|
+
step: 0.01 as const,
|
|
339
|
+
default: 1 as const,
|
|
317
340
|
},
|
|
318
341
|
top_p: {
|
|
319
|
-
min: 0,
|
|
320
|
-
max: 1,
|
|
321
|
-
step: 0.01,
|
|
322
|
-
default: 1,
|
|
342
|
+
min: 0 as const,
|
|
343
|
+
max: 1 as const,
|
|
344
|
+
step: 0.01 as const,
|
|
345
|
+
default: 1 as const,
|
|
323
346
|
},
|
|
324
347
|
presence_penalty: {
|
|
325
|
-
min: 0,
|
|
326
|
-
max: 2,
|
|
327
|
-
step: 0.01,
|
|
328
|
-
default: 0,
|
|
348
|
+
min: 0 as const,
|
|
349
|
+
max: 2 as const,
|
|
350
|
+
step: 0.01 as const,
|
|
351
|
+
default: 0 as const,
|
|
329
352
|
},
|
|
330
353
|
frequency_penalty: {
|
|
331
|
-
min: 0,
|
|
332
|
-
max: 2,
|
|
333
|
-
step: 0.01,
|
|
334
|
-
default: 0,
|
|
354
|
+
min: 0 as const,
|
|
355
|
+
max: 2 as const,
|
|
356
|
+
step: 0.01 as const,
|
|
357
|
+
default: 0 as const,
|
|
335
358
|
},
|
|
336
359
|
resendFiles: {
|
|
337
|
-
default: true,
|
|
360
|
+
default: true as const,
|
|
338
361
|
},
|
|
339
362
|
maxContextTokens: {
|
|
340
363
|
default: undefined,
|
|
@@ -343,7 +366,7 @@ export const agentsSettings = {
|
|
|
343
366
|
default: undefined,
|
|
344
367
|
},
|
|
345
368
|
imageDetail: {
|
|
346
|
-
default: ImageDetail.auto,
|
|
369
|
+
default: ImageDetail.auto as const,
|
|
347
370
|
},
|
|
348
371
|
};
|
|
349
372
|
|
|
@@ -377,6 +400,7 @@ export const tPluginSchema = z.object({
|
|
|
377
400
|
authConfig: z.array(tPluginAuthConfigSchema).optional(),
|
|
378
401
|
authenticated: z.boolean().optional(),
|
|
379
402
|
isButton: z.boolean().optional(),
|
|
403
|
+
toolkit: z.boolean().optional(),
|
|
380
404
|
});
|
|
381
405
|
|
|
382
406
|
export type TPlugin = z.infer<typeof tPluginSchema>;
|
|
@@ -453,7 +477,6 @@ export const tMessageSchema = z.object({
|
|
|
453
477
|
sender: z.string().optional(),
|
|
454
478
|
text: z.string(),
|
|
455
479
|
generation: z.string().nullable().optional(),
|
|
456
|
-
isEdited: z.boolean().optional(),
|
|
457
480
|
isCreatedByUser: z.boolean(),
|
|
458
481
|
error: z.boolean().optional(),
|
|
459
482
|
clientTimestamp: z.string().optional(),
|
|
@@ -472,7 +495,7 @@ export const tMessageSchema = z.object({
|
|
|
472
495
|
/* assistant */
|
|
473
496
|
thread_id: z.string().optional(),
|
|
474
497
|
/* frontend components */
|
|
475
|
-
iconURL: z.string().optional(),
|
|
498
|
+
iconURL: z.string().nullable().optional(),
|
|
476
499
|
});
|
|
477
500
|
|
|
478
501
|
export type TAttachmentMetadata = { messageId: string; toolCallId: string };
|
|
@@ -523,7 +546,7 @@ const DocumentType: z.ZodType<DocumentTypeValue> = z.lazy(() =>
|
|
|
523
546
|
export const tConversationSchema = z.object({
|
|
524
547
|
conversationId: z.string().nullable(),
|
|
525
548
|
endpoint: eModelEndpointSchema.nullable(),
|
|
526
|
-
endpointType: eModelEndpointSchema.optional(),
|
|
549
|
+
endpointType: eModelEndpointSchema.nullable().optional(),
|
|
527
550
|
isArchived: z.boolean().optional(),
|
|
528
551
|
title: z.string().nullable().or(z.literal('New Chat')).default('New Chat'),
|
|
529
552
|
user: z.string().optional(),
|
|
@@ -546,6 +569,8 @@ export const tConversationSchema = z.object({
|
|
|
546
569
|
/* Anthropic */
|
|
547
570
|
promptCache: z.boolean().optional(),
|
|
548
571
|
system: z.string().optional(),
|
|
572
|
+
thinking: z.boolean().optional(),
|
|
573
|
+
thinkingBudget: coerceNumber.optional(),
|
|
549
574
|
/* artifacts */
|
|
550
575
|
artifacts: z.string().optional(),
|
|
551
576
|
/* google */
|
|
@@ -556,10 +581,12 @@ export const tConversationSchema = z.object({
|
|
|
556
581
|
createdAt: z.string(),
|
|
557
582
|
updatedAt: z.string(),
|
|
558
583
|
/* Files */
|
|
584
|
+
resendFiles: z.boolean().optional(),
|
|
559
585
|
file_ids: z.array(z.string()).optional(),
|
|
560
586
|
/* vision */
|
|
561
|
-
resendFiles: z.boolean().optional(),
|
|
562
587
|
imageDetail: eImageDetailSchema.optional(),
|
|
588
|
+
/* OpenAI: o1 only */
|
|
589
|
+
reasoning_effort: eReasoningEffortSchema.optional(),
|
|
563
590
|
/* assistant */
|
|
564
591
|
assistant_id: z.string().optional(),
|
|
565
592
|
/* agents */
|
|
@@ -568,42 +595,25 @@ export const tConversationSchema = z.object({
|
|
|
568
595
|
region: z.string().optional(),
|
|
569
596
|
maxTokens: coerceNumber.optional(),
|
|
570
597
|
additionalModelRequestFields: DocumentType.optional(),
|
|
571
|
-
/*
|
|
598
|
+
/* assistants */
|
|
572
599
|
instructions: z.string().optional(),
|
|
573
600
|
additional_instructions: z.string().optional(),
|
|
601
|
+
append_current_datetime: z.boolean().optional(),
|
|
574
602
|
/** Used to overwrite active conversation settings when saving a Preset */
|
|
575
603
|
presetOverride: z.record(z.unknown()).optional(),
|
|
576
604
|
stop: z.array(z.string()).optional(),
|
|
577
605
|
/* frontend components */
|
|
578
|
-
iconURL: z.string().optional(),
|
|
579
606
|
greeting: z.string().optional(),
|
|
580
|
-
spec: z.string().optional(),
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
/** @deprecated */
|
|
585
|
-
suggestions: z.array(z.string()).optional(),
|
|
586
|
-
/** @deprecated */
|
|
587
|
-
systemMessage: z.string().nullable().optional(),
|
|
588
|
-
/** @deprecated */
|
|
589
|
-
jailbreak: z.boolean().optional(),
|
|
590
|
-
/** @deprecated */
|
|
591
|
-
jailbreakConversationId: z.string().nullable().optional(),
|
|
592
|
-
/** @deprecated */
|
|
593
|
-
conversationSignature: z.string().nullable().optional(),
|
|
594
|
-
/** @deprecated */
|
|
595
|
-
clientId: z.string().nullable().optional(),
|
|
596
|
-
/** @deprecated */
|
|
597
|
-
invocationId: z.number().nullable().optional(),
|
|
598
|
-
/** @deprecated */
|
|
599
|
-
toneStyle: z.string().nullable().optional(),
|
|
607
|
+
spec: z.string().nullable().optional(),
|
|
608
|
+
iconURL: z.string().nullable().optional(),
|
|
609
|
+
/* temporary chat */
|
|
610
|
+
expiredAt: z.string().nullable().optional(),
|
|
600
611
|
/** @deprecated */
|
|
601
612
|
resendImages: z.boolean().optional(),
|
|
602
613
|
/** @deprecated */
|
|
603
614
|
agentOptions: tAgentOptionsSchema.nullable().optional(),
|
|
604
615
|
/** @deprecated Prefer `modelLabel` over `chatGptLabel` */
|
|
605
616
|
chatGptLabel: z.string().nullable().optional(),
|
|
606
|
-
append_current_datetime: z.boolean().optional(),
|
|
607
617
|
});
|
|
608
618
|
|
|
609
619
|
export const tPresetSchema = tConversationSchema
|
|
@@ -630,11 +640,79 @@ export const tConvoUpdateSchema = tConversationSchema.merge(
|
|
|
630
640
|
}),
|
|
631
641
|
);
|
|
632
642
|
|
|
633
|
-
export const
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
643
|
+
export const tQueryParamsSchema = tConversationSchema
|
|
644
|
+
.pick({
|
|
645
|
+
// librechat settings
|
|
646
|
+
/** The AI context window, overrides the system-defined window as determined by `model` value */
|
|
647
|
+
maxContextTokens: true,
|
|
648
|
+
/**
|
|
649
|
+
* Whether or not to re-submit files from previous messages on subsequent messages
|
|
650
|
+
* */
|
|
651
|
+
resendFiles: true,
|
|
652
|
+
/**
|
|
653
|
+
* @endpoints openAI, custom, azureOpenAI
|
|
654
|
+
*
|
|
655
|
+
* System parameter that only affects the above endpoints.
|
|
656
|
+
* Image detail for re-sizing according to OpenAI spec, defaults to `auto`
|
|
657
|
+
* */
|
|
658
|
+
imageDetail: true,
|
|
659
|
+
/**
|
|
660
|
+
* AKA Custom Instructions, dynamically added to chat history as a system message;
|
|
661
|
+
* for `bedrock` endpoint, this is used as the `system` model param if the provider uses it;
|
|
662
|
+
* for `assistants` endpoint, this is used as the `additional_instructions` model param:
|
|
663
|
+
* https://platform.openai.com/docs/api-reference/runs/createRun#runs-createrun-additional_instructions
|
|
664
|
+
* ; otherwise, a message with `system` role is added to the chat history
|
|
665
|
+
*/
|
|
666
|
+
promptPrefix: true,
|
|
667
|
+
// Model parameters
|
|
668
|
+
/** @endpoints openAI, custom, azureOpenAI, google, anthropic, assistants, azureAssistants, bedrock */
|
|
669
|
+
model: true,
|
|
670
|
+
/** @endpoints openAI, custom, azureOpenAI, google, anthropic, bedrock */
|
|
671
|
+
temperature: true,
|
|
672
|
+
/** @endpoints openAI, custom, azureOpenAI */
|
|
673
|
+
presence_penalty: true,
|
|
674
|
+
/** @endpoints openAI, custom, azureOpenAI */
|
|
675
|
+
frequency_penalty: true,
|
|
676
|
+
/** @endpoints openAI, custom, azureOpenAI */
|
|
677
|
+
stop: true,
|
|
678
|
+
/** @endpoints openAI, custom, azureOpenAI */
|
|
679
|
+
top_p: true,
|
|
680
|
+
/** @endpoints openAI, custom, azureOpenAI */
|
|
681
|
+
max_tokens: true,
|
|
682
|
+
/** @endpoints google, anthropic, bedrock */
|
|
683
|
+
topP: true,
|
|
684
|
+
/** @endpoints google, anthropic */
|
|
685
|
+
topK: true,
|
|
686
|
+
/** @endpoints google, anthropic */
|
|
687
|
+
maxOutputTokens: true,
|
|
688
|
+
/** @endpoints anthropic */
|
|
689
|
+
promptCache: true,
|
|
690
|
+
thinking: true,
|
|
691
|
+
thinkingBudget: true,
|
|
692
|
+
/** @endpoints bedrock */
|
|
693
|
+
region: true,
|
|
694
|
+
/** @endpoints bedrock */
|
|
695
|
+
maxTokens: true,
|
|
696
|
+
/** @endpoints agents */
|
|
697
|
+
agent_id: true,
|
|
698
|
+
/** @endpoints assistants, azureAssistants */
|
|
699
|
+
assistant_id: true,
|
|
700
|
+
/** @endpoints assistants, azureAssistants */
|
|
701
|
+
append_current_datetime: true,
|
|
702
|
+
/**
|
|
703
|
+
* @endpoints assistants, azureAssistants
|
|
704
|
+
*
|
|
705
|
+
* Overrides existing assistant instructions, only used for the current run:
|
|
706
|
+
* https://platform.openai.com/docs/api-reference/runs/createRun#runs-createrun-instructions
|
|
707
|
+
* */
|
|
708
|
+
instructions: true,
|
|
709
|
+
})
|
|
710
|
+
.merge(
|
|
711
|
+
z.object({
|
|
712
|
+
/** @endpoints openAI, custom, azureOpenAI, google, anthropic, assistants, azureAssistants, bedrock, agents */
|
|
713
|
+
endpoint: extendedModelEndpointSchema.nullable(),
|
|
714
|
+
}),
|
|
715
|
+
);
|
|
638
716
|
|
|
639
717
|
export type TPreset = z.infer<typeof tPresetSchema>;
|
|
640
718
|
|
|
@@ -650,13 +728,12 @@ export const tSharedLinkSchema = z.object({
|
|
|
650
728
|
conversationId: z.string(),
|
|
651
729
|
shareId: z.string(),
|
|
652
730
|
messages: z.array(z.string()),
|
|
653
|
-
isAnonymous: z.boolean(),
|
|
654
731
|
isPublic: z.boolean(),
|
|
655
|
-
isVisible: z.boolean(),
|
|
656
732
|
title: z.string(),
|
|
657
733
|
createdAt: z.string(),
|
|
658
734
|
updatedAt: z.string(),
|
|
659
735
|
});
|
|
736
|
+
|
|
660
737
|
export type TSharedLink = z.infer<typeof tSharedLinkSchema>;
|
|
661
738
|
|
|
662
739
|
export const tConversationTagSchema = z.object({
|
|
@@ -687,72 +764,27 @@ export const googleSchema = tConversationSchema
|
|
|
687
764
|
spec: true,
|
|
688
765
|
maxContextTokens: true,
|
|
689
766
|
})
|
|
690
|
-
.transform((obj) =>
|
|
691
|
-
|
|
692
|
-
...obj,
|
|
693
|
-
model: obj.model ?? google.model.default,
|
|
694
|
-
modelLabel: obj.modelLabel ?? null,
|
|
695
|
-
promptPrefix: obj.promptPrefix ?? null,
|
|
696
|
-
examples: obj.examples ?? [{ input: { content: '' }, output: { content: '' } }],
|
|
697
|
-
temperature: obj.temperature ?? google.temperature.default,
|
|
698
|
-
maxOutputTokens: obj.maxOutputTokens ?? google.maxOutputTokens.default,
|
|
699
|
-
topP: obj.topP ?? google.topP.default,
|
|
700
|
-
topK: obj.topK ?? google.topK.default,
|
|
701
|
-
iconURL: obj.iconURL ?? undefined,
|
|
702
|
-
greeting: obj.greeting ?? undefined,
|
|
703
|
-
spec: obj.spec ?? undefined,
|
|
704
|
-
maxContextTokens: obj.maxContextTokens ?? undefined,
|
|
705
|
-
};
|
|
706
|
-
})
|
|
707
|
-
.catch(() => ({
|
|
708
|
-
model: google.model.default,
|
|
709
|
-
modelLabel: null,
|
|
710
|
-
promptPrefix: null,
|
|
711
|
-
examples: [{ input: { content: '' }, output: { content: '' } }],
|
|
712
|
-
temperature: google.temperature.default,
|
|
713
|
-
maxOutputTokens: google.maxOutputTokens.default,
|
|
714
|
-
topP: google.topP.default,
|
|
715
|
-
topK: google.topK.default,
|
|
716
|
-
iconURL: undefined,
|
|
717
|
-
greeting: undefined,
|
|
718
|
-
spec: undefined,
|
|
719
|
-
maxContextTokens: undefined,
|
|
720
|
-
}));
|
|
767
|
+
.transform((obj: Partial<TConversation>) => removeNullishValues(obj))
|
|
768
|
+
.catch(() => ({}));
|
|
721
769
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
770
|
+
/**
|
|
771
|
+
* TODO: Map the following fields:
|
|
772
|
+
- presence_penalty -> presencePenalty
|
|
773
|
+
- frequency_penalty -> frequencyPenalty
|
|
774
|
+
- stop -> stopSequences
|
|
775
|
+
*/
|
|
776
|
+
export const googleGenConfigSchema = z
|
|
777
|
+
.object({
|
|
778
|
+
maxOutputTokens: coerceNumber.optional(),
|
|
779
|
+
temperature: coerceNumber.optional(),
|
|
780
|
+
topP: coerceNumber.optional(),
|
|
781
|
+
topK: coerceNumber.optional(),
|
|
782
|
+
presencePenalty: coerceNumber.optional(),
|
|
783
|
+
frequencyPenalty: coerceNumber.optional(),
|
|
784
|
+
stopSequences: z.array(z.string()).optional(),
|
|
732
785
|
})
|
|
733
|
-
.
|
|
734
|
-
|
|
735
|
-
model: '',
|
|
736
|
-
jailbreak: obj.jailbreak ?? false,
|
|
737
|
-
systemMessage: obj.systemMessage ?? null,
|
|
738
|
-
context: obj.context ?? null,
|
|
739
|
-
toneStyle: obj.toneStyle ?? 'creative',
|
|
740
|
-
jailbreakConversationId: obj.jailbreakConversationId ?? null,
|
|
741
|
-
conversationSignature: obj.conversationSignature ?? null,
|
|
742
|
-
clientId: obj.clientId ?? null,
|
|
743
|
-
invocationId: obj.invocationId ?? 1,
|
|
744
|
-
}))
|
|
745
|
-
.catch(() => ({
|
|
746
|
-
model: '',
|
|
747
|
-
jailbreak: false,
|
|
748
|
-
systemMessage: null,
|
|
749
|
-
context: null,
|
|
750
|
-
toneStyle: 'creative',
|
|
751
|
-
jailbreakConversationId: null,
|
|
752
|
-
conversationSignature: null,
|
|
753
|
-
clientId: null,
|
|
754
|
-
invocationId: 1,
|
|
755
|
-
}));
|
|
786
|
+
.strip()
|
|
787
|
+
.optional();
|
|
756
788
|
|
|
757
789
|
export const chatGPTBrowserSchema = tConversationSchema
|
|
758
790
|
.pick({
|
|
@@ -834,7 +866,10 @@ export const gptPluginsSchema = tConversationSchema
|
|
|
834
866
|
maxContextTokens: undefined,
|
|
835
867
|
}));
|
|
836
868
|
|
|
837
|
-
export function removeNullishValues<T extends Record<string, unknown>>(
|
|
869
|
+
export function removeNullishValues<T extends Record<string, unknown>>(
|
|
870
|
+
obj: T,
|
|
871
|
+
removeEmptyStrings?: boolean,
|
|
872
|
+
): Partial<T> {
|
|
838
873
|
const newObj: Partial<T> = { ...obj };
|
|
839
874
|
|
|
840
875
|
(Object.keys(newObj) as Array<keyof T>).forEach((key) => {
|
|
@@ -842,6 +877,9 @@ export function removeNullishValues<T extends Record<string, unknown>>(obj: T):
|
|
|
842
877
|
if (value === undefined || value === null) {
|
|
843
878
|
delete newObj[key];
|
|
844
879
|
}
|
|
880
|
+
if (removeEmptyStrings && typeof value === 'string' && value === '') {
|
|
881
|
+
delete newObj[key];
|
|
882
|
+
}
|
|
845
883
|
});
|
|
846
884
|
|
|
847
885
|
return newObj;
|
|
@@ -892,8 +930,7 @@ export const compactAssistantSchema = tConversationSchema
|
|
|
892
930
|
greeting: true,
|
|
893
931
|
spec: true,
|
|
894
932
|
})
|
|
895
|
-
|
|
896
|
-
.transform(removeNullishValues)
|
|
933
|
+
.transform((obj) => removeNullishValues(obj))
|
|
897
934
|
.catch(() => ({}));
|
|
898
935
|
|
|
899
936
|
export const agentsSchema = tConversationSchema
|
|
@@ -967,6 +1004,7 @@ export const openAISchema = tConversationSchema
|
|
|
967
1004
|
spec: true,
|
|
968
1005
|
maxContextTokens: true,
|
|
969
1006
|
max_tokens: true,
|
|
1007
|
+
reasoning_effort: true,
|
|
970
1008
|
})
|
|
971
1009
|
.transform((obj: Partial<TConversation>) => removeNullishValues(obj))
|
|
972
1010
|
.catch(() => ({}));
|
|
@@ -1017,6 +1055,8 @@ export const anthropicSchema = tConversationSchema
|
|
|
1017
1055
|
topK: true,
|
|
1018
1056
|
resendFiles: true,
|
|
1019
1057
|
promptCache: true,
|
|
1058
|
+
thinking: true,
|
|
1059
|
+
thinkingBudget: true,
|
|
1020
1060
|
artifacts: true,
|
|
1021
1061
|
iconURL: true,
|
|
1022
1062
|
greeting: true,
|
|
@@ -1094,7 +1134,7 @@ export const compactPluginsSchema = tConversationSchema
|
|
|
1094
1134
|
})
|
|
1095
1135
|
.catch(() => ({}));
|
|
1096
1136
|
|
|
1097
|
-
const tBannerSchema = z.object({
|
|
1137
|
+
export const tBannerSchema = z.object({
|
|
1098
1138
|
bannerId: z.string(),
|
|
1099
1139
|
message: z.string(),
|
|
1100
1140
|
displayFrom: z.string(),
|
|
@@ -1112,9 +1152,8 @@ export const compactAgentsSchema = tConversationSchema
|
|
|
1112
1152
|
iconURL: true,
|
|
1113
1153
|
greeting: true,
|
|
1114
1154
|
agent_id: true,
|
|
1115
|
-
resendFiles: true,
|
|
1116
1155
|
instructions: true,
|
|
1117
1156
|
additional_instructions: true,
|
|
1118
1157
|
})
|
|
1119
|
-
.transform(removeNullishValues)
|
|
1158
|
+
.transform((obj) => removeNullishValues(obj))
|
|
1120
1159
|
.catch(() => ({}));
|