librechat-data-provider 0.7.69 → 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 +163 -184
- 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
|
@@ -24,8 +24,6 @@ export enum EModelEndpoint {
|
|
|
24
24
|
custom = 'custom',
|
|
25
25
|
bedrock = 'bedrock',
|
|
26
26
|
/** @deprecated */
|
|
27
|
-
bingAI = 'bingAI',
|
|
28
|
-
/** @deprecated */
|
|
29
27
|
chatGPTBrowser = 'chatGPTBrowser',
|
|
30
28
|
/** @deprecated */
|
|
31
29
|
gptPlugins = 'gptPlugins',
|
|
@@ -38,6 +36,7 @@ export const paramEndpoints = new Set<EModelEndpoint | string>([
|
|
|
38
36
|
EModelEndpoint.azureOpenAI,
|
|
39
37
|
EModelEndpoint.anthropic,
|
|
40
38
|
EModelEndpoint.custom,
|
|
39
|
+
EModelEndpoint.google,
|
|
41
40
|
]);
|
|
42
41
|
|
|
43
42
|
export enum BedrockProviders {
|
|
@@ -109,6 +108,12 @@ export enum ImageDetail {
|
|
|
109
108
|
high = 'high',
|
|
110
109
|
}
|
|
111
110
|
|
|
111
|
+
export enum ReasoningEffort {
|
|
112
|
+
low = 'low',
|
|
113
|
+
medium = 'medium',
|
|
114
|
+
high = 'high',
|
|
115
|
+
}
|
|
116
|
+
|
|
112
117
|
export const imageDetailNumeric = {
|
|
113
118
|
[ImageDetail.low]: 0,
|
|
114
119
|
[ImageDetail.auto]: 1,
|
|
@@ -122,6 +127,7 @@ export const imageDetailValue = {
|
|
|
122
127
|
};
|
|
123
128
|
|
|
124
129
|
export const eImageDetailSchema = z.nativeEnum(ImageDetail);
|
|
130
|
+
export const eReasoningEffortSchema = z.nativeEnum(ReasoningEffort);
|
|
125
131
|
|
|
126
132
|
export const defaultAssistantFormValues = {
|
|
127
133
|
assistant: '',
|
|
@@ -149,6 +155,7 @@ export const defaultAgentFormValues = {
|
|
|
149
155
|
tools: [],
|
|
150
156
|
provider: {},
|
|
151
157
|
projectIds: [],
|
|
158
|
+
artifacts: '',
|
|
152
159
|
isCollaborative: false,
|
|
153
160
|
[Tools.execute_code]: false,
|
|
154
161
|
[Tools.file_search]: false,
|
|
@@ -172,34 +179,34 @@ export const isImageVisionTool = (tool: FunctionTool | FunctionToolCall) =>
|
|
|
172
179
|
|
|
173
180
|
export const openAISettings = {
|
|
174
181
|
model: {
|
|
175
|
-
default: 'gpt-4o',
|
|
182
|
+
default: 'gpt-4o-mini' as const,
|
|
176
183
|
},
|
|
177
184
|
temperature: {
|
|
178
|
-
min: 0,
|
|
179
|
-
max: 2,
|
|
180
|
-
step: 0.01,
|
|
181
|
-
default: 1,
|
|
185
|
+
min: 0 as const,
|
|
186
|
+
max: 2 as const,
|
|
187
|
+
step: 0.01 as const,
|
|
188
|
+
default: 1 as const,
|
|
182
189
|
},
|
|
183
190
|
top_p: {
|
|
184
|
-
min: 0,
|
|
185
|
-
max: 1,
|
|
186
|
-
step: 0.01,
|
|
187
|
-
default: 1,
|
|
191
|
+
min: 0 as const,
|
|
192
|
+
max: 1 as const,
|
|
193
|
+
step: 0.01 as const,
|
|
194
|
+
default: 1 as const,
|
|
188
195
|
},
|
|
189
196
|
presence_penalty: {
|
|
190
|
-
min: 0,
|
|
191
|
-
max: 2,
|
|
192
|
-
step: 0.01,
|
|
193
|
-
default: 0,
|
|
197
|
+
min: 0 as const,
|
|
198
|
+
max: 2 as const,
|
|
199
|
+
step: 0.01 as const,
|
|
200
|
+
default: 0 as const,
|
|
194
201
|
},
|
|
195
202
|
frequency_penalty: {
|
|
196
|
-
min: 0,
|
|
197
|
-
max: 2,
|
|
198
|
-
step: 0.01,
|
|
199
|
-
default: 0,
|
|
203
|
+
min: 0 as const,
|
|
204
|
+
max: 2 as const,
|
|
205
|
+
step: 0.01 as const,
|
|
206
|
+
default: 0 as const,
|
|
200
207
|
},
|
|
201
208
|
resendFiles: {
|
|
202
|
-
default: true,
|
|
209
|
+
default: true as const,
|
|
203
210
|
},
|
|
204
211
|
maxContextTokens: {
|
|
205
212
|
default: undefined,
|
|
@@ -208,72 +215,85 @@ export const openAISettings = {
|
|
|
208
215
|
default: undefined,
|
|
209
216
|
},
|
|
210
217
|
imageDetail: {
|
|
211
|
-
default: ImageDetail.auto,
|
|
212
|
-
min: 0,
|
|
213
|
-
max: 2,
|
|
214
|
-
step: 1,
|
|
218
|
+
default: ImageDetail.auto as const,
|
|
219
|
+
min: 0 as const,
|
|
220
|
+
max: 2 as const,
|
|
221
|
+
step: 1 as const,
|
|
215
222
|
},
|
|
216
223
|
};
|
|
217
224
|
|
|
218
225
|
export const googleSettings = {
|
|
219
226
|
model: {
|
|
220
|
-
default: 'gemini-1.5-flash-latest',
|
|
227
|
+
default: 'gemini-1.5-flash-latest' as const,
|
|
221
228
|
},
|
|
222
229
|
maxOutputTokens: {
|
|
223
|
-
min: 1,
|
|
224
|
-
max: 8192,
|
|
225
|
-
step: 1,
|
|
226
|
-
default: 8192,
|
|
230
|
+
min: 1 as const,
|
|
231
|
+
max: 8192 as const,
|
|
232
|
+
step: 1 as const,
|
|
233
|
+
default: 8192 as const,
|
|
227
234
|
},
|
|
228
235
|
temperature: {
|
|
229
|
-
min: 0,
|
|
230
|
-
max: 2,
|
|
231
|
-
step: 0.01,
|
|
232
|
-
default: 1,
|
|
236
|
+
min: 0 as const,
|
|
237
|
+
max: 2 as const,
|
|
238
|
+
step: 0.01 as const,
|
|
239
|
+
default: 1 as const,
|
|
233
240
|
},
|
|
234
241
|
topP: {
|
|
235
|
-
min: 0,
|
|
236
|
-
max: 1,
|
|
237
|
-
step: 0.01,
|
|
238
|
-
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,
|
|
239
246
|
},
|
|
240
247
|
topK: {
|
|
241
|
-
min: 1,
|
|
242
|
-
max: 40,
|
|
243
|
-
step: 1,
|
|
244
|
-
default: 40,
|
|
248
|
+
min: 1 as const,
|
|
249
|
+
max: 40 as const,
|
|
250
|
+
step: 1 as const,
|
|
251
|
+
default: 40 as const,
|
|
245
252
|
},
|
|
246
253
|
};
|
|
247
254
|
|
|
248
|
-
const ANTHROPIC_MAX_OUTPUT =
|
|
249
|
-
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;
|
|
250
258
|
export const anthropicSettings = {
|
|
251
259
|
model: {
|
|
252
|
-
default: 'claude-3-5-sonnet-
|
|
260
|
+
default: 'claude-3-5-sonnet-latest' as const,
|
|
253
261
|
},
|
|
254
262
|
temperature: {
|
|
255
|
-
min: 0,
|
|
256
|
-
max: 1,
|
|
257
|
-
step: 0.01,
|
|
258
|
-
default: 1,
|
|
263
|
+
min: 0 as const,
|
|
264
|
+
max: 1 as const,
|
|
265
|
+
step: 0.01 as const,
|
|
266
|
+
default: 1 as const,
|
|
259
267
|
},
|
|
260
268
|
promptCache: {
|
|
261
|
-
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,
|
|
262
279
|
},
|
|
263
280
|
maxOutputTokens: {
|
|
264
|
-
min: 1,
|
|
281
|
+
min: 1 as const,
|
|
265
282
|
max: ANTHROPIC_MAX_OUTPUT,
|
|
266
|
-
step: 1,
|
|
267
|
-
default:
|
|
283
|
+
step: 1 as const,
|
|
284
|
+
default: DEFAULT_MAX_OUTPUT,
|
|
268
285
|
reset: (modelName: string) => {
|
|
269
|
-
if (
|
|
270
|
-
return
|
|
286
|
+
if (/claude-3[-.]5-sonnet/.test(modelName) || /claude-3[-.]7/.test(modelName)) {
|
|
287
|
+
return DEFAULT_MAX_OUTPUT;
|
|
271
288
|
}
|
|
272
289
|
|
|
273
290
|
return 4096;
|
|
274
291
|
},
|
|
275
292
|
set: (value: number, modelName: string) => {
|
|
276
|
-
if (
|
|
293
|
+
if (
|
|
294
|
+
!(/claude-3[-.]5-sonnet/.test(modelName) || /claude-3[-.]7/.test(modelName)) &&
|
|
295
|
+
value > LEGACY_ANTHROPIC_MAX_OUTPUT
|
|
296
|
+
) {
|
|
277
297
|
return LEGACY_ANTHROPIC_MAX_OUTPUT;
|
|
278
298
|
}
|
|
279
299
|
|
|
@@ -281,28 +301,28 @@ export const anthropicSettings = {
|
|
|
281
301
|
},
|
|
282
302
|
},
|
|
283
303
|
topP: {
|
|
284
|
-
min: 0,
|
|
285
|
-
max: 1,
|
|
286
|
-
step: 0.01,
|
|
287
|
-
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,
|
|
288
308
|
},
|
|
289
309
|
topK: {
|
|
290
|
-
min: 1,
|
|
291
|
-
max: 40,
|
|
292
|
-
step: 1,
|
|
293
|
-
default: 5,
|
|
310
|
+
min: 1 as const,
|
|
311
|
+
max: 40 as const,
|
|
312
|
+
step: 1 as const,
|
|
313
|
+
default: 5 as const,
|
|
294
314
|
},
|
|
295
315
|
resendFiles: {
|
|
296
|
-
default: true,
|
|
316
|
+
default: true as const,
|
|
297
317
|
},
|
|
298
318
|
maxContextTokens: {
|
|
299
319
|
default: undefined,
|
|
300
320
|
},
|
|
301
321
|
legacy: {
|
|
302
322
|
maxOutputTokens: {
|
|
303
|
-
min: 1,
|
|
323
|
+
min: 1 as const,
|
|
304
324
|
max: LEGACY_ANTHROPIC_MAX_OUTPUT,
|
|
305
|
-
step: 1,
|
|
325
|
+
step: 1 as const,
|
|
306
326
|
default: LEGACY_ANTHROPIC_MAX_OUTPUT,
|
|
307
327
|
},
|
|
308
328
|
},
|
|
@@ -310,34 +330,34 @@ export const anthropicSettings = {
|
|
|
310
330
|
|
|
311
331
|
export const agentsSettings = {
|
|
312
332
|
model: {
|
|
313
|
-
default: 'gpt-3.5-turbo-test',
|
|
333
|
+
default: 'gpt-3.5-turbo-test' as const,
|
|
314
334
|
},
|
|
315
335
|
temperature: {
|
|
316
|
-
min: 0,
|
|
317
|
-
max: 1,
|
|
318
|
-
step: 0.01,
|
|
319
|
-
default: 1,
|
|
336
|
+
min: 0 as const,
|
|
337
|
+
max: 1 as const,
|
|
338
|
+
step: 0.01 as const,
|
|
339
|
+
default: 1 as const,
|
|
320
340
|
},
|
|
321
341
|
top_p: {
|
|
322
|
-
min: 0,
|
|
323
|
-
max: 1,
|
|
324
|
-
step: 0.01,
|
|
325
|
-
default: 1,
|
|
342
|
+
min: 0 as const,
|
|
343
|
+
max: 1 as const,
|
|
344
|
+
step: 0.01 as const,
|
|
345
|
+
default: 1 as const,
|
|
326
346
|
},
|
|
327
347
|
presence_penalty: {
|
|
328
|
-
min: 0,
|
|
329
|
-
max: 2,
|
|
330
|
-
step: 0.01,
|
|
331
|
-
default: 0,
|
|
348
|
+
min: 0 as const,
|
|
349
|
+
max: 2 as const,
|
|
350
|
+
step: 0.01 as const,
|
|
351
|
+
default: 0 as const,
|
|
332
352
|
},
|
|
333
353
|
frequency_penalty: {
|
|
334
|
-
min: 0,
|
|
335
|
-
max: 2,
|
|
336
|
-
step: 0.01,
|
|
337
|
-
default: 0,
|
|
354
|
+
min: 0 as const,
|
|
355
|
+
max: 2 as const,
|
|
356
|
+
step: 0.01 as const,
|
|
357
|
+
default: 0 as const,
|
|
338
358
|
},
|
|
339
359
|
resendFiles: {
|
|
340
|
-
default: true,
|
|
360
|
+
default: true as const,
|
|
341
361
|
},
|
|
342
362
|
maxContextTokens: {
|
|
343
363
|
default: undefined,
|
|
@@ -346,7 +366,7 @@ export const agentsSettings = {
|
|
|
346
366
|
default: undefined,
|
|
347
367
|
},
|
|
348
368
|
imageDetail: {
|
|
349
|
-
default: ImageDetail.auto,
|
|
369
|
+
default: ImageDetail.auto as const,
|
|
350
370
|
},
|
|
351
371
|
};
|
|
352
372
|
|
|
@@ -380,6 +400,7 @@ export const tPluginSchema = z.object({
|
|
|
380
400
|
authConfig: z.array(tPluginAuthConfigSchema).optional(),
|
|
381
401
|
authenticated: z.boolean().optional(),
|
|
382
402
|
isButton: z.boolean().optional(),
|
|
403
|
+
toolkit: z.boolean().optional(),
|
|
383
404
|
});
|
|
384
405
|
|
|
385
406
|
export type TPlugin = z.infer<typeof tPluginSchema>;
|
|
@@ -456,7 +477,6 @@ export const tMessageSchema = z.object({
|
|
|
456
477
|
sender: z.string().optional(),
|
|
457
478
|
text: z.string(),
|
|
458
479
|
generation: z.string().nullable().optional(),
|
|
459
|
-
isEdited: z.boolean().optional(),
|
|
460
480
|
isCreatedByUser: z.boolean(),
|
|
461
481
|
error: z.boolean().optional(),
|
|
462
482
|
clientTimestamp: z.string().optional(),
|
|
@@ -475,7 +495,7 @@ export const tMessageSchema = z.object({
|
|
|
475
495
|
/* assistant */
|
|
476
496
|
thread_id: z.string().optional(),
|
|
477
497
|
/* frontend components */
|
|
478
|
-
iconURL: z.string().optional(),
|
|
498
|
+
iconURL: z.string().nullable().optional(),
|
|
479
499
|
});
|
|
480
500
|
|
|
481
501
|
export type TAttachmentMetadata = { messageId: string; toolCallId: string };
|
|
@@ -526,7 +546,7 @@ const DocumentType: z.ZodType<DocumentTypeValue> = z.lazy(() =>
|
|
|
526
546
|
export const tConversationSchema = z.object({
|
|
527
547
|
conversationId: z.string().nullable(),
|
|
528
548
|
endpoint: eModelEndpointSchema.nullable(),
|
|
529
|
-
endpointType: eModelEndpointSchema.optional(),
|
|
549
|
+
endpointType: eModelEndpointSchema.nullable().optional(),
|
|
530
550
|
isArchived: z.boolean().optional(),
|
|
531
551
|
title: z.string().nullable().or(z.literal('New Chat')).default('New Chat'),
|
|
532
552
|
user: z.string().optional(),
|
|
@@ -549,6 +569,8 @@ export const tConversationSchema = z.object({
|
|
|
549
569
|
/* Anthropic */
|
|
550
570
|
promptCache: z.boolean().optional(),
|
|
551
571
|
system: z.string().optional(),
|
|
572
|
+
thinking: z.boolean().optional(),
|
|
573
|
+
thinkingBudget: coerceNumber.optional(),
|
|
552
574
|
/* artifacts */
|
|
553
575
|
artifacts: z.string().optional(),
|
|
554
576
|
/* google */
|
|
@@ -559,10 +581,12 @@ export const tConversationSchema = z.object({
|
|
|
559
581
|
createdAt: z.string(),
|
|
560
582
|
updatedAt: z.string(),
|
|
561
583
|
/* Files */
|
|
584
|
+
resendFiles: z.boolean().optional(),
|
|
562
585
|
file_ids: z.array(z.string()).optional(),
|
|
563
586
|
/* vision */
|
|
564
|
-
resendFiles: z.boolean().optional(),
|
|
565
587
|
imageDetail: eImageDetailSchema.optional(),
|
|
588
|
+
/* OpenAI: o1 only */
|
|
589
|
+
reasoning_effort: eReasoningEffortSchema.optional(),
|
|
566
590
|
/* assistant */
|
|
567
591
|
assistant_id: z.string().optional(),
|
|
568
592
|
/* agents */
|
|
@@ -571,42 +595,25 @@ export const tConversationSchema = z.object({
|
|
|
571
595
|
region: z.string().optional(),
|
|
572
596
|
maxTokens: coerceNumber.optional(),
|
|
573
597
|
additionalModelRequestFields: DocumentType.optional(),
|
|
574
|
-
/*
|
|
598
|
+
/* assistants */
|
|
575
599
|
instructions: z.string().optional(),
|
|
576
600
|
additional_instructions: z.string().optional(),
|
|
601
|
+
append_current_datetime: z.boolean().optional(),
|
|
577
602
|
/** Used to overwrite active conversation settings when saving a Preset */
|
|
578
603
|
presetOverride: z.record(z.unknown()).optional(),
|
|
579
604
|
stop: z.array(z.string()).optional(),
|
|
580
605
|
/* frontend components */
|
|
581
|
-
iconURL: z.string().optional(),
|
|
582
606
|
greeting: z.string().optional(),
|
|
583
|
-
spec: z.string().optional(),
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
/** @deprecated */
|
|
588
|
-
suggestions: z.array(z.string()).optional(),
|
|
589
|
-
/** @deprecated */
|
|
590
|
-
systemMessage: z.string().nullable().optional(),
|
|
591
|
-
/** @deprecated */
|
|
592
|
-
jailbreak: z.boolean().optional(),
|
|
593
|
-
/** @deprecated */
|
|
594
|
-
jailbreakConversationId: z.string().nullable().optional(),
|
|
595
|
-
/** @deprecated */
|
|
596
|
-
conversationSignature: z.string().nullable().optional(),
|
|
597
|
-
/** @deprecated */
|
|
598
|
-
clientId: z.string().nullable().optional(),
|
|
599
|
-
/** @deprecated */
|
|
600
|
-
invocationId: z.number().nullable().optional(),
|
|
601
|
-
/** @deprecated */
|
|
602
|
-
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(),
|
|
603
611
|
/** @deprecated */
|
|
604
612
|
resendImages: z.boolean().optional(),
|
|
605
613
|
/** @deprecated */
|
|
606
614
|
agentOptions: tAgentOptionsSchema.nullable().optional(),
|
|
607
615
|
/** @deprecated Prefer `modelLabel` over `chatGptLabel` */
|
|
608
616
|
chatGptLabel: z.string().nullable().optional(),
|
|
609
|
-
append_current_datetime: z.boolean().optional(),
|
|
610
617
|
});
|
|
611
618
|
|
|
612
619
|
export const tPresetSchema = tConversationSchema
|
|
@@ -642,6 +649,13 @@ export const tQueryParamsSchema = tConversationSchema
|
|
|
642
649
|
* Whether or not to re-submit files from previous messages on subsequent messages
|
|
643
650
|
* */
|
|
644
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,
|
|
645
659
|
/**
|
|
646
660
|
* AKA Custom Instructions, dynamically added to chat history as a system message;
|
|
647
661
|
* for `bedrock` endpoint, this is used as the `system` model param if the provider uses it;
|
|
@@ -673,6 +687,8 @@ export const tQueryParamsSchema = tConversationSchema
|
|
|
673
687
|
maxOutputTokens: true,
|
|
674
688
|
/** @endpoints anthropic */
|
|
675
689
|
promptCache: true,
|
|
690
|
+
thinking: true,
|
|
691
|
+
thinkingBudget: true,
|
|
676
692
|
/** @endpoints bedrock */
|
|
677
693
|
region: true,
|
|
678
694
|
/** @endpoints bedrock */
|
|
@@ -681,6 +697,8 @@ export const tQueryParamsSchema = tConversationSchema
|
|
|
681
697
|
agent_id: true,
|
|
682
698
|
/** @endpoints assistants, azureAssistants */
|
|
683
699
|
assistant_id: true,
|
|
700
|
+
/** @endpoints assistants, azureAssistants */
|
|
701
|
+
append_current_datetime: true,
|
|
684
702
|
/**
|
|
685
703
|
* @endpoints assistants, azureAssistants
|
|
686
704
|
*
|
|
@@ -710,13 +728,12 @@ export const tSharedLinkSchema = z.object({
|
|
|
710
728
|
conversationId: z.string(),
|
|
711
729
|
shareId: z.string(),
|
|
712
730
|
messages: z.array(z.string()),
|
|
713
|
-
isAnonymous: z.boolean(),
|
|
714
731
|
isPublic: z.boolean(),
|
|
715
|
-
isVisible: z.boolean(),
|
|
716
732
|
title: z.string(),
|
|
717
733
|
createdAt: z.string(),
|
|
718
734
|
updatedAt: z.string(),
|
|
719
735
|
});
|
|
736
|
+
|
|
720
737
|
export type TSharedLink = z.infer<typeof tSharedLinkSchema>;
|
|
721
738
|
|
|
722
739
|
export const tConversationTagSchema = z.object({
|
|
@@ -747,72 +764,27 @@ export const googleSchema = tConversationSchema
|
|
|
747
764
|
spec: true,
|
|
748
765
|
maxContextTokens: true,
|
|
749
766
|
})
|
|
750
|
-
.transform((obj) =>
|
|
751
|
-
|
|
752
|
-
...obj,
|
|
753
|
-
model: obj.model ?? google.model.default,
|
|
754
|
-
modelLabel: obj.modelLabel ?? null,
|
|
755
|
-
promptPrefix: obj.promptPrefix ?? null,
|
|
756
|
-
examples: obj.examples ?? [{ input: { content: '' }, output: { content: '' } }],
|
|
757
|
-
temperature: obj.temperature ?? google.temperature.default,
|
|
758
|
-
maxOutputTokens: obj.maxOutputTokens ?? google.maxOutputTokens.default,
|
|
759
|
-
topP: obj.topP ?? google.topP.default,
|
|
760
|
-
topK: obj.topK ?? google.topK.default,
|
|
761
|
-
iconURL: obj.iconURL ?? undefined,
|
|
762
|
-
greeting: obj.greeting ?? undefined,
|
|
763
|
-
spec: obj.spec ?? undefined,
|
|
764
|
-
maxContextTokens: obj.maxContextTokens ?? undefined,
|
|
765
|
-
};
|
|
766
|
-
})
|
|
767
|
-
.catch(() => ({
|
|
768
|
-
model: google.model.default,
|
|
769
|
-
modelLabel: null,
|
|
770
|
-
promptPrefix: null,
|
|
771
|
-
examples: [{ input: { content: '' }, output: { content: '' } }],
|
|
772
|
-
temperature: google.temperature.default,
|
|
773
|
-
maxOutputTokens: google.maxOutputTokens.default,
|
|
774
|
-
topP: google.topP.default,
|
|
775
|
-
topK: google.topK.default,
|
|
776
|
-
iconURL: undefined,
|
|
777
|
-
greeting: undefined,
|
|
778
|
-
spec: undefined,
|
|
779
|
-
maxContextTokens: undefined,
|
|
780
|
-
}));
|
|
767
|
+
.transform((obj: Partial<TConversation>) => removeNullishValues(obj))
|
|
768
|
+
.catch(() => ({}));
|
|
781
769
|
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
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(),
|
|
792
785
|
})
|
|
793
|
-
.
|
|
794
|
-
|
|
795
|
-
model: '',
|
|
796
|
-
jailbreak: obj.jailbreak ?? false,
|
|
797
|
-
systemMessage: obj.systemMessage ?? null,
|
|
798
|
-
context: obj.context ?? null,
|
|
799
|
-
toneStyle: obj.toneStyle ?? 'creative',
|
|
800
|
-
jailbreakConversationId: obj.jailbreakConversationId ?? null,
|
|
801
|
-
conversationSignature: obj.conversationSignature ?? null,
|
|
802
|
-
clientId: obj.clientId ?? null,
|
|
803
|
-
invocationId: obj.invocationId ?? 1,
|
|
804
|
-
}))
|
|
805
|
-
.catch(() => ({
|
|
806
|
-
model: '',
|
|
807
|
-
jailbreak: false,
|
|
808
|
-
systemMessage: null,
|
|
809
|
-
context: null,
|
|
810
|
-
toneStyle: 'creative',
|
|
811
|
-
jailbreakConversationId: null,
|
|
812
|
-
conversationSignature: null,
|
|
813
|
-
clientId: null,
|
|
814
|
-
invocationId: 1,
|
|
815
|
-
}));
|
|
786
|
+
.strip()
|
|
787
|
+
.optional();
|
|
816
788
|
|
|
817
789
|
export const chatGPTBrowserSchema = tConversationSchema
|
|
818
790
|
.pick({
|
|
@@ -894,7 +866,10 @@ export const gptPluginsSchema = tConversationSchema
|
|
|
894
866
|
maxContextTokens: undefined,
|
|
895
867
|
}));
|
|
896
868
|
|
|
897
|
-
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> {
|
|
898
873
|
const newObj: Partial<T> = { ...obj };
|
|
899
874
|
|
|
900
875
|
(Object.keys(newObj) as Array<keyof T>).forEach((key) => {
|
|
@@ -902,6 +877,9 @@ export function removeNullishValues<T extends Record<string, unknown>>(obj: T):
|
|
|
902
877
|
if (value === undefined || value === null) {
|
|
903
878
|
delete newObj[key];
|
|
904
879
|
}
|
|
880
|
+
if (removeEmptyStrings && typeof value === 'string' && value === '') {
|
|
881
|
+
delete newObj[key];
|
|
882
|
+
}
|
|
905
883
|
});
|
|
906
884
|
|
|
907
885
|
return newObj;
|
|
@@ -952,8 +930,7 @@ export const compactAssistantSchema = tConversationSchema
|
|
|
952
930
|
greeting: true,
|
|
953
931
|
spec: true,
|
|
954
932
|
})
|
|
955
|
-
|
|
956
|
-
.transform(removeNullishValues)
|
|
933
|
+
.transform((obj) => removeNullishValues(obj))
|
|
957
934
|
.catch(() => ({}));
|
|
958
935
|
|
|
959
936
|
export const agentsSchema = tConversationSchema
|
|
@@ -1027,6 +1004,7 @@ export const openAISchema = tConversationSchema
|
|
|
1027
1004
|
spec: true,
|
|
1028
1005
|
maxContextTokens: true,
|
|
1029
1006
|
max_tokens: true,
|
|
1007
|
+
reasoning_effort: true,
|
|
1030
1008
|
})
|
|
1031
1009
|
.transform((obj: Partial<TConversation>) => removeNullishValues(obj))
|
|
1032
1010
|
.catch(() => ({}));
|
|
@@ -1077,6 +1055,8 @@ export const anthropicSchema = tConversationSchema
|
|
|
1077
1055
|
topK: true,
|
|
1078
1056
|
resendFiles: true,
|
|
1079
1057
|
promptCache: true,
|
|
1058
|
+
thinking: true,
|
|
1059
|
+
thinkingBudget: true,
|
|
1080
1060
|
artifacts: true,
|
|
1081
1061
|
iconURL: true,
|
|
1082
1062
|
greeting: true,
|
|
@@ -1154,7 +1134,7 @@ export const compactPluginsSchema = tConversationSchema
|
|
|
1154
1134
|
})
|
|
1155
1135
|
.catch(() => ({}));
|
|
1156
1136
|
|
|
1157
|
-
const tBannerSchema = z.object({
|
|
1137
|
+
export const tBannerSchema = z.object({
|
|
1158
1138
|
bannerId: z.string(),
|
|
1159
1139
|
message: z.string(),
|
|
1160
1140
|
displayFrom: z.string(),
|
|
@@ -1172,9 +1152,8 @@ export const compactAgentsSchema = tConversationSchema
|
|
|
1172
1152
|
iconURL: true,
|
|
1173
1153
|
greeting: true,
|
|
1174
1154
|
agent_id: true,
|
|
1175
|
-
resendFiles: true,
|
|
1176
1155
|
instructions: true,
|
|
1177
1156
|
additional_instructions: true,
|
|
1178
1157
|
})
|
|
1179
|
-
.transform(removeNullishValues)
|
|
1158
|
+
.transform((obj) => removeNullishValues(obj))
|
|
1180
1159
|
.catch(() => ({}));
|