librechat-data-provider 0.8.402 → 0.8.404

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.
Files changed (109) hide show
  1. package/dist/index.es.js +1 -1
  2. package/dist/index.es.js.map +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/react-query/index.es.js +1 -1
  6. package/dist/react-query/index.es.js.map +1 -1
  7. package/dist/types/accessPermissions.d.ts +744 -0
  8. package/dist/types/actions.d.ts +118 -0
  9. package/dist/types/api-endpoints.d.ts +150 -0
  10. package/dist/types/artifacts.d.ts +97 -0
  11. package/dist/types/azure.d.ts +22 -0
  12. package/dist/types/bedrock.d.ts +1220 -0
  13. package/dist/types/config.d.ts +14849 -0
  14. package/dist/types/config.spec.d.ts +1 -0
  15. package/dist/types/createPayload.d.ts +5 -0
  16. package/dist/types/data-service.d.ts +287 -0
  17. package/dist/types/feedback.d.ts +36 -0
  18. package/dist/types/file-config.d.ts +263 -0
  19. package/dist/types/file-config.spec.d.ts +1 -0
  20. package/dist/types/generate.d.ts +597 -0
  21. package/dist/types/headers-helpers.d.ts +2 -0
  22. package/{src/index.ts → dist/types/index.d.ts} +0 -15
  23. package/dist/types/keys.d.ts +92 -0
  24. package/dist/types/mcp.d.ts +2760 -0
  25. package/dist/types/messages.d.ts +10 -0
  26. package/dist/types/models.d.ts +1547 -0
  27. package/dist/types/parameterSettings.d.ts +69 -0
  28. package/dist/types/parsers.d.ts +110 -0
  29. package/dist/types/permissions.d.ts +522 -0
  30. package/dist/types/react-query/react-query-service.d.ts +85 -0
  31. package/dist/types/request.d.ts +25 -0
  32. package/dist/types/roles.d.ts +554 -0
  33. package/dist/types/roles.spec.d.ts +1 -0
  34. package/dist/types/schemas.d.ts +5110 -0
  35. package/dist/types/schemas.spec.d.ts +1 -0
  36. package/dist/types/types/agents.d.ts +433 -0
  37. package/dist/types/types/assistants.d.ts +547 -0
  38. package/dist/types/types/files.d.ts +172 -0
  39. package/dist/types/types/graph.d.ts +135 -0
  40. package/{src/types/mcpServers.ts → dist/types/types/mcpServers.d.ts} +12 -18
  41. package/dist/types/types/mutations.d.ts +209 -0
  42. package/dist/types/types/queries.d.ts +169 -0
  43. package/dist/types/types/runs.d.ts +36 -0
  44. package/dist/types/types/web.d.ts +520 -0
  45. package/dist/types/types.d.ts +503 -0
  46. package/dist/types/utils.d.ts +12 -0
  47. package/package.json +5 -1
  48. package/babel.config.js +0 -4
  49. package/check_updates.sh +0 -52
  50. package/jest.config.js +0 -19
  51. package/react-query/package-lock.json +0 -292
  52. package/react-query/package.json +0 -10
  53. package/rollup.config.js +0 -74
  54. package/server-rollup.config.js +0 -40
  55. package/specs/actions.spec.ts +0 -2533
  56. package/specs/api-endpoints-subdir.spec.ts +0 -140
  57. package/specs/api-endpoints.spec.ts +0 -74
  58. package/specs/azure.spec.ts +0 -844
  59. package/specs/bedrock.spec.ts +0 -862
  60. package/specs/filetypes.spec.ts +0 -175
  61. package/specs/generate.spec.ts +0 -770
  62. package/specs/headers-helpers.spec.ts +0 -24
  63. package/specs/mcp.spec.ts +0 -147
  64. package/specs/openapiSpecs.ts +0 -524
  65. package/specs/parsers.spec.ts +0 -601
  66. package/specs/request-interceptor.spec.ts +0 -304
  67. package/specs/utils.spec.ts +0 -196
  68. package/src/accessPermissions.ts +0 -346
  69. package/src/actions.ts +0 -813
  70. package/src/api-endpoints.ts +0 -440
  71. package/src/artifacts.ts +0 -3104
  72. package/src/azure.ts +0 -328
  73. package/src/bedrock.ts +0 -425
  74. package/src/config.spec.ts +0 -315
  75. package/src/config.ts +0 -2006
  76. package/src/createPayload.ts +0 -46
  77. package/src/data-service.ts +0 -1087
  78. package/src/feedback.ts +0 -141
  79. package/src/file-config.spec.ts +0 -1248
  80. package/src/file-config.ts +0 -764
  81. package/src/generate.ts +0 -634
  82. package/src/headers-helpers.ts +0 -13
  83. package/src/keys.ts +0 -99
  84. package/src/mcp.ts +0 -271
  85. package/src/messages.ts +0 -50
  86. package/src/models.ts +0 -69
  87. package/src/parameterSettings.ts +0 -1111
  88. package/src/parsers.ts +0 -563
  89. package/src/permissions.ts +0 -188
  90. package/src/react-query/react-query-service.ts +0 -566
  91. package/src/request.ts +0 -171
  92. package/src/roles.spec.ts +0 -132
  93. package/src/roles.ts +0 -225
  94. package/src/schemas.spec.ts +0 -355
  95. package/src/schemas.ts +0 -1234
  96. package/src/types/agents.ts +0 -470
  97. package/src/types/assistants.ts +0 -654
  98. package/src/types/files.ts +0 -191
  99. package/src/types/graph.ts +0 -145
  100. package/src/types/mutations.ts +0 -422
  101. package/src/types/queries.ts +0 -208
  102. package/src/types/runs.ts +0 -40
  103. package/src/types/web.ts +0 -588
  104. package/src/types.ts +0 -676
  105. package/src/utils.ts +0 -85
  106. package/tsconfig.json +0 -28
  107. package/tsconfig.spec.json +0 -10
  108. /package/{src/react-query/index.ts → dist/types/react-query/index.d.ts} +0 -0
  109. /package/{src/types/index.ts → dist/types/types/index.d.ts} +0 -0
package/src/generate.ts DELETED
@@ -1,634 +0,0 @@
1
- import { z, ZodArray, ZodError, ZodIssueCode } from 'zod';
2
- import { tConversationSchema, googleSettings as google, openAISettings as openAI } from './schemas';
3
- import type { ZodIssue } from 'zod';
4
- import type { TConversation, TSetOption, TPreset } from './schemas';
5
-
6
- export type GoogleSettings = Partial<typeof google>;
7
- export type OpenAISettings = Partial<typeof google>;
8
-
9
- export type ComponentType =
10
- | 'input'
11
- | 'textarea'
12
- | 'slider'
13
- | 'checkbox'
14
- | 'switch'
15
- | 'dropdown'
16
- | 'combobox'
17
- | 'tags';
18
-
19
- export type OptionType = 'conversation' | 'model' | 'custom';
20
-
21
- export type Option = Record<string, unknown> & {
22
- label?: string;
23
- value: string | number | null;
24
- };
25
-
26
- export type OptionWithIcon = Option & { icon?: React.ReactNode };
27
-
28
- export enum ComponentTypes {
29
- Input = 'input',
30
- Textarea = 'textarea',
31
- Slider = 'slider',
32
- Checkbox = 'checkbox',
33
- Switch = 'switch',
34
- Dropdown = 'dropdown',
35
- Combobox = 'combobox',
36
- Tags = 'tags',
37
- }
38
-
39
- export enum SettingTypes {
40
- Number = 'number',
41
- Boolean = 'boolean',
42
- String = 'string',
43
- Enum = 'enum',
44
- Array = 'array',
45
- }
46
-
47
- export enum OptionTypes {
48
- Conversation = 'conversation',
49
- Model = 'model',
50
- Custom = 'custom',
51
- }
52
- export interface SettingDefinition {
53
- key: string;
54
- description?: string;
55
- type: 'number' | 'boolean' | 'string' | 'enum' | 'array';
56
- default?: number | boolean | string | string[];
57
- showLabel?: boolean;
58
- showDefault?: boolean;
59
- options?: string[];
60
- range?: SettingRange;
61
- enumMappings?: Record<string, number | boolean | string>;
62
- component: ComponentType;
63
- optionType?: OptionType;
64
- columnSpan?: number;
65
- columns?: number;
66
- label?: string;
67
- placeholder?: string;
68
- labelCode?: boolean;
69
- placeholderCode?: boolean;
70
- descriptionCode?: boolean;
71
- minText?: number;
72
- maxText?: number;
73
- minTags?: number; // Specific to tags component
74
- maxTags?: number; // Specific to tags component
75
- includeInput?: boolean; // Specific to slider component
76
- descriptionSide?: 'top' | 'right' | 'bottom' | 'left';
77
- items?: OptionWithIcon[]; // Specific to combobox component
78
- searchPlaceholder?: string; // Specific to combobox component
79
- selectPlaceholder?: string; // Specific to combobox component
80
- searchPlaceholderCode?: boolean; // Specific to combobox component
81
- selectPlaceholderCode?: boolean; // Specific to combobox component
82
- }
83
-
84
- export type DynamicSettingProps = Partial<SettingDefinition> & {
85
- readonly?: boolean;
86
- settingKey: string;
87
- setOption: TSetOption;
88
- conversation: Partial<TConversation> | Partial<TPreset> | null;
89
- defaultValue?: number | boolean | string | string[];
90
- className?: string;
91
- inputClassName?: string;
92
- };
93
-
94
- const requiredSettingFields = ['key', 'type', 'component'];
95
-
96
- export interface SettingRange {
97
- min: number;
98
- max: number;
99
- step?: number;
100
- }
101
-
102
- export type SettingsConfiguration = SettingDefinition[];
103
-
104
- export function generateDynamicSchema(settings: SettingsConfiguration) {
105
- const schemaFields: { [key: string]: z.ZodTypeAny } = {};
106
-
107
- for (const setting of settings) {
108
- const {
109
- key,
110
- type,
111
- default: defaultValue,
112
- range,
113
- options,
114
- minText,
115
- maxText,
116
- minTags,
117
- maxTags,
118
- } = setting;
119
-
120
- if (type === SettingTypes.Number) {
121
- let schema = z.number();
122
- if (range) {
123
- schema = schema.min(range.min);
124
- schema = schema.max(range.max);
125
- }
126
- if (typeof defaultValue === 'number') {
127
- schemaFields[key] = schema.default(defaultValue);
128
- } else {
129
- schemaFields[key] = schema;
130
- }
131
- continue;
132
- }
133
-
134
- if (type === SettingTypes.Boolean) {
135
- const schema = z.boolean();
136
- if (typeof defaultValue === 'boolean') {
137
- schemaFields[key] = schema.default(defaultValue);
138
- } else {
139
- schemaFields[key] = schema;
140
- }
141
- continue;
142
- }
143
-
144
- if (type === SettingTypes.String) {
145
- let schema = z.string();
146
- if (minText) {
147
- schema = schema.min(minText);
148
- }
149
- if (maxText) {
150
- schema = schema.max(maxText);
151
- }
152
- if (typeof defaultValue === 'string') {
153
- schemaFields[key] = schema.default(defaultValue);
154
- } else {
155
- schemaFields[key] = schema;
156
- }
157
- continue;
158
- }
159
-
160
- if (type === SettingTypes.Enum) {
161
- if (!options || options.length === 0) {
162
- console.warn(`Missing or empty 'options' for enum setting '${key}'.`);
163
- continue;
164
- }
165
-
166
- const schema = z.enum(options as [string, ...string[]]);
167
- if (typeof defaultValue === 'string') {
168
- schemaFields[key] = schema.default(defaultValue);
169
- } else {
170
- schemaFields[key] = schema;
171
- }
172
- continue;
173
- }
174
-
175
- if (type === SettingTypes.Array) {
176
- let schema: z.ZodSchema = z.array(z.string().or(z.number()));
177
- if (minTags && schema instanceof ZodArray) {
178
- schema = schema.min(minTags);
179
- }
180
- if (maxTags && schema instanceof ZodArray) {
181
- schema = schema.max(maxTags);
182
- }
183
-
184
- if (defaultValue && Array.isArray(defaultValue)) {
185
- schema = schema.default(defaultValue);
186
- }
187
-
188
- schemaFields[key] = schema;
189
- continue;
190
- }
191
-
192
- console.warn(`Unsupported setting type: ${type}`);
193
- }
194
-
195
- return z.object(schemaFields);
196
- }
197
-
198
- const ZodTypeToSettingType: Record<string, string | undefined> = {
199
- ZodString: 'string',
200
- ZodNumber: 'number',
201
- ZodBoolean: 'boolean',
202
- };
203
-
204
- const minColumns = 1;
205
- const maxColumns = 4;
206
- const minSliderOptions = 2;
207
- const minDropdownOptions = 2;
208
- const minComboboxOptions = 2;
209
-
210
- /**
211
- * Validates the provided setting using the constraints unique to each component type.
212
- * @throws {ZodError} Throws a ZodError if any validation fails.
213
- */
214
- export function validateSettingDefinitions(settings: SettingsConfiguration): void {
215
- const errors: ZodIssue[] = [];
216
- // Validate columns
217
- const columnsSet = new Set<number>();
218
- for (const setting of settings) {
219
- if (setting.columns !== undefined) {
220
- if (setting.columns < minColumns || setting.columns > maxColumns) {
221
- errors.push({
222
- code: ZodIssueCode.custom,
223
- message: `Invalid columns value for setting ${setting.key}. Must be between ${minColumns} and ${maxColumns}.`,
224
- path: ['columns'],
225
- });
226
- } else {
227
- columnsSet.add(setting.columns);
228
- }
229
- }
230
- }
231
-
232
- const columns = columnsSet.size === 1 ? columnsSet.values().next().value : 2;
233
-
234
- for (const setting of settings) {
235
- for (const field of requiredSettingFields) {
236
- if (setting[field as keyof SettingDefinition] === undefined) {
237
- errors.push({
238
- code: ZodIssueCode.custom,
239
- message: `Missing required field ${field} for setting ${setting.key}.`,
240
- path: [field],
241
- });
242
- }
243
- }
244
-
245
- // check accepted types
246
- const settingTypes = Object.values(SettingTypes);
247
- if (!settingTypes.includes(setting.type as SettingTypes)) {
248
- errors.push({
249
- code: ZodIssueCode.custom,
250
- message: `Invalid type for setting ${setting.key}. Must be one of ${settingTypes.join(
251
- ', ',
252
- )}.`,
253
- path: ['type'],
254
- });
255
- }
256
-
257
- // Predefined constraints based on components
258
- if (
259
- (setting.component === ComponentTypes.Tags && setting.type !== SettingTypes.Array) ||
260
- (setting.component !== ComponentTypes.Tags && setting.type === SettingTypes.Array)
261
- ) {
262
- errors.push({
263
- code: ZodIssueCode.custom,
264
- message: `Tags component for setting ${setting.key} must have type array.`,
265
- path: ['type'],
266
- });
267
- }
268
-
269
- if (setting.component === ComponentTypes.Tags) {
270
- if (setting.minTags !== undefined && setting.minTags < 0) {
271
- errors.push({
272
- code: ZodIssueCode.custom,
273
- message: `Invalid minTags value for setting ${setting.key}. Must be non-negative.`,
274
- path: ['minTags'],
275
- });
276
- }
277
- if (setting.maxTags !== undefined && setting.maxTags < 0) {
278
- errors.push({
279
- code: ZodIssueCode.custom,
280
- message: `Invalid maxTags value for setting ${setting.key}. Must be non-negative.`,
281
- path: ['maxTags'],
282
- });
283
- }
284
- if (setting.default && !Array.isArray(setting.default)) {
285
- errors.push({
286
- code: ZodIssueCode.custom,
287
- message: `Invalid default value for setting ${setting.key}. Must be an array.`,
288
- path: ['default'],
289
- });
290
- }
291
- if (setting.default && setting.maxTags && (setting.default as []).length > setting.maxTags) {
292
- errors.push({
293
- code: ZodIssueCode.custom,
294
- message: `Invalid default value for setting ${setting.key}. Must have at most ${setting.maxTags} tags.`,
295
- path: ['default'],
296
- });
297
- }
298
- if (setting.default && setting.minTags && (setting.default as []).length < setting.minTags) {
299
- errors.push({
300
- code: ZodIssueCode.custom,
301
- message: `Invalid default value for setting ${setting.key}. Must have at least ${setting.minTags} tags.`,
302
- path: ['default'],
303
- });
304
- }
305
- if (!setting.default) {
306
- setting.default = [];
307
- }
308
- }
309
-
310
- if (
311
- setting.component === ComponentTypes.Input ||
312
- setting.component === ComponentTypes.Textarea
313
- ) {
314
- if (setting.type === SettingTypes.Number && setting.component === ComponentTypes.Textarea) {
315
- errors.push({
316
- code: ZodIssueCode.custom,
317
- message: `Textarea component for setting ${setting.key} must have type string.`,
318
- path: ['type'],
319
- });
320
- // continue;
321
- }
322
-
323
- if (
324
- setting.minText !== undefined &&
325
- setting.maxText !== undefined &&
326
- setting.minText > setting.maxText
327
- ) {
328
- errors.push({
329
- code: ZodIssueCode.custom,
330
- message: `For setting ${setting.key}, minText cannot be greater than maxText.`,
331
- path: [setting.key, 'minText', 'maxText'],
332
- });
333
- // continue;
334
- }
335
- if (!setting.placeholder) {
336
- setting.placeholder = '';
337
- } // Default placeholder
338
- }
339
-
340
- if (setting.component === ComponentTypes.Slider) {
341
- if (setting.type === SettingTypes.Number && !setting.range) {
342
- errors.push({
343
- code: ZodIssueCode.custom,
344
- message: `Slider component for setting ${setting.key} must have a range if type is number.`,
345
- path: ['range'],
346
- });
347
- // continue;
348
- }
349
- if (
350
- setting.type === SettingTypes.Enum &&
351
- (!setting.options || setting.options.length < minSliderOptions)
352
- ) {
353
- errors.push({
354
- code: ZodIssueCode.custom,
355
- message: `Slider component for setting ${setting.key} requires at least ${minSliderOptions} options for enum type.`,
356
- path: ['options'],
357
- });
358
- // continue;
359
- }
360
- setting.includeInput =
361
- setting.type === SettingTypes.Number ? (setting.includeInput ?? true) : false; // Default to true if type is number
362
- }
363
-
364
- if (setting.component === ComponentTypes.Slider && setting.type === SettingTypes.Number) {
365
- if (setting.default === undefined && setting.range) {
366
- // Set default to the middle of the range if unspecified
367
- setting.default = Math.round((setting.range.min + setting.range.max) / 2);
368
- }
369
- }
370
-
371
- if (
372
- setting.component === ComponentTypes.Checkbox ||
373
- setting.component === ComponentTypes.Switch
374
- ) {
375
- if (setting.options && setting.options.length > 2) {
376
- errors.push({
377
- code: ZodIssueCode.custom,
378
- message: `Checkbox/Switch component for setting ${setting.key} must have 1-2 options.`,
379
- path: ['options'],
380
- });
381
- // continue;
382
- }
383
- if (!setting.default && setting.type === SettingTypes.Boolean) {
384
- setting.default = false; // Default to false if type is boolean
385
- }
386
- }
387
-
388
- if (setting.component === ComponentTypes.Dropdown) {
389
- if (!setting.options || setting.options.length < minDropdownOptions) {
390
- errors.push({
391
- code: ZodIssueCode.custom,
392
- message: `Dropdown component for setting ${setting.key} requires at least ${minDropdownOptions} options.`,
393
- path: ['options'],
394
- });
395
- // continue;
396
- }
397
- if (!setting.default && setting.options && setting.options.length > 0) {
398
- setting.default = setting.options[0]; // Default to first option if not specified
399
- }
400
- }
401
-
402
- if (setting.component === ComponentTypes.Combobox) {
403
- if (!setting.options || setting.options.length < minComboboxOptions) {
404
- errors.push({
405
- code: ZodIssueCode.custom,
406
- message: `Combobox component for setting ${setting.key} requires at least ${minComboboxOptions} options.`,
407
- path: ['options'],
408
- });
409
- }
410
- if (!setting.default && setting.options && setting.options.length > 0) {
411
- setting.default = setting.options[0];
412
- }
413
- }
414
-
415
- // Default columnSpan
416
- if (!setting.columnSpan) {
417
- setting.columnSpan = Math.floor((columns ?? 0) / 2);
418
- }
419
-
420
- // Default label to key
421
- if (!setting.label) {
422
- setting.label = setting.key;
423
- }
424
-
425
- // Validate minText and maxText for input/textarea
426
- if (
427
- setting.component === ComponentTypes.Input ||
428
- setting.component === ComponentTypes.Textarea
429
- ) {
430
- if (setting.minText !== undefined && setting.minText < 0) {
431
- errors.push({
432
- code: ZodIssueCode.custom,
433
- message: `Invalid minText value for setting ${setting.key}. Must be non-negative.`,
434
- path: ['minText'],
435
- });
436
- }
437
- if (setting.maxText !== undefined && setting.maxText < 0) {
438
- errors.push({
439
- code: ZodIssueCode.custom,
440
- message: `Invalid maxText value for setting ${setting.key}. Must be non-negative.`,
441
- path: ['maxText'],
442
- });
443
- }
444
- }
445
-
446
- // Validate optionType and conversation schema
447
- if (setting.optionType !== OptionTypes.Custom) {
448
- const conversationSchema =
449
- tConversationSchema.shape[setting.key as keyof Omit<TConversation, 'disableParams'>];
450
- if (!conversationSchema) {
451
- errors.push({
452
- code: ZodIssueCode.custom,
453
- message: `Setting ${setting.key} with optionType "${setting.optionType}" must be defined in tConversationSchema.`,
454
- path: ['optionType'],
455
- });
456
- } else {
457
- const zodType = conversationSchema._def.typeName;
458
- const settingTypeEquivalent = ZodTypeToSettingType[zodType] || null;
459
- if (settingTypeEquivalent !== setting.type) {
460
- errors.push({
461
- code: ZodIssueCode.custom,
462
- message: `Setting ${setting.key} with optionType "${setting.optionType}" must match the type defined in tConversationSchema.`,
463
- path: ['optionType'],
464
- });
465
- }
466
- }
467
- }
468
-
469
- /* Default value checks */
470
- if (
471
- setting.type === SettingTypes.Number &&
472
- isNaN(setting.default as number) &&
473
- setting.default != null
474
- ) {
475
- errors.push({
476
- code: ZodIssueCode.custom,
477
- message: `Invalid default value for setting ${setting.key}. Must be a number.`,
478
- path: ['default'],
479
- });
480
- }
481
-
482
- if (
483
- setting.type === SettingTypes.Boolean &&
484
- typeof setting.default !== 'boolean' &&
485
- setting.default != null
486
- ) {
487
- errors.push({
488
- code: ZodIssueCode.custom,
489
- message: `Invalid default value for setting ${setting.key}. Must be a boolean.`,
490
- path: ['default'],
491
- });
492
- }
493
-
494
- if (
495
- (setting.type === SettingTypes.String || setting.type === SettingTypes.Enum) &&
496
- typeof setting.default !== 'string' &&
497
- setting.default != null
498
- ) {
499
- errors.push({
500
- code: ZodIssueCode.custom,
501
- message: `Invalid default value for setting ${setting.key}. Must be a string.`,
502
- path: ['default'],
503
- });
504
- }
505
-
506
- if (
507
- setting.type === SettingTypes.Enum &&
508
- setting.options &&
509
- !setting.options.includes(setting.default as string)
510
- ) {
511
- errors.push({
512
- code: ZodIssueCode.custom,
513
- message: `Invalid default value for setting ${
514
- setting.key
515
- }. Must be one of the options: [${setting.options.join(', ')}].`,
516
- path: ['default'],
517
- });
518
- }
519
-
520
- if (
521
- setting.type === SettingTypes.Number &&
522
- setting.range &&
523
- typeof setting.default === 'number' &&
524
- (setting.default < setting.range.min || setting.default > setting.range.max)
525
- ) {
526
- errors.push({
527
- code: ZodIssueCode.custom,
528
- message: `Invalid default value for setting ${setting.key}. Must be within the range [${setting.range.min}, ${setting.range.max}].`,
529
- path: ['default'],
530
- });
531
- }
532
-
533
- // Validate enumMappings
534
- if (setting.enumMappings && setting.type === SettingTypes.Enum && setting.options) {
535
- for (const option of setting.options) {
536
- if (!(option in setting.enumMappings)) {
537
- errors.push({
538
- code: ZodIssueCode.custom,
539
- message: `Missing enumMapping for option "${option}" in setting ${setting.key}.`,
540
- path: ['enumMappings'],
541
- });
542
- }
543
- }
544
- }
545
- }
546
-
547
- if (errors.length > 0) {
548
- throw new ZodError(errors);
549
- }
550
- }
551
-
552
- export const generateOpenAISchema = (customOpenAI: OpenAISettings) => {
553
- const defaults = { ...openAI, ...customOpenAI };
554
- return tConversationSchema
555
- .pick({
556
- model: true,
557
- chatGptLabel: true,
558
- promptPrefix: true,
559
- temperature: true,
560
- top_p: true,
561
- presence_penalty: true,
562
- frequency_penalty: true,
563
- resendFiles: true,
564
- imageDetail: true,
565
- maxContextTokens: true,
566
- })
567
- .transform((obj) => ({
568
- ...obj,
569
- model: obj.model ?? defaults.model.default,
570
- chatGptLabel: obj.chatGptLabel ?? null,
571
- promptPrefix: obj.promptPrefix ?? null,
572
- temperature: obj.temperature ?? defaults.temperature.default,
573
- top_p: obj.top_p ?? defaults.top_p.default,
574
- presence_penalty: obj.presence_penalty ?? defaults.presence_penalty.default,
575
- frequency_penalty: obj.frequency_penalty ?? defaults.frequency_penalty.default,
576
- resendFiles:
577
- typeof obj.resendFiles === 'boolean' ? obj.resendFiles : defaults.resendFiles.default,
578
- imageDetail: obj.imageDetail ?? defaults.imageDetail.default,
579
- maxContextTokens: obj.maxContextTokens ?? undefined,
580
- }))
581
- .catch(() => ({
582
- model: defaults.model.default,
583
- chatGptLabel: null,
584
- promptPrefix: null,
585
- temperature: defaults.temperature.default,
586
- top_p: defaults.top_p.default,
587
- presence_penalty: defaults.presence_penalty.default,
588
- frequency_penalty: defaults.frequency_penalty.default,
589
- resendFiles: defaults.resendFiles.default,
590
- imageDetail: defaults.imageDetail.default,
591
- maxContextTokens: undefined,
592
- }));
593
- };
594
-
595
- export const generateGoogleSchema = (customGoogle: GoogleSettings) => {
596
- const defaults = { ...google, ...customGoogle };
597
- return tConversationSchema
598
- .pick({
599
- model: true,
600
- modelLabel: true,
601
- promptPrefix: true,
602
- examples: true,
603
- temperature: true,
604
- maxOutputTokens: true,
605
- topP: true,
606
- topK: true,
607
- maxContextTokens: true,
608
- })
609
- .transform((obj) => {
610
- return {
611
- ...obj,
612
- model: obj.model ?? defaults.model.default,
613
- modelLabel: obj.modelLabel ?? null,
614
- promptPrefix: obj.promptPrefix ?? null,
615
- examples: obj.examples ?? [{ input: { content: '' }, output: { content: '' } }],
616
- temperature: obj.temperature ?? defaults.temperature.default,
617
- maxOutputTokens: obj.maxOutputTokens ?? defaults.maxOutputTokens.default,
618
- topP: obj.topP ?? defaults.topP.default,
619
- topK: obj.topK ?? defaults.topK.default,
620
- maxContextTokens: obj.maxContextTokens ?? undefined,
621
- };
622
- })
623
- .catch(() => ({
624
- model: defaults.model.default,
625
- modelLabel: null,
626
- promptPrefix: null,
627
- examples: [{ input: { content: '' }, output: { content: '' } }],
628
- temperature: defaults.temperature.default,
629
- maxOutputTokens: defaults.maxOutputTokens.default,
630
- topP: defaults.topP.default,
631
- topK: defaults.topK.default,
632
- maxContextTokens: undefined,
633
- }));
634
- };
@@ -1,13 +0,0 @@
1
- import axios from 'axios';
2
-
3
- export function setAcceptLanguageHeader(value: string): void {
4
- axios.defaults.headers.common['Accept-Language'] = value;
5
- }
6
-
7
- export function setTokenHeader(token: string | undefined) {
8
- if (token === undefined) {
9
- delete axios.defaults.headers.common['Authorization'];
10
- } else {
11
- axios.defaults.headers.common['Authorization'] = 'Bearer ' + token;
12
- }
13
- }