librechat-data-provider 0.6.0 → 0.6.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "librechat-data-provider",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "data services for librechat apps",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -21,8 +21,8 @@ export const abortRequest = (endpoint: string) => `/api/ask/${endpoint}/abort`;
21
21
 
22
22
  export const conversationsRoot = '/api/convos';
23
23
 
24
- export const conversations = (pageNumber: string) =>
25
- `${conversationsRoot}?pageNumber=${pageNumber}`;
24
+ export const conversations = (pageNumber: string, isArchived?: boolean) =>
25
+ `${conversationsRoot}?pageNumber=${pageNumber}${isArchived ? '&isArchived=true' : ''}`;
26
26
 
27
27
  export const conversationById = (id: string) => `${conversationsRoot}/${id}`;
28
28
 
@@ -34,6 +34,8 @@ export const deleteConversation = () => `${conversationsRoot}/clear`;
34
34
 
35
35
  export const importConversation = () => `${conversationsRoot}/import`;
36
36
 
37
+ export const forkConversation = () => `${conversationsRoot}/fork`;
38
+
37
39
  export const importConversationJobStatus = (jobId: string) =>
38
40
  `${conversationsRoot}/import/jobs/${jobId}`;
39
41
 
package/src/config.ts CHANGED
@@ -306,6 +306,7 @@ export enum KnownEndpoints {
306
306
  cohere = 'cohere',
307
307
  fireworks = 'fireworks',
308
308
  groq = 'groq',
309
+ huggingface = 'huggingface',
309
310
  mistral = 'mistral',
310
311
  mlx = 'mlx',
311
312
  ollama = 'ollama',
@@ -459,13 +460,13 @@ export const supportsBalanceCheck = {
459
460
  };
460
461
 
461
462
  export const visionModels = [
463
+ 'gpt-4-turbo',
462
464
  'gpt-4-vision',
463
465
  'llava',
464
466
  'llava-13b',
465
467
  'gemini-pro-vision',
466
468
  'claude-3',
467
469
  'gemini-1.5',
468
- 'gpt-4-turbo',
469
470
  ];
470
471
  export enum VisionModes {
471
472
  generative = 'generative',
@@ -653,6 +654,10 @@ export enum SettingsTabValues {
653
654
  * Tab for General Settings
654
655
  */
655
656
  GENERAL = 'general',
657
+ /**
658
+ * Tab for Messages Settings
659
+ */
660
+ MESSAGES = 'messages',
656
661
  /**
657
662
  * Tab for Beta Features
658
663
  */
@@ -698,6 +703,21 @@ export enum LocalStorageKeys {
698
703
  FILES_TO_DELETE = 'filesToDelete',
699
704
  /** Prefix key for the last selected assistant ID by index */
700
705
  ASST_ID_PREFIX = 'assistant_id__',
706
+ /** Key for the last selected fork setting */
707
+ FORK_SETTING = 'forkSetting',
708
+ /** Key for remembering the last selected option, instead of manually selecting */
709
+ REMEMBER_FORK_OPTION = 'rememberForkOption',
710
+ /** Key for remembering the split at target fork option modifier */
711
+ FORK_SPLIT_AT_TARGET = 'splitAtTarget',
712
+ }
713
+
714
+ export enum ForkOptions {
715
+ /** Key for direct path option */
716
+ DIRECT_PATH = 'directPath',
717
+ /** Key for including branches */
718
+ INCLUDE_BRANCHES = 'includeBranches',
719
+ /** Key for target level fork (default) */
720
+ TARGET_LEVEL = '',
701
721
  }
702
722
 
703
723
  /**
@@ -261,6 +261,10 @@ export const deleteAction = async (
261
261
 
262
262
  /* conversations */
263
263
 
264
+ export function forkConversation(payload: t.TForkConvoRequest): Promise<t.TForkConvoResponse> {
265
+ return request.post(endpoints.forkConversation(), payload);
266
+ }
267
+
264
268
  export function deleteConversation(payload: t.TDeleteConversationRequest) {
265
269
  //todo: this should be a DELETE request
266
270
  return request.post(endpoints.deleteConversation(), { arg: payload });
@@ -275,7 +279,8 @@ export const listConversations = (
275
279
  ): Promise<q.ConversationListResponse> => {
276
280
  // Assuming params has a pageNumber property
277
281
  const pageNumber = params?.pageNumber || '1'; // Default to page 1 if not provided
278
- return request.get(endpoints.conversations(pageNumber));
282
+ const isArchived = params?.isArchived || false; // Default to false if not provided
283
+ return request.get(endpoints.conversations(pageNumber, isArchived));
279
284
  };
280
285
 
281
286
  export const listConversationsByQuery = (
@@ -312,6 +317,12 @@ export function updateConversation(
312
317
  return request.post(endpoints.updateConversation(), { arg: payload });
313
318
  }
314
319
 
320
+ export function archiveConversation(
321
+ payload: t.TArchiveConversationRequest,
322
+ ): Promise<t.TArchiveConversationResponse> {
323
+ return request.post(endpoints.updateConversation(), { arg: payload });
324
+ }
325
+
315
326
  export function genTitle(payload: m.TGenTitleRequest): Promise<m.TGenTitleResponse> {
316
327
  return request.post(endpoints.genTitle(), payload);
317
328
  }
package/src/generate.ts CHANGED
@@ -72,6 +72,8 @@ export type DynamicSettingProps = Partial<SettingDefinition> & {
72
72
  setOption: TSetOption;
73
73
  conversation: TConversation | TPreset | null;
74
74
  defaultValue?: number | boolean | string | string[];
75
+ className?: string;
76
+ inputClassName?: string;
75
77
  };
76
78
 
77
79
  const requiredSettingFields = ['key', 'type', 'component'];
@@ -508,6 +510,7 @@ export const generateOpenAISchema = (customOpenAI: OpenAISettings) => {
508
510
  frequency_penalty: true,
509
511
  resendFiles: true,
510
512
  imageDetail: true,
513
+ maxContextTokens: true,
511
514
  })
512
515
  .transform((obj) => ({
513
516
  ...obj,
@@ -521,6 +524,7 @@ export const generateOpenAISchema = (customOpenAI: OpenAISettings) => {
521
524
  resendFiles:
522
525
  typeof obj.resendFiles === 'boolean' ? obj.resendFiles : defaults.resendFiles.default,
523
526
  imageDetail: obj.imageDetail ?? defaults.imageDetail.default,
527
+ maxContextTokens: obj.maxContextTokens ?? undefined,
524
528
  }))
525
529
  .catch(() => ({
526
530
  model: defaults.model.default,
@@ -532,6 +536,7 @@ export const generateOpenAISchema = (customOpenAI: OpenAISettings) => {
532
536
  frequency_penalty: defaults.frequency_penalty.default,
533
537
  resendFiles: defaults.resendFiles.default,
534
538
  imageDetail: defaults.imageDetail.default,
539
+ maxContextTokens: undefined,
535
540
  }));
536
541
  };
537
542
 
@@ -547,6 +552,7 @@ export const generateGoogleSchema = (customGoogle: GoogleSettings) => {
547
552
  maxOutputTokens: true,
548
553
  topP: true,
549
554
  topK: true,
555
+ maxContextTokens: true,
550
556
  })
551
557
  .transform((obj) => {
552
558
  const isGemini = obj?.model?.toLowerCase()?.includes('gemini');
@@ -571,6 +577,7 @@ export const generateGoogleSchema = (customGoogle: GoogleSettings) => {
571
577
  maxOutputTokens,
572
578
  topP: obj.topP ?? defaults.topP.default,
573
579
  topK: obj.topK ?? defaults.topK.default,
580
+ maxContextTokens: obj.maxContextTokens ?? undefined,
574
581
  };
575
582
  })
576
583
  .catch(() => ({
@@ -582,5 +589,6 @@ export const generateGoogleSchema = (customGoogle: GoogleSettings) => {
582
589
  maxOutputTokens: defaults.maxOutputTokens.default,
583
590
  topP: defaults.topP.default,
584
591
  topK: defaults.topK.default,
592
+ maxContextTokens: undefined,
585
593
  }));
586
594
  };
package/src/keys.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export enum QueryKeys {
2
2
  messages = 'messages',
3
3
  allConversations = 'allConversations',
4
+ archivedConversations = 'archivedConversations',
4
5
  searchConversations = 'searchConversations',
5
6
  conversation = 'conversation',
6
7
  searchEnabled = 'searchEnabled',
package/src/schemas.ts CHANGED
@@ -105,6 +105,12 @@ export const openAISettings = {
105
105
  resendFiles: {
106
106
  default: true,
107
107
  },
108
+ maxContextTokens: {
109
+ default: undefined,
110
+ },
111
+ max_tokens: {
112
+ default: undefined,
113
+ },
108
114
  imageDetail: {
109
115
  default: ImageDetail.auto,
110
116
  },
@@ -274,6 +280,13 @@ export type TMessage = z.input<typeof tMessageSchema> & {
274
280
  files?: Partial<TFile>[];
275
281
  };
276
282
 
283
+ export const coerceNumber = z.union([z.number(), z.string()]).transform((val) => {
284
+ if (typeof val === 'string') {
285
+ return val.trim() === '' ? undefined : parseFloat(val);
286
+ }
287
+ return val;
288
+ });
289
+
277
290
  export const tConversationSchema = z.object({
278
291
  conversationId: z.string().nullable(),
279
292
  title: z.string().nullable().or(z.literal('New Chat')).default('New Chat'),
@@ -309,6 +322,8 @@ export const tConversationSchema = z.object({
309
322
  maxOutputTokens: z.number().optional(),
310
323
  agentOptions: tAgentOptionsSchema.nullable().optional(),
311
324
  file_ids: z.array(z.string()).optional(),
325
+ maxContextTokens: coerceNumber.optional(),
326
+ max_tokens: coerceNumber.optional(),
312
327
  /** @deprecated */
313
328
  resendImages: z.boolean().optional(),
314
329
  /* vision */
@@ -382,6 +397,8 @@ export const openAISchema = tConversationSchema
382
397
  iconURL: true,
383
398
  greeting: true,
384
399
  spec: true,
400
+ maxContextTokens: true,
401
+ max_tokens: true,
385
402
  })
386
403
  .transform((obj) => ({
387
404
  ...obj,
@@ -399,6 +416,8 @@ export const openAISchema = tConversationSchema
399
416
  iconURL: obj.iconURL ?? undefined,
400
417
  greeting: obj.greeting ?? undefined,
401
418
  spec: obj.spec ?? undefined,
419
+ maxContextTokens: obj.maxContextTokens ?? undefined,
420
+ max_tokens: obj.max_tokens ?? undefined,
402
421
  }))
403
422
  .catch(() => ({
404
423
  model: openAISettings.model.default,
@@ -414,6 +433,8 @@ export const openAISchema = tConversationSchema
414
433
  iconURL: undefined,
415
434
  greeting: undefined,
416
435
  spec: undefined,
436
+ maxContextTokens: undefined,
437
+ max_tokens: undefined,
417
438
  }));
418
439
 
419
440
  export const googleSchema = tConversationSchema
@@ -429,6 +450,7 @@ export const googleSchema = tConversationSchema
429
450
  iconURL: true,
430
451
  greeting: true,
431
452
  spec: true,
453
+ maxContextTokens: true,
432
454
  })
433
455
  .transform((obj) => {
434
456
  const isGemini = obj?.model?.toLowerCase()?.includes('gemini');
@@ -456,6 +478,7 @@ export const googleSchema = tConversationSchema
456
478
  iconURL: obj.iconURL ?? undefined,
457
479
  greeting: obj.greeting ?? undefined,
458
480
  spec: obj.spec ?? undefined,
481
+ maxContextTokens: obj.maxContextTokens ?? undefined,
459
482
  };
460
483
  })
461
484
  .catch(() => ({
@@ -470,6 +493,7 @@ export const googleSchema = tConversationSchema
470
493
  iconURL: undefined,
471
494
  greeting: undefined,
472
495
  spec: undefined,
496
+ maxContextTokens: undefined,
473
497
  }));
474
498
 
475
499
  export const bingAISchema = tConversationSchema
@@ -520,6 +544,7 @@ export const anthropicSchema = tConversationSchema
520
544
  iconURL: true,
521
545
  greeting: true,
522
546
  spec: true,
547
+ maxContextTokens: true,
523
548
  })
524
549
  .transform((obj) => ({
525
550
  ...obj,
@@ -534,6 +559,7 @@ export const anthropicSchema = tConversationSchema
534
559
  iconURL: obj.iconURL ?? undefined,
535
560
  greeting: obj.greeting ?? undefined,
536
561
  spec: obj.spec ?? undefined,
562
+ maxContextTokens: obj.maxContextTokens ?? undefined,
537
563
  }))
538
564
  .catch(() => ({
539
565
  model: 'claude-1',
@@ -547,6 +573,7 @@ export const anthropicSchema = tConversationSchema
547
573
  iconURL: undefined,
548
574
  greeting: undefined,
549
575
  spec: undefined,
576
+ maxContextTokens: undefined,
550
577
  }));
551
578
 
552
579
  export const chatGPTBrowserSchema = tConversationSchema
@@ -576,6 +603,7 @@ export const gptPluginsSchema = tConversationSchema
576
603
  iconURL: true,
577
604
  greeting: true,
578
605
  spec: true,
606
+ maxContextTokens: true,
579
607
  })
580
608
  .transform((obj) => ({
581
609
  ...obj,
@@ -596,6 +624,7 @@ export const gptPluginsSchema = tConversationSchema
596
624
  iconURL: obj.iconURL ?? undefined,
597
625
  greeting: obj.greeting ?? undefined,
598
626
  spec: obj.spec ?? undefined,
627
+ maxContextTokens: obj.maxContextTokens ?? undefined,
599
628
  }))
600
629
  .catch(() => ({
601
630
  model: 'gpt-3.5-turbo',
@@ -615,6 +644,7 @@ export const gptPluginsSchema = tConversationSchema
615
644
  iconURL: undefined,
616
645
  greeting: undefined,
617
646
  spec: undefined,
647
+ maxContextTokens: undefined,
618
648
  }));
619
649
 
620
650
  export function removeNullishValues<T extends object>(obj: T): T {
@@ -688,6 +718,8 @@ export const compactOpenAISchema = tConversationSchema
688
718
  iconURL: true,
689
719
  greeting: true,
690
720
  spec: true,
721
+ maxContextTokens: true,
722
+ max_tokens: true,
691
723
  })
692
724
  .transform((obj: Partial<TConversation>) => {
693
725
  const newObj: Partial<TConversation> = { ...obj };
@@ -727,6 +759,7 @@ export const compactGoogleSchema = tConversationSchema
727
759
  iconURL: true,
728
760
  greeting: true,
729
761
  spec: true,
762
+ maxContextTokens: true,
730
763
  })
731
764
  .transform((obj) => {
732
765
  const newObj: Partial<TConversation> = { ...obj };
@@ -760,6 +793,7 @@ export const compactAnthropicSchema = tConversationSchema
760
793
  iconURL: true,
761
794
  greeting: true,
762
795
  spec: true,
796
+ maxContextTokens: true,
763
797
  })
764
798
  .transform((obj) => {
765
799
  const newObj: Partial<TConversation> = { ...obj };
@@ -807,6 +841,7 @@ export const compactPluginsSchema = tConversationSchema
807
841
  iconURL: true,
808
842
  greeting: true,
809
843
  spec: true,
844
+ maxContextTokens: true,
810
845
  })
811
846
  .transform((obj) => {
812
847
  const newObj: Partial<TConversation> = { ...obj };
@@ -1,4 +1,4 @@
1
- import { TPreset, TDeleteConversationResponse, TDeleteConversationRequest } from '../types';
1
+ import type * as types from '../types';
2
2
  import {
3
3
  Assistant,
4
4
  AssistantCreateParams,
@@ -9,6 +9,18 @@ import {
9
9
  Action,
10
10
  } from './assistants';
11
11
 
12
+ export type MutationOptions<
13
+ Response,
14
+ Request,
15
+ Context = unknown,
16
+ Error = unknown,
17
+ Snapshot = void,
18
+ > = {
19
+ onSuccess?: (data: Response, variables: Request, context?: Context) => void;
20
+ onMutate?: (variables: Request) => Snapshot | Promise<Snapshot>;
21
+ onError?: (error: Error, variables: Request, context?: Context, snapshot?: Snapshot) => void;
22
+ };
23
+
12
24
  export type TGenTitleRequest = {
13
25
  conversationId: string;
14
26
  };
@@ -22,27 +34,11 @@ export type PresetDeleteResponse = {
22
34
  deletedCount: number;
23
35
  };
24
36
 
25
- export type UpdatePresetOptions = {
26
- onSuccess?: (data: TPreset, variables: TPreset, context?: unknown) => void;
27
- onMutate?: (variables: TPreset) => void | Promise<unknown>;
28
- onError?: (error: unknown, variables: TPreset, context?: unknown) => void;
29
- };
37
+ export type UpdatePresetOptions = MutationOptions<types.TPreset, types.TPreset>;
30
38
 
31
- export type DeletePresetOptions = {
32
- onSuccess?: (
33
- data: PresetDeleteResponse,
34
- variables: TPreset | undefined,
35
- context?: unknown,
36
- ) => void;
37
- onMutate?: (variables: TPreset | undefined) => void | Promise<unknown>;
38
- onError?: (error: unknown, variables: TPreset | undefined, context?: unknown) => void;
39
- };
39
+ export type DeletePresetOptions = MutationOptions<PresetDeleteResponse, types.TPreset | undefined>;
40
40
 
41
- export type LogoutOptions = {
42
- onSuccess?: (data: unknown, variables: undefined, context?: unknown) => void;
43
- onMutate?: (variables: undefined) => void | Promise<unknown>;
44
- onError?: (error: unknown, variables: undefined, context?: unknown) => void;
45
- };
41
+ export type LogoutOptions = MutationOptions<unknown, undefined>;
46
42
 
47
43
  export type AssistantAvatarVariables = {
48
44
  assistant_id: string;
@@ -59,53 +55,26 @@ export type UpdateActionVariables = {
59
55
  model: string;
60
56
  };
61
57
 
62
- export type UploadAssistantAvatarOptions = {
63
- onSuccess?: (data: Assistant, variables: AssistantAvatarVariables, context?: unknown) => void;
64
- onMutate?: (variables: AssistantAvatarVariables) => void | Promise<unknown>;
65
- onError?: (error: unknown, variables: AssistantAvatarVariables, context?: unknown) => void;
66
- };
58
+ export type UploadAssistantAvatarOptions = MutationOptions<Assistant, AssistantAvatarVariables>;
67
59
 
68
- export type CreateAssistantMutationOptions = {
69
- onSuccess?: (data: Assistant, variables: AssistantCreateParams, context?: unknown) => void;
70
- onMutate?: (variables: AssistantCreateParams) => void | Promise<unknown>;
71
- onError?: (error: unknown, variables: AssistantCreateParams, context?: unknown) => void;
72
- };
60
+ export type CreateAssistantMutationOptions = MutationOptions<Assistant, AssistantCreateParams>;
73
61
 
74
- export type UpdateAssistantMutationOptions = {
75
- onSuccess?: (
76
- data: Assistant,
77
- variables: { assistant_id: string; data: AssistantUpdateParams },
78
- context?: unknown,
79
- ) => void;
80
- onMutate?: (variables: {
81
- assistant_id: string;
82
- data: AssistantUpdateParams;
83
- }) => void | Promise<unknown>;
84
- onError?: (
85
- error: unknown,
86
- variables: { assistant_id: string; data: AssistantUpdateParams },
87
- context?: unknown,
88
- ) => void;
62
+ export type UpdateAssistantVariables = {
63
+ assistant_id: string;
64
+ data: AssistantUpdateParams;
89
65
  };
90
66
 
67
+ export type UpdateAssistantMutationOptions = MutationOptions<Assistant, UpdateAssistantVariables>;
68
+
91
69
  export type DeleteAssistantBody = { assistant_id: string; model: string };
92
70
 
93
- export type DeleteAssistantMutationOptions = {
94
- onSuccess?: (data: void, variables: { assistant_id: string }, context?: unknown) => void;
95
- onMutate?: (variables: { assistant_id: string }) => void | Promise<unknown>;
96
- onError?: (error: unknown, variables: { assistant_id: string }, context?: unknown) => void;
97
- };
71
+ export type DeleteAssistantMutationOptions = MutationOptions<
72
+ void,
73
+ Pick<DeleteAssistantBody, 'assistant_id'>
74
+ >;
98
75
 
99
76
  export type UpdateActionResponse = [AssistantDocument, Assistant, Action];
100
- export type UpdateActionOptions = {
101
- onSuccess?: (
102
- data: UpdateActionResponse,
103
- variables: UpdateActionVariables,
104
- context?: unknown,
105
- ) => void;
106
- onMutate?: (variables: UpdateActionVariables) => void | Promise<unknown>;
107
- onError?: (error: unknown, variables: UpdateActionVariables, context?: unknown) => void;
108
- };
77
+ export type UpdateActionOptions = MutationOptions<UpdateActionResponse, UpdateActionVariables>;
109
78
 
110
79
  export type DeleteActionVariables = {
111
80
  assistant_id: string;
@@ -113,18 +82,11 @@ export type DeleteActionVariables = {
113
82
  model: string;
114
83
  };
115
84
 
116
- export type DeleteActionOptions = {
117
- onSuccess?: (data: void, variables: DeleteActionVariables, context?: unknown) => void;
118
- onMutate?: (variables: DeleteActionVariables) => void | Promise<unknown>;
119
- onError?: (error: unknown, variables: DeleteActionVariables, context?: unknown) => void;
120
- };
85
+ export type DeleteActionOptions = MutationOptions<void, DeleteActionVariables>;
121
86
 
122
- export type DeleteConversationOptions = {
123
- onSuccess?: (
124
- data: TDeleteConversationResponse,
125
- variables: TDeleteConversationRequest,
126
- context?: unknown,
127
- ) => void;
128
- onMutate?: (variables: TDeleteConversationRequest) => void | Promise<unknown>;
129
- onError?: (error: unknown, variables: TDeleteConversationRequest, context?: unknown) => void;
130
- };
87
+ export type DeleteConversationOptions = MutationOptions<
88
+ types.TDeleteConversationResponse,
89
+ types.TDeleteConversationRequest
90
+ >;
91
+
92
+ export type ForkConvoOptions = MutationOptions<types.TForkConvoResponse, types.TForkConvoRequest>;
@@ -16,6 +16,7 @@ export type ConversationListParams = {
16
16
  order?: 'asc' | 'desc';
17
17
  pageNumber: string; // Add this line
18
18
  conversationId?: string;
19
+ isArchived: boolean;
19
20
  };
20
21
 
21
22
  // Type for the response from the conversation list API
package/src/types.ts CHANGED
@@ -17,6 +17,7 @@ export type TEndpointOption = {
17
17
  endpointType?: EModelEndpoint;
18
18
  modelDisplayLabel?: string;
19
19
  resendFiles?: boolean;
20
+ maxContextTokens?: number;
20
21
  imageDetail?: ImageDetail;
21
22
  model?: string | null;
22
23
  promptPrefix?: string;
@@ -125,6 +126,26 @@ export type TDeleteConversationResponse = {
125
126
  };
126
127
  };
127
128
 
129
+ export type TArchiveConversationRequest = {
130
+ conversationId: string;
131
+ isArchived: boolean;
132
+ };
133
+
134
+ export type TArchiveConversationResponse = TConversation;
135
+
136
+ export type TForkConvoRequest = {
137
+ messageId: string;
138
+ conversationId: string;
139
+ option?: string;
140
+ splitAtTarget?: boolean;
141
+ latestMessageId?: string;
142
+ };
143
+
144
+ export type TForkConvoResponse = {
145
+ conversation: TConversation;
146
+ messages: TMessage[];
147
+ };
148
+
128
149
  export type TSearchResults = {
129
150
  conversations: TConversation[];
130
151
  messages: TMessage[];