librechat-data-provider 0.5.2 → 0.5.3
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/package.json +1 -1
- package/specs/generate.spec.ts +586 -0
- package/src/config.ts +19 -0
- package/src/data-service.ts +5 -3
- package/src/generate.ts +474 -0
- package/src/index.ts +1 -0
- package/src/react-query/react-query-service.ts +7 -6
- package/src/schemas.ts +109 -117
package/src/schemas.ts
CHANGED
|
@@ -17,6 +17,26 @@ export enum EModelEndpoint {
|
|
|
17
17
|
custom = 'custom',
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
export enum ImageDetail {
|
|
21
|
+
low = 'low',
|
|
22
|
+
auto = 'auto',
|
|
23
|
+
high = 'high',
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const imageDetailNumeric = {
|
|
27
|
+
[ImageDetail.low]: 0,
|
|
28
|
+
[ImageDetail.auto]: 1,
|
|
29
|
+
[ImageDetail.high]: 2,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const imageDetailValue = {
|
|
33
|
+
0: ImageDetail.low,
|
|
34
|
+
1: ImageDetail.auto,
|
|
35
|
+
2: ImageDetail.high,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const eImageDetailSchema = z.nativeEnum(ImageDetail);
|
|
39
|
+
|
|
20
40
|
export const defaultAssistantFormValues = {
|
|
21
41
|
assistant: '',
|
|
22
42
|
id: '',
|
|
@@ -46,66 +66,85 @@ export const ImageVisionTool: FunctionTool = {
|
|
|
46
66
|
export const isImageVisionTool = (tool: FunctionTool | FunctionToolCall) =>
|
|
47
67
|
tool.type === 'function' && tool.function?.name === ImageVisionTool?.function?.name;
|
|
48
68
|
|
|
49
|
-
export const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
export const openAISettings = {
|
|
70
|
+
model: {
|
|
71
|
+
default: 'gpt-3.5-turbo',
|
|
72
|
+
},
|
|
73
|
+
temperature: {
|
|
74
|
+
min: 0,
|
|
75
|
+
max: 1,
|
|
76
|
+
step: 0.01,
|
|
77
|
+
default: 1,
|
|
78
|
+
},
|
|
79
|
+
top_p: {
|
|
80
|
+
min: 0,
|
|
81
|
+
max: 1,
|
|
82
|
+
step: 0.01,
|
|
83
|
+
default: 1,
|
|
84
|
+
},
|
|
85
|
+
presence_penalty: {
|
|
86
|
+
min: 0,
|
|
87
|
+
max: 2,
|
|
88
|
+
step: 0.01,
|
|
89
|
+
default: 0,
|
|
90
|
+
},
|
|
91
|
+
frequency_penalty: {
|
|
92
|
+
min: 0,
|
|
93
|
+
max: 2,
|
|
94
|
+
step: 0.01,
|
|
95
|
+
default: 0,
|
|
96
|
+
},
|
|
97
|
+
resendFiles: {
|
|
98
|
+
default: true,
|
|
99
|
+
},
|
|
100
|
+
imageDetail: {
|
|
101
|
+
default: ImageDetail.auto,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const googleSettings = {
|
|
106
|
+
model: {
|
|
107
|
+
default: 'chat-bison',
|
|
108
|
+
},
|
|
109
|
+
maxOutputTokens: {
|
|
110
|
+
min: 1,
|
|
111
|
+
max: 2048,
|
|
112
|
+
step: 1,
|
|
113
|
+
default: 1024,
|
|
114
|
+
maxGeminiPro: 8192,
|
|
115
|
+
defaultGeminiPro: 8192,
|
|
116
|
+
},
|
|
117
|
+
temperature: {
|
|
118
|
+
min: 0,
|
|
119
|
+
max: 1,
|
|
120
|
+
step: 0.01,
|
|
121
|
+
default: 0.2,
|
|
122
|
+
},
|
|
123
|
+
topP: {
|
|
124
|
+
min: 0,
|
|
125
|
+
max: 1,
|
|
126
|
+
step: 0.01,
|
|
127
|
+
default: 0.8,
|
|
128
|
+
},
|
|
129
|
+
topK: {
|
|
130
|
+
min: 1,
|
|
131
|
+
max: 40,
|
|
132
|
+
step: 0.01,
|
|
133
|
+
default: 40,
|
|
80
134
|
},
|
|
81
135
|
};
|
|
82
136
|
|
|
137
|
+
export const endpointSettings = {
|
|
138
|
+
[EModelEndpoint.openAI]: openAISettings,
|
|
139
|
+
[EModelEndpoint.google]: googleSettings,
|
|
140
|
+
};
|
|
141
|
+
|
|
83
142
|
const google = endpointSettings[EModelEndpoint.google];
|
|
84
143
|
|
|
85
144
|
export const eModelEndpointSchema = z.nativeEnum(EModelEndpoint);
|
|
86
145
|
|
|
87
146
|
export const extendedModelEndpointSchema = z.union([eModelEndpointSchema, z.string()]);
|
|
88
147
|
|
|
89
|
-
export enum ImageDetail {
|
|
90
|
-
low = 'low',
|
|
91
|
-
auto = 'auto',
|
|
92
|
-
high = 'high',
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export const imageDetailNumeric = {
|
|
96
|
-
[ImageDetail.low]: 0,
|
|
97
|
-
[ImageDetail.auto]: 1,
|
|
98
|
-
[ImageDetail.high]: 2,
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export const imageDetailValue = {
|
|
102
|
-
0: ImageDetail.low,
|
|
103
|
-
1: ImageDetail.auto,
|
|
104
|
-
2: ImageDetail.high,
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export const eImageDetailSchema = z.nativeEnum(ImageDetail);
|
|
108
|
-
|
|
109
148
|
export const tPluginAuthConfigSchema = z.object({
|
|
110
149
|
authField: z.string(),
|
|
111
150
|
label: z.string(),
|
|
@@ -278,12 +317,14 @@ export const tPresetUpdateSchema = tConversationSchema.merge(
|
|
|
278
317
|
|
|
279
318
|
export type TPreset = z.infer<typeof tPresetSchema>;
|
|
280
319
|
|
|
320
|
+
export type TSetOption = (
|
|
321
|
+
param: number | string,
|
|
322
|
+
) => (newValue: number | string | boolean | Partial<TPreset>) => void;
|
|
323
|
+
|
|
281
324
|
export type TConversation = z.infer<typeof tConversationSchema> & {
|
|
282
325
|
presetOverride?: Partial<TPreset>;
|
|
283
326
|
};
|
|
284
327
|
|
|
285
|
-
// type DefaultSchemaValues = Partial<typeof google>;
|
|
286
|
-
|
|
287
328
|
export const openAISchema = tConversationSchema
|
|
288
329
|
.pick({
|
|
289
330
|
model: true,
|
|
@@ -298,26 +339,27 @@ export const openAISchema = tConversationSchema
|
|
|
298
339
|
})
|
|
299
340
|
.transform((obj) => ({
|
|
300
341
|
...obj,
|
|
301
|
-
model: obj.model ??
|
|
342
|
+
model: obj.model ?? openAISettings.model.default,
|
|
302
343
|
chatGptLabel: obj.chatGptLabel ?? null,
|
|
303
344
|
promptPrefix: obj.promptPrefix ?? null,
|
|
304
|
-
temperature: obj.temperature ??
|
|
305
|
-
top_p: obj.top_p ??
|
|
306
|
-
presence_penalty: obj.presence_penalty ??
|
|
307
|
-
frequency_penalty: obj.frequency_penalty ??
|
|
308
|
-
resendFiles:
|
|
309
|
-
|
|
345
|
+
temperature: obj.temperature ?? openAISettings.temperature.default,
|
|
346
|
+
top_p: obj.top_p ?? openAISettings.top_p.default,
|
|
347
|
+
presence_penalty: obj.presence_penalty ?? openAISettings.presence_penalty.default,
|
|
348
|
+
frequency_penalty: obj.frequency_penalty ?? openAISettings.frequency_penalty.default,
|
|
349
|
+
resendFiles:
|
|
350
|
+
typeof obj.resendFiles === 'boolean' ? obj.resendFiles : openAISettings.resendFiles.default,
|
|
351
|
+
imageDetail: obj.imageDetail ?? openAISettings.imageDetail.default,
|
|
310
352
|
}))
|
|
311
353
|
.catch(() => ({
|
|
312
|
-
model:
|
|
354
|
+
model: openAISettings.model.default,
|
|
313
355
|
chatGptLabel: null,
|
|
314
356
|
promptPrefix: null,
|
|
315
|
-
temperature:
|
|
316
|
-
top_p:
|
|
317
|
-
presence_penalty:
|
|
318
|
-
frequency_penalty:
|
|
319
|
-
resendFiles:
|
|
320
|
-
imageDetail:
|
|
357
|
+
temperature: openAISettings.temperature.default,
|
|
358
|
+
top_p: openAISettings.top_p.default,
|
|
359
|
+
presence_penalty: openAISettings.presence_penalty.default,
|
|
360
|
+
frequency_penalty: openAISettings.frequency_penalty.default,
|
|
361
|
+
resendFiles: openAISettings.resendFiles.default,
|
|
362
|
+
imageDetail: openAISettings.imageDetail.default,
|
|
321
363
|
}));
|
|
322
364
|
|
|
323
365
|
export const googleSchema = tConversationSchema
|
|
@@ -674,53 +716,3 @@ export const compactPluginsSchema = tConversationSchema
|
|
|
674
716
|
return removeNullishValues(newObj);
|
|
675
717
|
})
|
|
676
718
|
.catch(() => ({}));
|
|
677
|
-
|
|
678
|
-
// const createGoogleSchema = (customGoogle: DefaultSchemaValues) => {
|
|
679
|
-
// const defaults = { ...google, ...customGoogle };
|
|
680
|
-
// return tConversationSchema
|
|
681
|
-
// .pick({
|
|
682
|
-
// model: true,
|
|
683
|
-
// modelLabel: true,
|
|
684
|
-
// promptPrefix: true,
|
|
685
|
-
// examples: true,
|
|
686
|
-
// temperature: true,
|
|
687
|
-
// maxOutputTokens: true,
|
|
688
|
-
// topP: true,
|
|
689
|
-
// topK: true,
|
|
690
|
-
// })
|
|
691
|
-
// .transform((obj) => {
|
|
692
|
-
// const isGeminiPro = obj?.model?.toLowerCase()?.includes('gemini-pro');
|
|
693
|
-
|
|
694
|
-
// const maxOutputTokensMax = isGeminiPro
|
|
695
|
-
// ? defaults.maxOutputTokens.maxGeminiPro
|
|
696
|
-
// : defaults.maxOutputTokens.max;
|
|
697
|
-
// const maxOutputTokensDefault = isGeminiPro
|
|
698
|
-
// ? defaults.maxOutputTokens.defaultGeminiPro
|
|
699
|
-
// : defaults.maxOutputTokens.default;
|
|
700
|
-
|
|
701
|
-
// let maxOutputTokens = obj.maxOutputTokens ?? maxOutputTokensDefault;
|
|
702
|
-
// maxOutputTokens = Math.min(maxOutputTokens, maxOutputTokensMax);
|
|
703
|
-
|
|
704
|
-
// return {
|
|
705
|
-
// ...obj,
|
|
706
|
-
// model: obj.model ?? defaults.model.default,
|
|
707
|
-
// modelLabel: obj.modelLabel ?? null,
|
|
708
|
-
// promptPrefix: obj.promptPrefix ?? null,
|
|
709
|
-
// examples: obj.examples ?? [{ input: { content: '' }, output: { content: '' } }],
|
|
710
|
-
// temperature: obj.temperature ?? defaults.temperature.default,
|
|
711
|
-
// maxOutputTokens,
|
|
712
|
-
// topP: obj.topP ?? defaults.topP.default,
|
|
713
|
-
// topK: obj.topK ?? defaults.topK.default,
|
|
714
|
-
// };
|
|
715
|
-
// })
|
|
716
|
-
// .catch(() => ({
|
|
717
|
-
// model: defaults.model.default,
|
|
718
|
-
// modelLabel: null,
|
|
719
|
-
// promptPrefix: null,
|
|
720
|
-
// examples: [{ input: { content: '' }, output: { content: '' } }],
|
|
721
|
-
// temperature: defaults.temperature.default,
|
|
722
|
-
// maxOutputTokens: defaults.maxOutputTokens.default,
|
|
723
|
-
// topP: defaults.topP.default,
|
|
724
|
-
// topK: defaults.topK.default,
|
|
725
|
-
// }));
|
|
726
|
-
// };
|