librechat-data-provider 0.7.1 → 0.7.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.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "data services for librechat apps",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -128,14 +128,18 @@ export const images = () => `${files()}/images`;
128
128
 
129
129
  export const avatar = () => `${images()}/avatar`;
130
130
 
131
- export const speechToText = () => `${files()}/stt`;
131
+ export const speech = () => `${files()}/speech`;
132
132
 
133
- export const textToSpeech = () => `${files()}/tts`;
133
+ export const speechToText = () => `${speech()}/stt`;
134
+
135
+ export const textToSpeech = () => `${speech()}/tts`;
134
136
 
135
137
  export const textToSpeechManual = () => `${textToSpeech()}/manual`;
136
138
 
137
139
  export const textToSpeechVoices = () => `${textToSpeech()}/voices`;
138
140
 
141
+ export const getCustomConfigSpeech = () => `${speech()}/config/get`;
142
+
139
143
  export const getPromptGroup = (_id: string) => `${prompts()}/groups/${_id}`;
140
144
 
141
145
  export const getPromptGroupsWithFilters = (filter: object) => {
@@ -177,6 +181,8 @@ export const deletePrompt = ({ _id, groupId }: { _id: string; groupId: string })
177
181
 
178
182
  export const getCategories = () => '/api/categories';
179
183
 
184
+ export const getAllPromptGroups = () => `${prompts()}/all`;
185
+
180
186
  /* Roles */
181
187
  export const roles = () => '/api/roles';
182
188
  export const getRole = (roleName: string) => `${roles()}/${roleName.toLowerCase()}`;
package/src/config.ts CHANGED
@@ -136,71 +136,81 @@ export const defaultAssistantsVersion = {
136
136
  [EModelEndpoint.azureAssistants]: 1,
137
137
  };
138
138
 
139
- export const assistantEndpointSchema = z.object({
140
- /* assistants specific */
141
- disableBuilder: z.boolean().optional(),
142
- pollIntervalMs: z.number().optional(),
143
- timeoutMs: z.number().optional(),
144
- version: z.union([z.string(), z.number()]).default(2),
145
- supportedIds: z.array(z.string()).min(1).optional(),
146
- excludedIds: z.array(z.string()).min(1).optional(),
147
- privateAssistants: z.boolean().optional(),
148
- retrievalModels: z.array(z.string()).min(1).optional().default(defaultRetrievalModels),
149
- capabilities: z
150
- .array(z.nativeEnum(Capabilities))
151
- .optional()
152
- .default([
153
- Capabilities.code_interpreter,
154
- Capabilities.image_vision,
155
- Capabilities.retrieval,
156
- Capabilities.actions,
157
- Capabilities.tools,
158
- ]),
159
- /* general */
160
- apiKey: z.string().optional(),
161
- baseURL: z.string().optional(),
162
- models: z
163
- .object({
164
- default: z.array(z.string()).min(1),
165
- fetch: z.boolean().optional(),
166
- userIdQuery: z.boolean().optional(),
167
- })
168
- .optional(),
169
- titleConvo: z.boolean().optional(),
170
- titleMethod: z.union([z.literal('completion'), z.literal('functions')]).optional(),
171
- titleModel: z.string().optional(),
172
- headers: z.record(z.any()).optional(),
139
+ export const baseEndpointSchema = z.object({
140
+ streamRate: z.number().optional(),
173
141
  });
174
142
 
143
+ export type TBaseEndpoint = z.infer<typeof baseEndpointSchema>;
144
+
145
+ export const assistantEndpointSchema = baseEndpointSchema.merge(
146
+ z.object({
147
+ /* assistants specific */
148
+ disableBuilder: z.boolean().optional(),
149
+ pollIntervalMs: z.number().optional(),
150
+ timeoutMs: z.number().optional(),
151
+ version: z.union([z.string(), z.number()]).default(2),
152
+ supportedIds: z.array(z.string()).min(1).optional(),
153
+ excludedIds: z.array(z.string()).min(1).optional(),
154
+ privateAssistants: z.boolean().optional(),
155
+ retrievalModels: z.array(z.string()).min(1).optional().default(defaultRetrievalModels),
156
+ capabilities: z
157
+ .array(z.nativeEnum(Capabilities))
158
+ .optional()
159
+ .default([
160
+ Capabilities.code_interpreter,
161
+ Capabilities.image_vision,
162
+ Capabilities.retrieval,
163
+ Capabilities.actions,
164
+ Capabilities.tools,
165
+ ]),
166
+ /* general */
167
+ apiKey: z.string().optional(),
168
+ baseURL: z.string().optional(),
169
+ models: z
170
+ .object({
171
+ default: z.array(z.string()).min(1),
172
+ fetch: z.boolean().optional(),
173
+ userIdQuery: z.boolean().optional(),
174
+ })
175
+ .optional(),
176
+ titleConvo: z.boolean().optional(),
177
+ titleMethod: z.union([z.literal('completion'), z.literal('functions')]).optional(),
178
+ titleModel: z.string().optional(),
179
+ headers: z.record(z.any()).optional(),
180
+ }),
181
+ );
182
+
175
183
  export type TAssistantEndpoint = z.infer<typeof assistantEndpointSchema>;
176
184
 
177
- export const endpointSchema = z.object({
178
- name: z.string().refine((value) => !eModelEndpointSchema.safeParse(value).success, {
179
- message: `Value cannot be one of the default endpoint (EModelEndpoint) values: ${Object.values(
180
- EModelEndpoint,
181
- ).join(', ')}`,
182
- }),
183
- apiKey: z.string(),
184
- baseURL: z.string(),
185
- models: z.object({
186
- default: z.array(z.string()).min(1),
187
- fetch: z.boolean().optional(),
188
- userIdQuery: z.boolean().optional(),
185
+ export const endpointSchema = baseEndpointSchema.merge(
186
+ z.object({
187
+ name: z.string().refine((value) => !eModelEndpointSchema.safeParse(value).success, {
188
+ message: `Value cannot be one of the default endpoint (EModelEndpoint) values: ${Object.values(
189
+ EModelEndpoint,
190
+ ).join(', ')}`,
191
+ }),
192
+ apiKey: z.string(),
193
+ baseURL: z.string(),
194
+ models: z.object({
195
+ default: z.array(z.string()).min(1),
196
+ fetch: z.boolean().optional(),
197
+ userIdQuery: z.boolean().optional(),
198
+ }),
199
+ titleConvo: z.boolean().optional(),
200
+ titleMethod: z.union([z.literal('completion'), z.literal('functions')]).optional(),
201
+ titleModel: z.string().optional(),
202
+ summarize: z.boolean().optional(),
203
+ summaryModel: z.string().optional(),
204
+ forcePrompt: z.boolean().optional(),
205
+ modelDisplayLabel: z.string().optional(),
206
+ headers: z.record(z.any()).optional(),
207
+ addParams: z.record(z.any()).optional(),
208
+ dropParams: z.array(z.string()).optional(),
209
+ customOrder: z.number().optional(),
210
+ directEndpoint: z.boolean().optional(),
211
+ titleMessageRole: z.string().optional(),
189
212
  }),
190
- titleConvo: z.boolean().optional(),
191
- titleMethod: z.union([z.literal('completion'), z.literal('functions')]).optional(),
192
- titleModel: z.string().optional(),
193
- summarize: z.boolean().optional(),
194
- summaryModel: z.string().optional(),
195
- forcePrompt: z.boolean().optional(),
196
- modelDisplayLabel: z.string().optional(),
197
- headers: z.record(z.any()).optional(),
198
- addParams: z.record(z.any()).optional(),
199
- dropParams: z.array(z.string()).optional(),
200
- customOrder: z.number().optional(),
201
- directEndpoint: z.boolean().optional(),
202
- titleMessageRole: z.string().optional(),
203
- });
213
+ );
204
214
 
205
215
  export type TEndpoint = z.infer<typeof endpointSchema>;
206
216
 
@@ -213,6 +223,7 @@ export const azureEndpointSchema = z
213
223
  .and(
214
224
  endpointSchema
215
225
  .pick({
226
+ streamRate: true,
216
227
  titleConvo: true,
217
228
  titleMethod: true,
218
229
  titleModel: true,
@@ -233,6 +244,15 @@ const ttsOpenaiSchema = z.object({
233
244
  voices: z.array(z.string()),
234
245
  });
235
246
 
247
+ const ttsAzureOpenAISchema = z.object({
248
+ instanceName: z.string(),
249
+ apiKey: z.string(),
250
+ deploymentName: z.string(),
251
+ apiVersion: z.string(),
252
+ model: z.string(),
253
+ voices: z.array(z.string()),
254
+ });
255
+
236
256
  const ttsElevenLabsSchema = z.object({
237
257
  url: z.string().optional(),
238
258
  websocketUrl: z.string().optional(),
@@ -259,20 +279,63 @@ const ttsLocalaiSchema = z.object({
259
279
 
260
280
  const ttsSchema = z.object({
261
281
  openai: ttsOpenaiSchema.optional(),
282
+ azureOpenAI: ttsAzureOpenAISchema.optional(),
262
283
  elevenLabs: ttsElevenLabsSchema.optional(),
263
284
  localai: ttsLocalaiSchema.optional(),
264
285
  });
265
286
 
287
+ const sttOpenaiSchema = z.object({
288
+ url: z.string().optional(),
289
+ apiKey: z.string(),
290
+ model: z.string(),
291
+ });
292
+
293
+ const sttAzureOpenAISchema = z.object({
294
+ instanceName: z.string(),
295
+ apiKey: z.string(),
296
+ deploymentName: z.string(),
297
+ apiVersion: z.string(),
298
+ });
299
+
266
300
  const sttSchema = z.object({
267
- openai: z
268
- .object({
269
- url: z.string().optional(),
270
- apiKey: z.string().optional(),
271
- model: z.string().optional(),
272
- })
273
- .optional(),
301
+ openai: sttOpenaiSchema.optional(),
302
+ azureOpenAI: sttAzureOpenAISchema.optional(),
274
303
  });
275
304
 
305
+ const speechTab = z
306
+ .object({
307
+ conversationMode: z.boolean().optional(),
308
+ advancedMode: z.boolean().optional(),
309
+ speechToText: z
310
+ .boolean()
311
+ .optional()
312
+ .or(
313
+ z.object({
314
+ engineSTT: z.string().optional(),
315
+ languageSTT: z.string().optional(),
316
+ autoTranscribeAudio: z.boolean().optional(),
317
+ decibelValue: z.number().optional(),
318
+ autoSendText: z.number().optional(),
319
+ }),
320
+ )
321
+ .optional(),
322
+ textToSpeech: z
323
+ .boolean()
324
+ .optional()
325
+ .or(
326
+ z.object({
327
+ engineTTS: z.string().optional(),
328
+ voice: z.string().optional(),
329
+ languageTTS: z.string().optional(),
330
+ automaticPlayback: z.boolean().optional(),
331
+ playbackRate: z.number().optional(),
332
+ cacheTTS: z.boolean().optional(),
333
+ }),
334
+ )
335
+ .optional(),
336
+ })
337
+ .optional();
338
+
276
339
  export enum RateLimitPrefix {
277
340
  FILE_UPLOAD = 'FILE_UPLOAD',
278
341
  IMPORT = 'IMPORT',
@@ -362,17 +425,27 @@ export const configSchema = z.object({
362
425
  allowedDomains: z.array(z.string()).optional(),
363
426
  })
364
427
  .default({ socialLogins: defaultSocialLogins }),
365
- tts: ttsSchema.optional(),
366
- stt: sttSchema.optional(),
428
+ speech: z
429
+ .object({
430
+ tts: ttsSchema.optional(),
431
+ stt: sttSchema.optional(),
432
+ speechTab: speechTab.optional(),
433
+ })
434
+ .optional(),
367
435
  rateLimits: rateLimitSchema.optional(),
368
436
  fileConfig: fileConfigSchema.optional(),
369
437
  modelSpecs: specsConfigSchema.optional(),
370
438
  endpoints: z
371
439
  .object({
440
+ all: baseEndpointSchema.optional(),
441
+ [EModelEndpoint.openAI]: baseEndpointSchema.optional(),
442
+ [EModelEndpoint.google]: baseEndpointSchema.optional(),
443
+ [EModelEndpoint.anthropic]: baseEndpointSchema.optional(),
444
+ [EModelEndpoint.gptPlugins]: baseEndpointSchema.optional(),
372
445
  [EModelEndpoint.azureOpenAI]: azureEndpointSchema.optional(),
373
446
  [EModelEndpoint.azureAssistants]: assistantEndpointSchema.optional(),
374
447
  [EModelEndpoint.assistants]: assistantEndpointSchema.optional(),
375
- custom: z.array(endpointSchema.partial()).optional(),
448
+ [EModelEndpoint.custom]: z.array(endpointSchema.partial()).optional(),
376
449
  })
377
450
  .strict()
378
451
  .refine((data) => Object.keys(data).length > 0, {
@@ -600,6 +673,16 @@ export enum InfiniteCollections {
600
673
  SHARED_LINKS = 'sharedLinks',
601
674
  }
602
675
 
676
+ /**
677
+ * Enum for time intervals
678
+ */
679
+ export enum Time {
680
+ THIRTY_MINUTES = 1800000,
681
+ TEN_MINUTES = 600000,
682
+ FIVE_MINUTES = 300000,
683
+ TWO_MINUTES = 120000,
684
+ }
685
+
603
686
  /**
604
687
  * Enum for cache keys.
605
688
  */
@@ -670,6 +753,10 @@ export enum CacheKeys {
670
753
  * Key for the cached audio run Ids.
671
754
  */
672
755
  AUDIO_RUNS = 'audioRuns',
756
+ /**
757
+ * Key for in-progress messages.
758
+ */
759
+ MESSAGES = 'messages',
673
760
  }
674
761
 
675
762
  /**
@@ -785,9 +872,9 @@ export enum SettingsTabValues {
785
872
  */
786
873
  GENERAL = 'general',
787
874
  /**
788
- * Tab for Messages Settings
875
+ * Tab for Chat Settings
789
876
  */
790
- MESSAGES = 'messages',
877
+ CHAT = 'chat',
791
878
  /**
792
879
  * Tab for Speech Settings
793
880
  */
@@ -806,12 +893,42 @@ export enum SettingsTabValues {
806
893
  ACCOUNT = 'account',
807
894
  }
808
895
 
896
+ export enum STTProviders {
897
+ /**
898
+ * Provider for OpenAI STT
899
+ */
900
+ OPENAI = 'openai',
901
+ /**
902
+ * Provider for Microsoft Azure STT
903
+ */
904
+ AZURE_OPENAI = 'azureOpenAI',
905
+ }
906
+
907
+ export enum TTSProviders {
908
+ /**
909
+ * Provider for OpenAI TTS
910
+ */
911
+ OPENAI = 'openai',
912
+ /**
913
+ * Provider for Microsoft Azure OpenAI TTS
914
+ */
915
+ AZURE_OPENAI = 'azureOpenAI',
916
+ /**
917
+ * Provider for ElevenLabs TTS
918
+ */
919
+ ELEVENLABS = 'elevenlabs',
920
+ /**
921
+ * Provider for LocalAI TTS
922
+ */
923
+ LOCALAI = 'localai',
924
+ }
925
+
809
926
  /** Enum for app-wide constants */
810
927
  export enum Constants {
811
928
  /** Key for the app's version. */
812
929
  VERSION = 'v0.7.4-rc1',
813
930
  /** Key for the Custom Config's version (librechat.yaml). */
814
- CONFIG_VERSION = '1.1.4',
931
+ CONFIG_VERSION = '1.1.5',
815
932
  /** Standard value for the first message's `parentMessageId` value, to indicate no parent exists. */
816
933
  NO_PARENT = '00000000-0000-0000-0000-000000000000',
817
934
  /** Standard value for the initial conversationId before a request is sent */
@@ -822,6 +939,10 @@ export enum Constants {
822
939
  CURRENT_MODEL = 'current_model',
823
940
  /** Common divider for text values */
824
941
  COMMON_DIVIDER = '__',
942
+ /** Max length for commands */
943
+ COMMANDS_MAX_LENGTH = 56,
944
+ /** Default Stream Rate (ms) */
945
+ DEFAULT_STREAM_RATE = 1,
825
946
  }
826
947
 
827
948
  export enum LocalStorageKeys {
@@ -355,6 +355,10 @@ export const getVoices = (): Promise<f.VoiceResponse> => {
355
355
  return request.get(endpoints.textToSpeechVoices());
356
356
  };
357
357
 
358
+ export const getCustomConfigSpeech = (): Promise<t.TCustomConfigSpeechResponse> => {
359
+ return request.get(endpoints.getCustomConfigSpeech());
360
+ };
361
+
358
362
  /* actions */
359
363
 
360
364
  export const updateAction = (data: m.UpdateActionVariables): Promise<m.UpdateActionResponse> => {
@@ -475,6 +479,10 @@ export function getPrompts(filter: t.TPromptsWithFilterRequest): Promise<t.TProm
475
479
  return request.get(endpoints.getPromptsWithFilters(filter));
476
480
  }
477
481
 
482
+ export function getAllPromptGroups(): Promise<q.AllPromptGroupsResponse> {
483
+ return request.get(endpoints.getAllPromptGroups());
484
+ }
485
+
478
486
  export function getPromptGroups(
479
487
  filter: t.TPromptGroupsWithFilterRequest,
480
488
  ): Promise<t.PromptGroupListResponse> {
package/src/keys.ts CHANGED
@@ -27,9 +27,11 @@ export enum QueryKeys {
27
27
  assistantDocs = 'assistantDocs',
28
28
  fileDownload = 'fileDownload',
29
29
  voices = 'voices',
30
+ customConfigSpeech = 'customConfigSpeech',
30
31
  prompts = 'prompts',
31
32
  prompt = 'prompt',
32
33
  promptGroups = 'promptGroups',
34
+ allPromptGroups = 'allPromptGroups',
33
35
  promptGroup = 'promptGroup',
34
36
  categories = 'categories',
35
37
  randomPrompts = 'randomPrompts',
@@ -422,3 +422,18 @@ export const useGetStartupConfig = (
422
422
  },
423
423
  );
424
424
  };
425
+
426
+ export const useGetCustomConfigSpeechQuery = (
427
+ config?: UseQueryOptions<t.TCustomConfigSpeechResponse>,
428
+ ): QueryObserverResult<t.TCustomConfigSpeechResponse> => {
429
+ return useQuery<t.TCustomConfigSpeechResponse>(
430
+ [QueryKeys.customConfigSpeech],
431
+ () => dataService.getCustomConfigSpeech(),
432
+ {
433
+ refetchOnWindowFocus: false,
434
+ refetchOnReconnect: false,
435
+ refetchOnMount: false,
436
+ ...config,
437
+ },
438
+ );
439
+ };
@@ -1,5 +1,6 @@
1
1
  import type { InfiniteData } from '@tanstack/react-query';
2
2
  import type { TMessage, TConversation, TSharedLink } from '../schemas';
3
+ import type * as t from '../types';
3
4
  export type Conversation = {
4
5
  id: string;
5
6
  createdAt: number;
@@ -54,3 +55,16 @@ export type SharedLinkListResponse = {
54
55
  };
55
56
 
56
57
  export type SharedLinkListData = InfiniteData<SharedLinkListResponse>;
58
+
59
+ export type AllPromptGroupsFilterRequest = {
60
+ category: string;
61
+ pageNumber: string;
62
+ pageSize: string | number;
63
+ before?: string | null;
64
+ after?: string | null;
65
+ order?: 'asc' | 'desc';
66
+ name?: string;
67
+ author?: string;
68
+ };
69
+
70
+ export type AllPromptGroupsResponse = t.TPromptGroup[];
package/src/types.ts CHANGED
@@ -351,6 +351,7 @@ export type TPrompt = {
351
351
  export type TPromptGroup = {
352
352
  name: string;
353
353
  numberOfGenerations?: number;
354
+ command?: string;
354
355
  oneliner?: string;
355
356
  category?: string;
356
357
  projectIds?: string[];
@@ -365,7 +366,7 @@ export type TPromptGroup = {
365
366
 
366
367
  export type TCreatePrompt = {
367
368
  prompt: Pick<TPrompt, 'prompt' | 'type'> & { groupId?: string };
368
- group?: { name: string; category?: string; oneliner?: string };
369
+ group?: { name: string; category?: string; oneliner?: string; command?: string };
369
370
  };
370
371
 
371
372
  export type TCreatePromptRecord = TCreatePrompt & Pick<TPromptGroup, 'author' | 'authorName'>;
@@ -385,6 +386,7 @@ export type TPromptGroupsWithFilterRequest = {
385
386
  after?: string | null;
386
387
  order?: 'asc' | 'desc';
387
388
  name?: string;
389
+ author?: string;
388
390
  };
389
391
 
390
392
  export type PromptGroupListResponse = {
@@ -461,3 +463,5 @@ export type TGetRandomPromptsRequest = {
461
463
  limit: number;
462
464
  skip: number;
463
465
  };
466
+
467
+ export type TCustomConfigSpeechResponse = { [key: string]: string };