librechat-data-provider 0.7.69 → 0.7.72

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.
@@ -41,27 +41,29 @@ export function getSharedMessages(shareId: string): Promise<t.TSharedMessagesRes
41
41
  return request.get(endpoints.shareMessages(shareId));
42
42
  }
43
43
 
44
- export const listSharedLinks = (
45
- params?: q.SharedLinkListParams,
44
+ export const listSharedLinks = async (
45
+ params: q.SharedLinksListParams,
46
46
  ): Promise<q.SharedLinksResponse> => {
47
- const pageNumber = (params?.pageNumber ?? '1') || '1'; // Default to page 1 if not provided
48
- const isPublic = params?.isPublic ?? true; // Default to true if not provided
49
- return request.get(endpoints.getSharedLinks(pageNumber, isPublic));
47
+ const { pageSize, isPublic, sortBy, sortDirection, search, cursor } = params;
48
+
49
+ return request.get(
50
+ endpoints.getSharedLinks(pageSize, isPublic, sortBy, sortDirection, search, cursor),
51
+ );
50
52
  };
51
53
 
52
- export function getSharedLink(shareId: string): Promise<t.TSharedLinkResponse> {
53
- return request.get(endpoints.shareMessages(shareId));
54
+ export function getSharedLink(conversationId: string): Promise<t.TSharedLinkGetResponse> {
55
+ return request.get(endpoints.getSharedLink(conversationId));
54
56
  }
55
57
 
56
- export function createSharedLink(payload: t.TSharedLinkRequest): Promise<t.TSharedLinkResponse> {
57
- return request.post(endpoints.createSharedLink, payload);
58
+ export function createSharedLink(conversationId: string): Promise<t.TSharedLinkResponse> {
59
+ return request.post(endpoints.createSharedLink(conversationId));
58
60
  }
59
61
 
60
- export function updateSharedLink(payload: t.TSharedLinkRequest): Promise<t.TSharedLinkResponse> {
61
- return request.patch(endpoints.updateSharedLink, payload);
62
+ export function updateSharedLink(shareId: string): Promise<t.TSharedLinkResponse> {
63
+ return request.patch(endpoints.updateSharedLink(shareId));
62
64
  }
63
65
 
64
- export function deleteSharedLink(shareId: string): Promise<t.TDeleteSharedLinkResponse> {
66
+ export function deleteSharedLink(shareId: string): Promise<m.TDeleteSharedLinkResponse> {
65
67
  return request.delete(endpoints.shareMessages(shareId));
66
68
  }
67
69
 
@@ -74,6 +76,13 @@ export function updateMessage(payload: t.TUpdateMessageRequest): Promise<unknown
74
76
  return request.put(endpoints.messages(conversationId, messageId), { text });
75
77
  }
76
78
 
79
+ export const editArtifact = async ({
80
+ messageId,
81
+ ...params
82
+ }: m.TEditArtifactRequest): Promise<m.TEditArtifactResponse> => {
83
+ return request.post(`/api/messages/artifact/${messageId}`, params);
84
+ };
85
+
77
86
  export function updateMessageContent(payload: t.TUpdateMessageContent): Promise<unknown> {
78
87
  const { conversationId, messageId, index, text } = payload;
79
88
  if (!conversationId) {
@@ -124,11 +133,11 @@ export const updateTokenCount = (text: string) => {
124
133
  return request.post(endpoints.tokenizer(), { arg: text });
125
134
  };
126
135
 
127
- export const login = (payload: t.TLoginUser) => {
136
+ export const login = (payload: t.TLoginUser): Promise<t.TLoginResponse> => {
128
137
  return request.post(endpoints.login(), payload);
129
138
  };
130
139
 
131
- export const logout = () => {
140
+ export const logout = (): Promise<m.TLogoutResponse> => {
132
141
  return request.post(endpoints.logout());
133
142
  };
134
143
 
@@ -173,7 +182,7 @@ export const updateUserPlugins = (payload: t.TUpdateUserPlugins) => {
173
182
 
174
183
  /* Config */
175
184
 
176
- export const getStartupConfig = (): Promise<t.TStartupConfig> => {
185
+ export const getStartupConfig = (): Promise<config.TStartupConfig> => {
177
186
  return request.get(endpoints.config());
178
187
  };
179
188
 
@@ -765,3 +774,33 @@ export function acceptTerms(): Promise<t.TAcceptTermsResponse> {
765
774
  export function getBanner(): Promise<t.TBannerResponse> {
766
775
  return request.get(endpoints.banner());
767
776
  }
777
+
778
+ export function enableTwoFactor(): Promise<t.TEnable2FAResponse> {
779
+ return request.get(endpoints.enableTwoFactor());
780
+ }
781
+
782
+ export function verifyTwoFactor(
783
+ payload: t.TVerify2FARequest,
784
+ ): Promise<t.TVerify2FAResponse> {
785
+ return request.post(endpoints.verifyTwoFactor(), payload);
786
+ }
787
+
788
+ export function confirmTwoFactor(
789
+ payload: t.TVerify2FARequest,
790
+ ): Promise<t.TVerify2FAResponse> {
791
+ return request.post(endpoints.confirmTwoFactor(), payload);
792
+ }
793
+
794
+ export function disableTwoFactor(): Promise<t.TDisable2FAResponse> {
795
+ return request.post(endpoints.disableTwoFactor());
796
+ }
797
+
798
+ export function regenerateBackupCodes(): Promise<t.TRegenerateBackupCodesResponse> {
799
+ return request.post(endpoints.regenerateBackupCodes());
800
+ }
801
+
802
+ export function verifyTwoFactorTemp(
803
+ payload: t.TVerify2FATempRequest,
804
+ ): Promise<t.TVerify2FATempResponse> {
805
+ return request.post(endpoints.verifyTwoFactorTemp(), payload);
806
+ }
@@ -54,6 +54,8 @@ export const fullMimeTypesList = [
54
54
  'application/typescript',
55
55
  'application/xml',
56
56
  'application/zip',
57
+ 'image/svg',
58
+ 'image/svg+xml',
57
59
  ...excelFileTypes,
58
60
  ];
59
61
 
@@ -122,6 +124,8 @@ export const supportedMimeTypes = [
122
124
  excelMimeTypes,
123
125
  applicationMimeTypes,
124
126
  imageMimeTypes,
127
+ /** Supported by LC Code Interpreter PAI */
128
+ /^image\/(svg|svg\+xml)$/,
125
129
  ];
126
130
 
127
131
  export const codeInterpreterMimeTypes = [
@@ -145,6 +149,9 @@ export const codeTypeMapping: { [key: string]: string } = {
145
149
  ts: 'application/typescript',
146
150
  tar: 'application/x-tar',
147
151
  zip: 'application/zip',
152
+ yml: 'application/x-yaml',
153
+ yaml: 'application/x-yaml',
154
+ log: 'text/plain',
148
155
  };
149
156
 
150
157
  export const retrievalMimeTypes = [
package/src/generate.ts CHANGED
@@ -414,7 +414,7 @@ export function validateSettingDefinitions(settings: SettingsConfiguration): voi
414
414
 
415
415
  // Default columnSpan
416
416
  if (!setting.columnSpan) {
417
- setting.columnSpan = Math.floor(columns / 2);
417
+ setting.columnSpan = Math.floor((columns ?? 0) / 2);
418
418
  }
419
419
 
420
420
  // Default label to key
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ export * from './file-config';
7
7
  export * from './artifacts';
8
8
  /* schema helpers */
9
9
  export * from './parsers';
10
+ export * from './ocr';
10
11
  export * from './zod';
11
12
  /* custom/dynamic configurations */
12
13
  export * from './generate';
@@ -31,5 +32,6 @@ export { default as request } from './request';
31
32
  export { dataService };
32
33
  import * as dataService from './data-service';
33
34
  /* general helpers */
35
+ export * from './utils';
34
36
  export * from './actions';
35
37
  export { default as createPayload } from './createPayload';
package/src/keys.ts CHANGED
@@ -53,7 +53,9 @@ export enum MutationKeys {
53
53
  fileDelete = 'fileDelete',
54
54
  updatePreset = 'updatePreset',
55
55
  deletePreset = 'deletePreset',
56
+ loginUser = 'loginUser',
56
57
  logoutUser = 'logoutUser',
58
+ refreshToken = 'refreshToken',
57
59
  avatarUpload = 'avatarUpload',
58
60
  speechToText = 'speechToText',
59
61
  textToSpeech = 'textToSpeech',
@@ -65,4 +67,6 @@ export enum MutationKeys {
65
67
  deleteAgentAction = 'deleteAgentAction',
66
68
  deleteUser = 'deleteUser',
67
69
  updateRole = 'updateRole',
70
+ enableTwoFactor = 'enableTwoFactor',
71
+ verifyTwoFactor = 'verifyTwoFactor',
68
72
  }
package/src/mcp.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import { z } from 'zod';
2
+ import { extractEnvVariable } from './utils';
2
3
 
3
4
  const BaseOptionsSchema = z.object({
4
5
  iconPath: z.string().optional(),
6
+ timeout: z.number().optional(),
5
7
  });
6
8
 
7
9
  export const StdioOptionsSchema = BaseOptionsSchema.extend({
@@ -18,8 +20,22 @@ export const StdioOptionsSchema = BaseOptionsSchema.extend({
18
20
  * The environment to use when spawning the process.
19
21
  *
20
22
  * If not specified, the result of getDefaultEnvironment() will be used.
23
+ * Environment variables can be referenced using ${VAR_NAME} syntax.
21
24
  */
22
- env: z.record(z.string(), z.string()).optional(),
25
+ env: z
26
+ .record(z.string(), z.string())
27
+ .optional()
28
+ .transform((env) => {
29
+ if (!env) {
30
+ return env;
31
+ }
32
+
33
+ const processedEnv: Record<string, string> = {};
34
+ for (const [key, value] of Object.entries(env)) {
35
+ processedEnv[key] = extractEnvVariable(value);
36
+ }
37
+ return processedEnv;
38
+ }),
23
39
  /**
24
40
  * How to handle stderr of the child process. This matches the semantics of Node's `child_process.spawn`.
25
41
  *
package/src/models.ts CHANGED
@@ -37,7 +37,7 @@ export const tModelSpecSchema = z.object({
37
37
  export const specsConfigSchema = z.object({
38
38
  enforce: z.boolean().default(false),
39
39
  prioritize: z.boolean().default(true),
40
- list: z.array(tModelSpecSchema).optional(),
40
+ list: z.array(tModelSpecSchema).min(1),
41
41
  });
42
42
 
43
43
  export type TSpecsConfig = z.infer<typeof specsConfigSchema>;
package/src/ocr.ts ADDED
@@ -0,0 +1,14 @@
1
+ import type { TCustomConfig } from '../src/config';
2
+ import { OCRStrategy } from '../src/config';
3
+
4
+ export function loadOCRConfig(config: TCustomConfig['ocr']): TCustomConfig['ocr'] {
5
+ const baseURL = config?.baseURL ?? '';
6
+ const apiKey = config?.apiKey ?? '';
7
+ const mistralModel = config?.mistralModel ?? '';
8
+ return {
9
+ apiKey,
10
+ baseURL,
11
+ mistralModel,
12
+ strategy: config?.strategy ?? OCRStrategy.MISTRAL_OCR,
13
+ };
14
+ }
package/src/parsers.ts CHANGED
@@ -6,7 +6,6 @@ import { ContentTypes } from './types/runs';
6
6
  import {
7
7
  openAISchema,
8
8
  googleSchema,
9
- bingAISchema,
10
9
  EModelEndpoint,
11
10
  anthropicSchema,
12
11
  assistantSchema,
@@ -20,12 +19,12 @@ import {
20
19
  compactAssistantSchema,
21
20
  } from './schemas';
22
21
  import { bedrockInputSchema } from './bedrock';
22
+ import { extractEnvVariable } from './utils';
23
23
  import { alternateName } from './config';
24
24
 
25
25
  type EndpointSchema =
26
26
  | typeof openAISchema
27
27
  | typeof googleSchema
28
- | typeof bingAISchema
29
28
  | typeof anthropicSchema
30
29
  | typeof chatGPTBrowserSchema
31
30
  | typeof gptPluginsSchema
@@ -38,7 +37,6 @@ const endpointSchemas: Record<EModelEndpoint, EndpointSchema> = {
38
37
  [EModelEndpoint.azureOpenAI]: openAISchema,
39
38
  [EModelEndpoint.custom]: openAISchema,
40
39
  [EModelEndpoint.google]: googleSchema,
41
- [EModelEndpoint.bingAI]: bingAISchema,
42
40
  [EModelEndpoint.anthropic]: anthropicSchema,
43
41
  [EModelEndpoint.chatGPTBrowser]: chatGPTBrowserSchema,
44
42
  [EModelEndpoint.gptPlugins]: gptPluginsSchema,
@@ -61,7 +59,6 @@ export function getEnabledEndpoints() {
61
59
  EModelEndpoint.azureAssistants,
62
60
  EModelEndpoint.azureOpenAI,
63
61
  EModelEndpoint.google,
64
- EModelEndpoint.bingAI,
65
62
  EModelEndpoint.chatGPTBrowser,
66
63
  EModelEndpoint.gptPlugins,
67
64
  EModelEndpoint.anthropic,
@@ -126,18 +123,6 @@ export function errorsToString(errors: ZodIssue[]) {
126
123
  .join(' ');
127
124
  }
128
125
 
129
- export const envVarRegex = /^\${(.+)}$/;
130
-
131
- /** Extracts the value of an environment variable from a string. */
132
- export function extractEnvVariable(value: string) {
133
- const envVarMatch = value.match(envVarRegex);
134
- if (envVarMatch) {
135
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
136
- return process.env[envVarMatch[1]] || value;
137
- }
138
- return value;
139
- }
140
-
141
126
  /** Resolves header values to env variables if detected */
142
127
  export function resolveHeaders(headers: Record<string, string> | undefined) {
143
128
  const resolvedHeaders = { ...(headers ?? {}) };
@@ -183,7 +168,7 @@ export const parseConvo = ({
183
168
  possibleValues,
184
169
  }: {
185
170
  endpoint: EModelEndpoint;
186
- endpointType?: EModelEndpoint;
171
+ endpointType?: EModelEndpoint | null;
187
172
  conversation: Partial<s.TConversation | s.TPreset> | null;
188
173
  possibleValues?: TPossibleValues;
189
174
  // TODO: POC for default schema
@@ -215,6 +200,29 @@ export const parseConvo = ({
215
200
  return convo;
216
201
  };
217
202
 
203
+ /** Match GPT followed by digit, optional decimal, and optional suffix
204
+ *
205
+ * Examples: gpt-4, gpt-4o, gpt-4.5, gpt-5a, etc. */
206
+ const extractGPTVersion = (modelStr: string): string => {
207
+ const gptMatch = modelStr.match(/gpt-(\d+(?:\.\d+)?)([a-z])?/i);
208
+ if (gptMatch) {
209
+ const version = gptMatch[1];
210
+ const suffix = gptMatch[2] || '';
211
+ return `GPT-${version}${suffix}`;
212
+ }
213
+ return '';
214
+ };
215
+
216
+ /** Match omni models (o1, o3, etc.), "o" followed by a digit, possibly with decimal */
217
+ const extractOmniVersion = (modelStr: string): string => {
218
+ const omniMatch = modelStr.match(/\bo(\d+(?:\.\d+)?)\b/i);
219
+ if (omniMatch) {
220
+ const version = omniMatch[1];
221
+ return `o${version}`;
222
+ }
223
+ return '';
224
+ };
225
+
218
226
  export const getResponseSender = (endpointOption: t.TEndpointOption): string => {
219
227
  const {
220
228
  model: _m,
@@ -223,7 +231,6 @@ export const getResponseSender = (endpointOption: t.TEndpointOption): string =>
223
231
  modelDisplayLabel: _mdl,
224
232
  chatGptLabel: _cgl,
225
233
  modelLabel: _ml,
226
- jailbreak,
227
234
  } = endpointOption;
228
235
 
229
236
  const model = _m ?? '';
@@ -243,24 +250,17 @@ export const getResponseSender = (endpointOption: t.TEndpointOption): string =>
243
250
  return chatGptLabel;
244
251
  } else if (modelLabel) {
245
252
  return modelLabel;
246
- } else if (model && /\bo1\b/i.test(model)) {
247
- return 'o1';
248
- } else if (model && model.includes('gpt-3')) {
249
- return 'GPT-3.5';
250
- } else if (model && model.includes('gpt-4o')) {
251
- return 'GPT-4o';
252
- } else if (model && model.includes('gpt-4')) {
253
- return 'GPT-4';
253
+ } else if (model && extractOmniVersion(model)) {
254
+ return extractOmniVersion(model);
254
255
  } else if (model && model.includes('mistral')) {
255
256
  return 'Mistral';
257
+ } else if (model && model.includes('gpt-')) {
258
+ const gptVersion = extractGPTVersion(model);
259
+ return gptVersion || 'GPT';
256
260
  }
257
261
  return (alternateName[endpoint] as string | undefined) ?? 'ChatGPT';
258
262
  }
259
263
 
260
- if (endpoint === EModelEndpoint.bingAI) {
261
- return jailbreak === true ? 'Sydney' : 'BingAI';
262
- }
263
-
264
264
  if (endpoint === EModelEndpoint.anthropic) {
265
265
  return modelLabel || 'Claude';
266
266
  }
@@ -272,7 +272,7 @@ export const getResponseSender = (endpointOption: t.TEndpointOption): string =>
272
272
  if (endpoint === EModelEndpoint.google) {
273
273
  if (modelLabel) {
274
274
  return modelLabel;
275
- } else if (model && model.includes('gemini')) {
275
+ } else if (model && (model.includes('gemini') || model.includes('learnlm'))) {
276
276
  return 'Gemini';
277
277
  } else if (model && model.includes('code')) {
278
278
  return 'Codey';
@@ -286,14 +286,13 @@ export const getResponseSender = (endpointOption: t.TEndpointOption): string =>
286
286
  return modelLabel;
287
287
  } else if (chatGptLabel) {
288
288
  return chatGptLabel;
289
+ } else if (model && extractOmniVersion(model)) {
290
+ return extractOmniVersion(model);
289
291
  } else if (model && model.includes('mistral')) {
290
292
  return 'Mistral';
291
- } else if (model && model.includes('gpt-3')) {
292
- return 'GPT-3.5';
293
- } else if (model && model.includes('gpt-4o')) {
294
- return 'GPT-4o';
295
- } else if (model && model.includes('gpt-4')) {
296
- return 'GPT-4';
293
+ } else if (model && model.includes('gpt-')) {
294
+ const gptVersion = extractGPTVersion(model);
295
+ return gptVersion || 'GPT';
297
296
  } else if (modelDisplayLabel) {
298
297
  return modelDisplayLabel;
299
298
  }
@@ -309,7 +308,6 @@ type CompactEndpointSchema =
309
308
  | typeof compactAssistantSchema
310
309
  | typeof compactAgentsSchema
311
310
  | typeof compactGoogleSchema
312
- | typeof bingAISchema
313
311
  | typeof anthropicSchema
314
312
  | typeof compactChatGPTSchema
315
313
  | typeof bedrockInputSchema
@@ -324,8 +322,6 @@ const compactEndpointSchemas: Record<string, CompactEndpointSchema> = {
324
322
  [EModelEndpoint.agents]: compactAgentsSchema,
325
323
  [EModelEndpoint.google]: compactGoogleSchema,
326
324
  [EModelEndpoint.bedrock]: bedrockInputSchema,
327
- /* BingAI needs all fields */
328
- [EModelEndpoint.bingAI]: bingAISchema,
329
325
  [EModelEndpoint.anthropic]: anthropicSchema,
330
326
  [EModelEndpoint.chatGPTBrowser]: compactChatGPTSchema,
331
327
  [EModelEndpoint.gptPlugins]: compactPluginsSchema,
@@ -338,7 +334,7 @@ export const parseCompactConvo = ({
338
334
  possibleValues,
339
335
  }: {
340
336
  endpoint?: EModelEndpoint;
341
- endpointType?: EModelEndpoint;
337
+ endpointType?: EModelEndpoint | null;
342
338
  conversation: Partial<s.TConversation | s.TPreset>;
343
339
  possibleValues?: TPossibleValues;
344
340
  // TODO: POC for default schema
@@ -348,7 +344,7 @@ export const parseCompactConvo = ({
348
344
  throw new Error(`undefined endpoint: ${endpoint}`);
349
345
  }
350
346
 
351
- let schema = compactEndpointSchemas[endpoint];
347
+ let schema = compactEndpointSchemas[endpoint] as CompactEndpointSchema | undefined;
352
348
 
353
349
  if (!schema && !endpointType) {
354
350
  throw new Error(`Unknown endpoint: ${endpoint}`);
@@ -356,7 +352,11 @@ export const parseCompactConvo = ({
356
352
  schema = compactEndpointSchemas[endpointType];
357
353
  }
358
354
 
359
- const convo = schema.parse(conversation) as s.TConversation;
355
+ if (!schema) {
356
+ throw new Error(`Unknown endpointType: ${endpointType}`);
357
+ }
358
+
359
+ const convo = schema.parse(conversation) as s.TConversation | null;
360
360
  // const { models, secondaryModels } = possibleValues ?? {};
361
361
  const { models } = possibleValues ?? {};
362
362
 
@@ -4,12 +4,11 @@ import type {
4
4
  UseMutationResult,
5
5
  QueryObserverResult,
6
6
  } from '@tanstack/react-query';
7
- import { initialModelsConfig, LocalStorageKeys } from '../config';
7
+ import { initialModelsConfig } from '../config';
8
8
  import { defaultOrderQuery } from '../types/assistants';
9
9
  import * as dataService from '../data-service';
10
10
  import * as m from '../types/mutations';
11
11
  import { QueryKeys } from '../keys';
12
- import request from '../request';
13
12
  import * as s from '../schemas';
14
13
  import * as t from '../types';
15
14
 
@@ -30,18 +29,6 @@ export const useAbortRequestWithMessage = (): UseMutationResult<
30
29
  );
31
30
  };
32
31
 
33
- export const useGetUserQuery = (
34
- config?: UseQueryOptions<t.TUser>,
35
- ): QueryObserverResult<t.TUser> => {
36
- return useQuery<t.TUser>([QueryKeys.user], () => dataService.getUser(), {
37
- refetchOnWindowFocus: false,
38
- refetchOnReconnect: false,
39
- refetchOnMount: false,
40
- retry: false,
41
- ...config,
42
- });
43
- };
44
-
45
32
  export const useGetMessagesByConvoId = <TData = s.TMessage[]>(
46
33
  id: string,
47
34
  config?: UseQueryOptions<s.TMessage[], unknown, TData>,
@@ -74,15 +61,27 @@ export const useGetSharedMessages = (
74
61
  );
75
62
  };
76
63
 
77
- export const useGetUserBalance = (
78
- config?: UseQueryOptions<string>,
79
- ): QueryObserverResult<string> => {
80
- return useQuery<string>([QueryKeys.balance], () => dataService.getUserBalance(), {
81
- refetchOnWindowFocus: true,
82
- refetchOnReconnect: true,
83
- refetchOnMount: true,
84
- ...config,
85
- });
64
+ export const useGetSharedLinkQuery = (
65
+ conversationId: string,
66
+ config?: UseQueryOptions<t.TSharedLinkGetResponse>,
67
+ ): QueryObserverResult<t.TSharedLinkGetResponse> => {
68
+ const queryClient = useQueryClient();
69
+ return useQuery<t.TSharedLinkGetResponse>(
70
+ [QueryKeys.sharedLinks, conversationId],
71
+ () => dataService.getSharedLink(conversationId),
72
+ {
73
+ refetchOnWindowFocus: false,
74
+ refetchOnReconnect: false,
75
+ refetchOnMount: false,
76
+ onSuccess: (data) => {
77
+ queryClient.setQueryData([QueryKeys.sharedLinks, conversationId], {
78
+ conversationId: data.conversationId,
79
+ shareId: data.shareId,
80
+ });
81
+ },
82
+ ...config,
83
+ },
84
+ );
86
85
  };
87
86
 
88
87
  export const useGetConversationByIdQuery = (
@@ -202,33 +201,6 @@ export const useRevokeAllUserKeysMutation = (): UseMutationResult<unknown> => {
202
201
  });
203
202
  };
204
203
 
205
- export const useGetSearchEnabledQuery = (
206
- config?: UseQueryOptions<boolean>,
207
- ): QueryObserverResult<boolean> => {
208
- return useQuery<boolean>([QueryKeys.searchEnabled], () => dataService.getSearchEnabled(), {
209
- refetchOnWindowFocus: false,
210
- refetchOnReconnect: false,
211
- refetchOnMount: false,
212
- ...config,
213
- });
214
- };
215
-
216
- export const useGetEndpointsQuery = <TData = t.TEndpointsConfig>(
217
- config?: UseQueryOptions<t.TEndpointsConfig, unknown, TData>,
218
- ): QueryObserverResult<TData> => {
219
- return useQuery<t.TEndpointsConfig, unknown, TData>(
220
- [QueryKeys.endpoints],
221
- () => dataService.getAIEndpoints(),
222
- {
223
- staleTime: Infinity,
224
- refetchOnWindowFocus: false,
225
- refetchOnReconnect: false,
226
- refetchOnMount: false,
227
- ...config,
228
- },
229
- );
230
- };
231
-
232
204
  export const useGetModelsQuery = (
233
205
  config?: UseQueryOptions<t.TModelsConfig>,
234
206
  ): QueryObserverResult<t.TModelsConfig> => {
@@ -301,54 +273,22 @@ export const useUpdateTokenCountMutation = (): UseMutationResult<
301
273
  });
302
274
  };
303
275
 
304
- export const useLoginUserMutation = (): UseMutationResult<
305
- t.TLoginResponse,
306
- unknown,
307
- t.TLoginUser,
308
- unknown
309
- > => {
310
- const queryClient = useQueryClient();
311
- return useMutation((payload: t.TLoginUser) => dataService.login(payload), {
312
- onMutate: () => {
313
- queryClient.removeQueries();
314
- localStorage.removeItem(LocalStorageKeys.LAST_CONVO_SETUP);
315
- localStorage.removeItem(`${LocalStorageKeys.LAST_CONVO_SETUP}_0`);
316
- localStorage.removeItem(`${LocalStorageKeys.LAST_CONVO_SETUP}_1`);
317
- localStorage.removeItem(LocalStorageKeys.LAST_MODEL);
318
- localStorage.removeItem(LocalStorageKeys.LAST_TOOLS);
319
- localStorage.removeItem(LocalStorageKeys.FILES_TO_DELETE);
320
- // localStorage.removeItem('lastAssistant');
321
- },
322
- });
323
- };
324
-
325
276
  export const useRegisterUserMutation = (
326
277
  options?: m.RegistrationOptions,
327
278
  ): UseMutationResult<t.TError, unknown, t.TRegisterUser, unknown> => {
328
279
  const queryClient = useQueryClient();
329
- return useMutation((payload: t.TRegisterUser) => dataService.register(payload), {
330
- ...options,
331
- onSuccess: (...args) => {
332
- queryClient.invalidateQueries([QueryKeys.user]);
333
- if (options?.onSuccess) {
334
- options.onSuccess(...args);
335
- }
336
- },
337
- });
338
- };
339
-
340
- export const useRefreshTokenMutation = (): UseMutationResult<
341
- t.TRefreshTokenResponse | undefined,
342
- unknown,
343
- unknown,
344
- unknown
345
- > => {
346
- const queryClient = useQueryClient();
347
- return useMutation(() => request.refreshToken(), {
348
- onMutate: () => {
349
- queryClient.removeQueries();
280
+ return useMutation<t.TRegisterUserResponse, t.TError, t.TRegisterUser>(
281
+ (payload: t.TRegisterUser) => dataService.register(payload),
282
+ {
283
+ ...options,
284
+ onSuccess: (...args) => {
285
+ queryClient.invalidateQueries([QueryKeys.user]);
286
+ if (options?.onSuccess) {
287
+ options.onSuccess(...args);
288
+ }
289
+ },
350
290
  },
351
- });
291
+ );
352
292
  };
353
293
 
354
294
  export const useUserKeyQuery = (
@@ -422,21 +362,6 @@ export const useUpdateUserPluginsMutation = (
422
362
  });
423
363
  };
424
364
 
425
- export const useGetStartupConfig = (
426
- config?: UseQueryOptions<t.TStartupConfig>,
427
- ): QueryObserverResult<t.TStartupConfig> => {
428
- return useQuery<t.TStartupConfig>(
429
- [QueryKeys.startupConfig],
430
- () => dataService.getStartupConfig(),
431
- {
432
- refetchOnWindowFocus: false,
433
- refetchOnReconnect: false,
434
- refetchOnMount: false,
435
- ...config,
436
- },
437
- );
438
- };
439
-
440
365
  export const useGetCustomConfigSpeechQuery = (
441
366
  config?: UseQueryOptions<t.TCustomConfigSpeechResponse>,
442
367
  ): QueryObserverResult<t.TCustomConfigSpeechResponse> => {
@@ -451,14 +376,3 @@ export const useGetCustomConfigSpeechQuery = (
451
376
  },
452
377
  );
453
378
  };
454
-
455
- export const useGetBannerQuery = (
456
- config?: UseQueryOptions<t.TBannerResponse>,
457
- ): QueryObserverResult<t.TBannerResponse> => {
458
- return useQuery<t.TBannerResponse>([QueryKeys.banner], () => dataService.getBanner(), {
459
- refetchOnWindowFocus: false,
460
- refetchOnReconnect: false,
461
- refetchOnMount: false,
462
- ...config,
463
- });
464
- };
package/src/request.ts CHANGED
@@ -91,6 +91,13 @@ axios.interceptors.response.use(
91
91
  return Promise.reject(error);
92
92
  }
93
93
 
94
+ if (originalRequest.url?.includes('/api/auth/2fa') === true) {
95
+ return Promise.reject(error);
96
+ }
97
+ if (originalRequest.url?.includes('/api/auth/logout') === true) {
98
+ return Promise.reject(error);
99
+ }
100
+
94
101
  if (error.response.status === 401 && !originalRequest._retry) {
95
102
  console.warn('401 error, refreshing token');
96
103
  originalRequest._retry = true;