librechat-data-provider 0.7.3 → 0.7.41

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.7.3",
3
+ "version": "0.7.41",
4
4
  "description": "data services for librechat apps",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -1,5 +1,6 @@
1
1
  import type { AssistantsEndpoint } from './schemas';
2
2
 
3
+ export const health = () => '/health';
3
4
  export const user = () => '/api/user';
4
5
 
5
6
  export const balance = () => '/api/balance';
@@ -32,8 +33,10 @@ export const abortRequest = (endpoint: string) => `/api/ask/${endpoint}/abort`;
32
33
 
33
34
  export const conversationsRoot = '/api/convos';
34
35
 
35
- export const conversations = (pageNumber: string, isArchived?: boolean) =>
36
- `${conversationsRoot}?pageNumber=${pageNumber}${isArchived ? '&isArchived=true' : ''}`;
36
+ export const conversations = (pageNumber: string, isArchived?: boolean, tags?: string[]) =>
37
+ `${conversationsRoot}?pageNumber=${pageNumber}${isArchived ? '&isArchived=true' : ''}${tags
38
+ ?.map((tag) => `&tags=${tag}`)
39
+ .join('')}`;
37
40
 
38
41
  export const conversationById = (id: string) => `${conversationsRoot}/${id}`;
39
42
 
@@ -188,3 +191,14 @@ export const roles = () => '/api/roles';
188
191
  export const getRole = (roleName: string) => `${roles()}/${roleName.toLowerCase()}`;
189
192
  export const updatePromptPermissions = (roleName: string) =>
190
193
  `${roles()}/${roleName.toLowerCase()}/prompts`;
194
+
195
+ /* Conversation Tags */
196
+ export const conversationTags = (tag?: string) => `/api/tags${tag ? `/${tag}` : ''}`;
197
+
198
+ export const conversationTagsList = (pageNumber: string, sort?: string, order?: string) =>
199
+ `${conversationTags()}/list?pageNumber=${pageNumber}${sort ? `&sort=${sort}` : ''}${
200
+ order ? `&order=${order}` : ''
201
+ }`;
202
+
203
+ export const addTagToConversation = (conversationId: string) =>
204
+ `${conversationsRoot}/tags/${conversationId}`;
package/src/config.ts CHANGED
@@ -12,6 +12,7 @@ export const defaultSocialLogins = ['google', 'facebook', 'openid', 'github', 'd
12
12
  export const defaultRetrievalModels = [
13
13
  'gpt-4o',
14
14
  'gpt-4o-2024-05-13',
15
+ 'gpt-4o-2024-08-06',
15
16
  'gpt-4o-mini',
16
17
  'gpt-4o-mini-2024-07-18',
17
18
  'gpt-4-turbo-preview',
@@ -282,7 +283,7 @@ const ttsLocalaiSchema = z.object({
282
283
  const ttsSchema = z.object({
283
284
  openai: ttsOpenaiSchema.optional(),
284
285
  azureOpenAI: ttsAzureOpenAISchema.optional(),
285
- elevenLabs: ttsElevenLabsSchema.optional(),
286
+ elevenlabs: ttsElevenLabsSchema.optional(),
286
287
  localai: ttsLocalaiSchema.optional(),
287
288
  });
288
289
 
@@ -679,6 +680,7 @@ export enum InfiniteCollections {
679
680
  * Enum for time intervals
680
681
  */
681
682
  export enum Time {
683
+ ONE_HOUR = 3600000,
682
684
  THIRTY_MINUTES = 1800000,
683
685
  TEN_MINUTES = 600000,
684
686
  FIVE_MINUTES = 300000,
@@ -799,6 +801,10 @@ export enum ViolationTypes {
799
801
  * Verify Email Limit Violation.
800
802
  */
801
803
  VERIFY_EMAIL_LIMIT = 'verify_email_limit',
804
+ /**
805
+ * Verify Conversation Access violation.
806
+ */
807
+ CONVO_ACCESS = 'convo_access',
802
808
  }
803
809
 
804
810
  /**
@@ -895,6 +901,10 @@ export enum SettingsTabValues {
895
901
  * Tab for Account Settings
896
902
  */
897
903
  ACCOUNT = 'account',
904
+ /**
905
+ * Chat input commands
906
+ */
907
+ COMMANDS = 'commands',
898
908
  }
899
909
 
900
910
  export enum STTProviders {
@@ -930,7 +940,7 @@ export enum TTSProviders {
930
940
  /** Enum for app-wide constants */
931
941
  export enum Constants {
932
942
  /** Key for the app's version. */
933
- VERSION = 'v0.7.4-rc1',
943
+ VERSION = 'v0.7.4',
934
944
  /** Key for the Custom Config's version (librechat.yaml). */
935
945
  CONFIG_VERSION = '1.1.5',
936
946
  /** Standard value for the first message's `parentMessageId` value, to indicate no parent exists. */
@@ -947,6 +957,8 @@ export enum Constants {
947
957
  COMMANDS_MAX_LENGTH = 56,
948
958
  /** Default Stream Rate (ms) */
949
959
  DEFAULT_STREAM_RATE = 1,
960
+ /** Saved Tag */
961
+ SAVED_TAG = 'Saved',
950
962
  }
951
963
 
952
964
  export enum LocalStorageKeys {
@@ -424,7 +424,8 @@ export const listConversations = (
424
424
  // Assuming params has a pageNumber property
425
425
  const pageNumber = params?.pageNumber || '1'; // Default to page 1 if not provided
426
426
  const isArchived = params?.isArchived || false; // Default to false if not provided
427
- return request.get(endpoints.conversations(pageNumber, isArchived));
427
+ const tags = params?.tags || []; // Default to an empty array if not provided
428
+ return request.get(endpoints.conversations(pageNumber, isArchived, tags));
428
429
  };
429
430
 
430
431
  export const listConversationsByQuery = (
@@ -541,3 +542,38 @@ export function updatePromptPermissions(
541
542
  ): Promise<m.UpdatePromptPermResponse> {
542
543
  return request.put(endpoints.updatePromptPermissions(variables.roleName), variables.updates);
543
544
  }
545
+
546
+ /* Tags */
547
+ export function getConversationTags(): Promise<t.TConversationTagsResponse> {
548
+ return request.get(endpoints.conversationTags());
549
+ }
550
+
551
+ export function createConversationTag(
552
+ payload: t.TConversationTagRequest,
553
+ ): Promise<t.TConversationTagResponse> {
554
+ return request.post(endpoints.conversationTags(), payload);
555
+ }
556
+
557
+ export function updateConversationTag(
558
+ tag: string,
559
+ payload: t.TConversationTagRequest,
560
+ ): Promise<t.TConversationTagResponse> {
561
+ return request.put(endpoints.conversationTags(tag), payload);
562
+ }
563
+ export function deleteConversationTag(tag: string): Promise<t.TConversationTagResponse> {
564
+ return request.delete(endpoints.conversationTags(tag));
565
+ }
566
+
567
+ export function addTagToConversation(
568
+ conversationId: string,
569
+ payload: t.TTagConversationRequest,
570
+ ): Promise<t.TTagConversationResponse> {
571
+ return request.put(endpoints.addTagToConversation(conversationId), payload);
572
+ }
573
+ export function rebuildConversationTags(): Promise<t.TConversationTagsResponse> {
574
+ return request.post(endpoints.conversationTags('rebuild'));
575
+ }
576
+
577
+ export function healthCheck(): Promise<string> {
578
+ return request.get(endpoints.health());
579
+ }
package/src/keys.ts CHANGED
@@ -36,6 +36,8 @@ export enum QueryKeys {
36
36
  categories = 'categories',
37
37
  randomPrompts = 'randomPrompts',
38
38
  roles = 'roles',
39
+ conversationTags = 'conversationTags',
40
+ health = 'health',
39
41
  }
40
42
 
41
43
  export enum MutationKeys {
package/src/schemas.ts CHANGED
@@ -156,9 +156,70 @@ export const googleSettings = {
156
156
  },
157
157
  };
158
158
 
159
+ const ANTHROPIC_MAX_OUTPUT = 8192;
160
+ const LEGACY_ANTHROPIC_MAX_OUTPUT = 4096;
161
+ export const anthropicSettings = {
162
+ model: {
163
+ default: 'claude-3-5-sonnet-20240620',
164
+ },
165
+ temperature: {
166
+ min: 0,
167
+ max: 1,
168
+ step: 0.01,
169
+ default: 1,
170
+ },
171
+ maxOutputTokens: {
172
+ min: 1,
173
+ max: ANTHROPIC_MAX_OUTPUT,
174
+ step: 1,
175
+ default: ANTHROPIC_MAX_OUTPUT,
176
+ reset: (modelName: string) => {
177
+ if (modelName.includes('claude-3-5-sonnet')) {
178
+ return ANTHROPIC_MAX_OUTPUT;
179
+ }
180
+
181
+ return 4096;
182
+ },
183
+ set: (value: number, modelName: string) => {
184
+ if (!modelName.includes('claude-3-5-sonnet') && value > LEGACY_ANTHROPIC_MAX_OUTPUT) {
185
+ return LEGACY_ANTHROPIC_MAX_OUTPUT;
186
+ }
187
+
188
+ return value;
189
+ },
190
+ },
191
+ topP: {
192
+ min: 0,
193
+ max: 1,
194
+ step: 0.01,
195
+ default: 0.7,
196
+ },
197
+ topK: {
198
+ min: 1,
199
+ max: 40,
200
+ step: 1,
201
+ default: 5,
202
+ },
203
+ resendFiles: {
204
+ default: true,
205
+ },
206
+ maxContextTokens: {
207
+ default: undefined,
208
+ },
209
+ legacy: {
210
+ maxOutputTokens: {
211
+ min: 1,
212
+ max: LEGACY_ANTHROPIC_MAX_OUTPUT,
213
+ step: 1,
214
+ default: LEGACY_ANTHROPIC_MAX_OUTPUT,
215
+ },
216
+ },
217
+ };
218
+
159
219
  export const endpointSettings = {
160
220
  [EModelEndpoint.openAI]: openAISettings,
161
221
  [EModelEndpoint.google]: googleSettings,
222
+ [EModelEndpoint.anthropic]: anthropicSettings,
162
223
  };
163
224
 
164
225
  const google = endpointSettings[EModelEndpoint.google];
@@ -310,6 +371,7 @@ export const tConversationSchema = z.object({
310
371
  updatedAt: z.string(),
311
372
  modelLabel: z.string().nullable().optional(),
312
373
  examples: z.array(tExampleSchema).optional(),
374
+ tags: z.array(z.string()).optional(),
313
375
  /* Prefer modelLabel over chatGptLabel */
314
376
  chatGptLabel: z.string().nullable().optional(),
315
377
  userLabel: z.string().optional(),
@@ -415,6 +477,17 @@ export const tSharedLinkSchema = z.object({
415
477
  });
416
478
  export type TSharedLink = z.infer<typeof tSharedLinkSchema>;
417
479
 
480
+ export const tConversationTagSchema = z.object({
481
+ user: z.string(),
482
+ tag: z.string(),
483
+ description: z.string().optional(),
484
+ createdAt: z.string(),
485
+ updatedAt: z.string(),
486
+ count: z.number(),
487
+ position: z.number(),
488
+ });
489
+ export type TConversationTag = z.infer<typeof tConversationTagSchema>;
490
+
418
491
  export const openAISchema = tConversationSchema
419
492
  .pick({
420
493
  model: true,
@@ -576,34 +649,40 @@ export const anthropicSchema = tConversationSchema
576
649
  spec: true,
577
650
  maxContextTokens: true,
578
651
  })
579
- .transform((obj) => ({
580
- ...obj,
581
- model: obj.model ?? 'claude-1',
582
- modelLabel: obj.modelLabel ?? null,
583
- promptPrefix: obj.promptPrefix ?? null,
584
- temperature: obj.temperature ?? 1,
585
- maxOutputTokens: obj.maxOutputTokens ?? 4000,
586
- topP: obj.topP ?? 0.7,
587
- topK: obj.topK ?? 5,
588
- resendFiles: typeof obj.resendFiles === 'boolean' ? obj.resendFiles : true,
589
- iconURL: obj.iconURL ?? undefined,
590
- greeting: obj.greeting ?? undefined,
591
- spec: obj.spec ?? undefined,
592
- maxContextTokens: obj.maxContextTokens ?? undefined,
593
- }))
652
+ .transform((obj) => {
653
+ const model = obj.model ?? anthropicSettings.model.default;
654
+ return {
655
+ ...obj,
656
+ model,
657
+ modelLabel: obj.modelLabel ?? null,
658
+ promptPrefix: obj.promptPrefix ?? null,
659
+ temperature: obj.temperature ?? anthropicSettings.temperature.default,
660
+ maxOutputTokens: obj.maxOutputTokens ?? anthropicSettings.maxOutputTokens.reset(model),
661
+ topP: obj.topP ?? anthropicSettings.topP.default,
662
+ topK: obj.topK ?? anthropicSettings.topK.default,
663
+ resendFiles:
664
+ typeof obj.resendFiles === 'boolean'
665
+ ? obj.resendFiles
666
+ : anthropicSettings.resendFiles.default,
667
+ iconURL: obj.iconURL ?? undefined,
668
+ greeting: obj.greeting ?? undefined,
669
+ spec: obj.spec ?? undefined,
670
+ maxContextTokens: obj.maxContextTokens ?? anthropicSettings.maxContextTokens.default,
671
+ };
672
+ })
594
673
  .catch(() => ({
595
- model: 'claude-1',
674
+ model: anthropicSettings.model.default,
596
675
  modelLabel: null,
597
676
  promptPrefix: null,
598
- temperature: 1,
599
- maxOutputTokens: 4000,
600
- topP: 0.7,
601
- topK: 5,
602
- resendFiles: true,
677
+ temperature: anthropicSettings.temperature.default,
678
+ maxOutputTokens: anthropicSettings.maxOutputTokens.default,
679
+ topP: anthropicSettings.topP.default,
680
+ topK: anthropicSettings.topK.default,
681
+ resendFiles: anthropicSettings.resendFiles.default,
603
682
  iconURL: undefined,
604
683
  greeting: undefined,
605
684
  spec: undefined,
606
- maxContextTokens: undefined,
685
+ maxContextTokens: anthropicSettings.maxContextTokens.default,
607
686
  }));
608
687
 
609
688
  export const chatGPTBrowserSchema = tConversationSchema
@@ -835,19 +914,19 @@ export const compactAnthropicSchema = tConversationSchema
835
914
  })
836
915
  .transform((obj) => {
837
916
  const newObj: Partial<TConversation> = { ...obj };
838
- if (newObj.temperature === 1) {
917
+ if (newObj.temperature === anthropicSettings.temperature.default) {
839
918
  delete newObj.temperature;
840
919
  }
841
- if (newObj.maxOutputTokens === 4000) {
920
+ if (newObj.maxOutputTokens === anthropicSettings.legacy.maxOutputTokens.default) {
842
921
  delete newObj.maxOutputTokens;
843
922
  }
844
- if (newObj.topP === 0.7) {
923
+ if (newObj.topP === anthropicSettings.topP.default) {
845
924
  delete newObj.topP;
846
925
  }
847
- if (newObj.topK === 5) {
926
+ if (newObj.topK === anthropicSettings.topK.default) {
848
927
  delete newObj.topK;
849
928
  }
850
- if (newObj.resendFiles === true) {
929
+ if (newObj.resendFiles === anthropicSettings.resendFiles.default) {
851
930
  delete newObj.resendFiles;
852
931
  }
853
932
 
@@ -173,3 +173,9 @@ export type UpdatePromptPermOptions = MutationOptions<
173
173
  unknown,
174
174
  types.TError
175
175
  >;
176
+
177
+ export type UpdateConversationTagOptions = MutationOptions<
178
+ types.TConversationTag,
179
+ types.TConversationTagRequest
180
+ >;
181
+ export type DeleteConversationTagOptions = MutationOptions<types.TConversationTag, string>;
@@ -1,6 +1,7 @@
1
1
  import type { InfiniteData } from '@tanstack/react-query';
2
- import type { TMessage, TConversation, TSharedLink } from '../schemas';
3
2
  import type * as t from '../types';
3
+ import type { TMessage, TConversation, TSharedLink, TConversationTag } from '../schemas';
4
+
4
5
  export type Conversation = {
5
6
  id: string;
6
7
  createdAt: number;
@@ -18,6 +19,7 @@ export type ConversationListParams = {
18
19
  pageNumber: string; // Add this line
19
20
  conversationId?: string;
20
21
  isArchived?: boolean;
22
+ tags?: string[];
21
23
  };
22
24
 
23
25
  // Type for the response from the conversation list API
@@ -68,3 +70,5 @@ export type AllPromptGroupsFilterRequest = {
68
70
  };
69
71
 
70
72
  export type AllPromptGroupsResponse = t.TPromptGroup[];
73
+
74
+ export type ConversationTagsResponse = TConversationTag[];
package/src/types.ts CHANGED
@@ -7,6 +7,7 @@ import type {
7
7
  TSharedLink,
8
8
  TConversation,
9
9
  EModelEndpoint,
10
+ TConversationTag,
10
11
  } from './schemas';
11
12
  import type { TSpecsConfig } from './models';
12
13
  export type TOpenAIMessage = OpenAI.Chat.ChatCompletionMessageParam;
@@ -170,6 +171,24 @@ export type TSharedLinkResponse = TSharedLink;
170
171
  export type TSharedLinksResponse = TSharedLink[];
171
172
  export type TDeleteSharedLinkResponse = TSharedLink;
172
173
 
174
+ // type for getting conversation tags
175
+ export type TConversationTagsResponse = TConversationTag[];
176
+ // type for creating conversation tag
177
+ export type TConversationTagRequest = Partial<
178
+ Omit<TConversationTag, 'createdAt' | 'updatedAt' | 'count' | 'user'>
179
+ > & {
180
+ conversationId?: string;
181
+ addToConversation?: boolean;
182
+ };
183
+
184
+ export type TConversationTagResponse = TConversationTag;
185
+
186
+ // type for tagging conversation
187
+ export type TTagConversationRequest = {
188
+ tags: string[];
189
+ };
190
+ export type TTagConversationResponse = string[];
191
+
173
192
  export type TForkConvoRequest = {
174
193
  messageId: string;
175
194
  conversationId: string;
@@ -294,7 +313,13 @@ export type TStartupConfig = {
294
313
  openidLoginEnabled: boolean;
295
314
  openidLabel: string;
296
315
  openidImageUrl: string;
297
- ldapLoginEnabled: boolean;
316
+ /** LDAP Auth Configuration */
317
+ ldap?: {
318
+ /** LDAP enabled */
319
+ enabled: boolean;
320
+ /** Whether LDAP uses username vs. email */
321
+ username?: boolean;
322
+ };
298
323
  serverDomain: string;
299
324
  emailLoginEnabled: boolean;
300
325
  registrationEnabled: boolean;