librechat-data-provider 0.4.9 → 0.5.0
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/actions.spec.ts +33 -0
- package/src/actions.ts +8 -0
- package/src/config.ts +1 -0
- package/src/file-config.ts +4 -4
- package/src/schemas.ts +15 -13
- package/src/types/files.ts +7 -0
- package/src/types.ts +1 -1
package/src/actions.ts
CHANGED
|
@@ -95,6 +95,14 @@ export class ActionRequest {
|
|
|
95
95
|
async setParams(params: object) {
|
|
96
96
|
this.operationHash = sha1(JSON.stringify(params));
|
|
97
97
|
this.params = params;
|
|
98
|
+
|
|
99
|
+
for (const [key, value] of Object.entries(params)) {
|
|
100
|
+
const paramPattern = `{${key}}`;
|
|
101
|
+
if (this.path.includes(paramPattern)) {
|
|
102
|
+
this.path = this.path.replace(paramPattern, encodeURIComponent(value as string));
|
|
103
|
+
delete (this.params as Record<string, unknown>)[key];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
98
106
|
}
|
|
99
107
|
|
|
100
108
|
async setAuth(metadata: ActionMetadata) {
|
package/src/config.ts
CHANGED
package/src/file-config.ts
CHANGED
|
@@ -109,7 +109,7 @@ export const textMimeTypes =
|
|
|
109
109
|
/^(text\/(x-c|x-c\+\+|x-java|html|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain|css|javascript|csv))$/;
|
|
110
110
|
|
|
111
111
|
export const applicationMimeTypes =
|
|
112
|
-
/^(application\/(csv|json|pdf|x-tar|typescript|vnd\.openxmlformats-officedocument\.(wordprocessingml\.document|presentationml\.presentation|spreadsheetml\.sheet)|xml|zip))$/;
|
|
112
|
+
/^(application\/(epub\+zip|csv|json|pdf|x-tar|typescript|vnd\.openxmlformats-officedocument\.(wordprocessingml\.document|presentationml\.presentation|spreadsheetml\.sheet)|xml|zip))$/;
|
|
113
113
|
|
|
114
114
|
export const imageMimeTypes = /^image\/(jpeg|gif|png|webp)$/;
|
|
115
115
|
|
|
@@ -147,9 +147,9 @@ export const fileConfig = {
|
|
|
147
147
|
},
|
|
148
148
|
default: {
|
|
149
149
|
fileLimit: 10,
|
|
150
|
-
fileSizeLimit: mbToBytes(
|
|
151
|
-
totalSizeLimit: mbToBytes(
|
|
152
|
-
supportedMimeTypes
|
|
150
|
+
fileSizeLimit: mbToBytes(512),
|
|
151
|
+
totalSizeLimit: mbToBytes(512),
|
|
152
|
+
supportedMimeTypes,
|
|
153
153
|
disabled: false,
|
|
154
154
|
},
|
|
155
155
|
},
|
package/src/schemas.ts
CHANGED
|
@@ -216,8 +216,10 @@ export const tConversationSchema = z.object({
|
|
|
216
216
|
maxOutputTokens: z.number().optional(),
|
|
217
217
|
agentOptions: tAgentOptionsSchema.nullable().optional(),
|
|
218
218
|
file_ids: z.array(z.string()).optional(),
|
|
219
|
-
|
|
219
|
+
/** @deprecated */
|
|
220
220
|
resendImages: z.boolean().optional(),
|
|
221
|
+
/* vision */
|
|
222
|
+
resendFiles: z.boolean().optional(),
|
|
221
223
|
imageDetail: eImageDetailSchema.optional(),
|
|
222
224
|
/* assistant */
|
|
223
225
|
assistant_id: z.string().optional(),
|
|
@@ -273,7 +275,7 @@ export const openAISchema = tConversationSchema
|
|
|
273
275
|
top_p: true,
|
|
274
276
|
presence_penalty: true,
|
|
275
277
|
frequency_penalty: true,
|
|
276
|
-
|
|
278
|
+
resendFiles: true,
|
|
277
279
|
imageDetail: true,
|
|
278
280
|
})
|
|
279
281
|
.transform((obj) => ({
|
|
@@ -285,7 +287,7 @@ export const openAISchema = tConversationSchema
|
|
|
285
287
|
top_p: obj.top_p ?? 1,
|
|
286
288
|
presence_penalty: obj.presence_penalty ?? 0,
|
|
287
289
|
frequency_penalty: obj.frequency_penalty ?? 0,
|
|
288
|
-
|
|
290
|
+
resendFiles: typeof obj.resendFiles === 'boolean' ? obj.resendFiles : true,
|
|
289
291
|
imageDetail: obj.imageDetail ?? ImageDetail.auto,
|
|
290
292
|
}))
|
|
291
293
|
.catch(() => ({
|
|
@@ -296,7 +298,7 @@ export const openAISchema = tConversationSchema
|
|
|
296
298
|
top_p: 1,
|
|
297
299
|
presence_penalty: 0,
|
|
298
300
|
frequency_penalty: 0,
|
|
299
|
-
|
|
301
|
+
resendFiles: true,
|
|
300
302
|
imageDetail: ImageDetail.auto,
|
|
301
303
|
}));
|
|
302
304
|
|
|
@@ -391,7 +393,7 @@ export const anthropicSchema = tConversationSchema
|
|
|
391
393
|
maxOutputTokens: true,
|
|
392
394
|
topP: true,
|
|
393
395
|
topK: true,
|
|
394
|
-
|
|
396
|
+
resendFiles: true,
|
|
395
397
|
})
|
|
396
398
|
.transform((obj) => ({
|
|
397
399
|
...obj,
|
|
@@ -402,7 +404,7 @@ export const anthropicSchema = tConversationSchema
|
|
|
402
404
|
maxOutputTokens: obj.maxOutputTokens ?? 4000,
|
|
403
405
|
topP: obj.topP ?? 0.7,
|
|
404
406
|
topK: obj.topK ?? 5,
|
|
405
|
-
|
|
407
|
+
resendFiles: typeof obj.resendFiles === 'boolean' ? obj.resendFiles : true,
|
|
406
408
|
}))
|
|
407
409
|
.catch(() => ({
|
|
408
410
|
model: 'claude-1',
|
|
@@ -412,7 +414,7 @@ export const anthropicSchema = tConversationSchema
|
|
|
412
414
|
maxOutputTokens: 4000,
|
|
413
415
|
topP: 0.7,
|
|
414
416
|
topK: 5,
|
|
415
|
-
|
|
417
|
+
resendFiles: true,
|
|
416
418
|
}));
|
|
417
419
|
|
|
418
420
|
export const chatGPTBrowserSchema = tConversationSchema
|
|
@@ -504,7 +506,7 @@ export const compactOpenAISchema = tConversationSchema
|
|
|
504
506
|
top_p: true,
|
|
505
507
|
presence_penalty: true,
|
|
506
508
|
frequency_penalty: true,
|
|
507
|
-
|
|
509
|
+
resendFiles: true,
|
|
508
510
|
imageDetail: true,
|
|
509
511
|
})
|
|
510
512
|
.transform((obj: Partial<TConversation>) => {
|
|
@@ -521,8 +523,8 @@ export const compactOpenAISchema = tConversationSchema
|
|
|
521
523
|
if (newObj.frequency_penalty === 0) {
|
|
522
524
|
delete newObj.frequency_penalty;
|
|
523
525
|
}
|
|
524
|
-
if (newObj.
|
|
525
|
-
delete newObj.
|
|
526
|
+
if (newObj.resendFiles === true) {
|
|
527
|
+
delete newObj.resendFiles;
|
|
526
528
|
}
|
|
527
529
|
if (newObj.imageDetail === ImageDetail.auto) {
|
|
528
530
|
delete newObj.imageDetail;
|
|
@@ -571,7 +573,7 @@ export const compactAnthropicSchema = tConversationSchema
|
|
|
571
573
|
maxOutputTokens: true,
|
|
572
574
|
topP: true,
|
|
573
575
|
topK: true,
|
|
574
|
-
|
|
576
|
+
resendFiles: true,
|
|
575
577
|
})
|
|
576
578
|
.transform((obj) => {
|
|
577
579
|
const newObj: Partial<TConversation> = { ...obj };
|
|
@@ -587,8 +589,8 @@ export const compactAnthropicSchema = tConversationSchema
|
|
|
587
589
|
if (newObj.topK === 5) {
|
|
588
590
|
delete newObj.topK;
|
|
589
591
|
}
|
|
590
|
-
if (newObj.
|
|
591
|
-
delete newObj.
|
|
592
|
+
if (newObj.resendFiles === true) {
|
|
593
|
+
delete newObj.resendFiles;
|
|
592
594
|
}
|
|
593
595
|
|
|
594
596
|
return removeNullishValues(newObj);
|
package/src/types/files.ts
CHANGED
|
@@ -12,6 +12,11 @@ export enum FileContext {
|
|
|
12
12
|
image_generation = 'image_generation',
|
|
13
13
|
assistants_output = 'assistants_output',
|
|
14
14
|
message_attachment = 'message_attachment',
|
|
15
|
+
filename = 'filename',
|
|
16
|
+
updatedAt = 'updatedAt',
|
|
17
|
+
source = 'source',
|
|
18
|
+
context = 'context',
|
|
19
|
+
bytes = 'bytes',
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
export type EndpointFileConfig = {
|
|
@@ -40,6 +45,7 @@ export type TFile = {
|
|
|
40
45
|
file_id: string;
|
|
41
46
|
temp_file_id?: string;
|
|
42
47
|
bytes: number;
|
|
48
|
+
embedded: boolean;
|
|
43
49
|
filename: string;
|
|
44
50
|
filepath: string;
|
|
45
51
|
object: 'file';
|
|
@@ -83,6 +89,7 @@ export type DeleteFilesResponse = {
|
|
|
83
89
|
export type BatchFile = {
|
|
84
90
|
file_id: string;
|
|
85
91
|
filepath: string;
|
|
92
|
+
embedded: boolean;
|
|
86
93
|
source: FileSources;
|
|
87
94
|
};
|
|
88
95
|
|
package/src/types.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type TEndpointOption = {
|
|
|
16
16
|
endpoint: EModelEndpoint;
|
|
17
17
|
endpointType?: EModelEndpoint;
|
|
18
18
|
modelDisplayLabel?: string;
|
|
19
|
-
|
|
19
|
+
resendFiles?: boolean;
|
|
20
20
|
imageDetail?: ImageDetail;
|
|
21
21
|
model?: string | null;
|
|
22
22
|
promptPrefix?: string;
|