librechat-data-provider 0.6.3 → 0.6.5
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/src/actions.ts +6 -1
- package/src/api-endpoints.ts +31 -5
- package/src/config.ts +39 -33
- package/src/createPayload.ts +2 -2
- package/src/data-service.ts +156 -31
- package/src/file-config.ts +15 -10
- package/src/keys.ts +2 -0
- package/src/parsers.ts +3 -0
- package/src/react-query/react-query-service.ts +35 -9
- package/src/schemas.ts +81 -42
- package/src/types/assistants.ts +68 -3
- package/src/types/files.ts +8 -0
- package/src/types/mutations.ts +20 -1
- package/src/types/queries.ts +23 -2
- package/src/types.ts +22 -1
package/package.json
CHANGED
package/src/actions.ts
CHANGED
|
@@ -212,6 +212,10 @@ export function resolveRef(
|
|
|
212
212
|
return schema as OpenAPIV3.SchemaObject;
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
+
function sanitizeOperationId(input: string) {
|
|
216
|
+
return input.replace(/[^a-zA-Z0-9_-]/g, '');
|
|
217
|
+
}
|
|
218
|
+
|
|
215
219
|
/** Function to convert OpenAPI spec to function signatures and request builders */
|
|
216
220
|
export function openapiToFunction(openapiSpec: OpenAPIV3.Document): {
|
|
217
221
|
functionSignatures: FunctionSignature[];
|
|
@@ -231,7 +235,8 @@ export function openapiToFunction(openapiSpec: OpenAPIV3.Document): {
|
|
|
231
235
|
};
|
|
232
236
|
|
|
233
237
|
// Operation ID is used as the function name
|
|
234
|
-
const
|
|
238
|
+
const defaultOperationId = `${method}_${path}`;
|
|
239
|
+
const operationId = operationObj.operationId || sanitizeOperationId(defaultOperationId);
|
|
235
240
|
const description = operationObj.summary || operationObj.description || '';
|
|
236
241
|
|
|
237
242
|
const parametersSchema: ParametersSchema = { type: 'object', properties: {}, required: [] };
|
package/src/api-endpoints.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { AssistantsEndpoint } from './schemas';
|
|
2
|
+
|
|
1
3
|
export const user = () => '/api/user';
|
|
2
4
|
|
|
3
5
|
export const balance = () => '/api/balance';
|
|
@@ -7,6 +9,13 @@ export const userPlugins = () => '/api/user/plugins';
|
|
|
7
9
|
export const messages = (conversationId: string, messageId?: string) =>
|
|
8
10
|
`/api/messages/${conversationId}${messageId ? `/${messageId}` : ''}`;
|
|
9
11
|
|
|
12
|
+
const shareRoot = '/api/share';
|
|
13
|
+
export const shareMessages = (shareId: string) => `${shareRoot}/${shareId}`;
|
|
14
|
+
export const getSharedLinks = (pageNumber: string, isPublic: boolean) =>
|
|
15
|
+
`${shareRoot}?pageNumber=${pageNumber}&isPublic=${isPublic}`;
|
|
16
|
+
export const createSharedLink = shareRoot;
|
|
17
|
+
export const updateSharedLink = shareRoot;
|
|
18
|
+
|
|
10
19
|
const keysEndpoint = '/api/keys';
|
|
11
20
|
|
|
12
21
|
export const keys = () => keysEndpoint;
|
|
@@ -76,15 +85,32 @@ export const plugins = () => '/api/plugins';
|
|
|
76
85
|
|
|
77
86
|
export const config = () => '/api/config';
|
|
78
87
|
|
|
79
|
-
export const assistants = (
|
|
80
|
-
|
|
88
|
+
export const assistants = ({
|
|
89
|
+
path,
|
|
90
|
+
options,
|
|
91
|
+
version,
|
|
92
|
+
endpoint,
|
|
93
|
+
}: {
|
|
94
|
+
path?: string;
|
|
95
|
+
options?: object;
|
|
96
|
+
endpoint?: AssistantsEndpoint;
|
|
97
|
+
version: number | string;
|
|
98
|
+
}) => {
|
|
99
|
+
let url = `/api/assistants/v${version}`;
|
|
100
|
+
|
|
101
|
+
if (path) {
|
|
102
|
+
url += `/${path}`;
|
|
103
|
+
}
|
|
81
104
|
|
|
82
|
-
if (
|
|
83
|
-
|
|
105
|
+
if (endpoint) {
|
|
106
|
+
options = {
|
|
107
|
+
...(options ?? {}),
|
|
108
|
+
endpoint,
|
|
109
|
+
};
|
|
84
110
|
}
|
|
85
111
|
|
|
86
112
|
if (options && Object.keys(options).length > 0) {
|
|
87
|
-
const queryParams = new URLSearchParams(options).toString();
|
|
113
|
+
const queryParams = new URLSearchParams(options as Record<string, string>).toString();
|
|
88
114
|
url += `?${queryParams}`;
|
|
89
115
|
}
|
|
90
116
|
|
package/src/config.ts
CHANGED
|
@@ -10,6 +10,8 @@ import { TModelsConfig } from './types';
|
|
|
10
10
|
export const defaultSocialLogins = ['google', 'facebook', 'openid', 'github', 'discord'];
|
|
11
11
|
|
|
12
12
|
export const defaultRetrievalModels = [
|
|
13
|
+
'gpt-4o',
|
|
14
|
+
'gpt-4o-2024-05-13',
|
|
13
15
|
'gpt-4-turbo-preview',
|
|
14
16
|
'gpt-3.5-turbo-0125',
|
|
15
17
|
'gpt-4-0125-preview',
|
|
@@ -129,11 +131,17 @@ export enum Capabilities {
|
|
|
129
131
|
tools = 'tools',
|
|
130
132
|
}
|
|
131
133
|
|
|
134
|
+
export const defaultAssistantsVersion = {
|
|
135
|
+
[EModelEndpoint.assistants]: 2,
|
|
136
|
+
[EModelEndpoint.azureAssistants]: 1,
|
|
137
|
+
};
|
|
138
|
+
|
|
132
139
|
export const assistantEndpointSchema = z.object({
|
|
133
140
|
/* assistants specific */
|
|
134
141
|
disableBuilder: z.boolean().optional(),
|
|
135
142
|
pollIntervalMs: z.number().optional(),
|
|
136
143
|
timeoutMs: z.number().optional(),
|
|
144
|
+
version: z.union([z.string(), z.number()]).default(2),
|
|
137
145
|
supportedIds: z.array(z.string()).min(1).optional(),
|
|
138
146
|
excludedIds: z.array(z.string()).min(1).optional(),
|
|
139
147
|
retrievalModels: z.array(z.string()).min(1).optional().default(defaultRetrievalModels),
|
|
@@ -245,6 +253,7 @@ export const configSchema = z.object({
|
|
|
245
253
|
cache: z.boolean().default(true),
|
|
246
254
|
secureImageLinks: z.boolean().optional(),
|
|
247
255
|
imageOutputType: z.nativeEnum(EImageOutputType).default(EImageOutputType.PNG),
|
|
256
|
+
includedTools: z.array(z.string()).optional(),
|
|
248
257
|
filteredTools: z.array(z.string()).optional(),
|
|
249
258
|
interface: z
|
|
250
259
|
.object({
|
|
@@ -286,6 +295,7 @@ export const configSchema = z.object({
|
|
|
286
295
|
endpoints: z
|
|
287
296
|
.object({
|
|
288
297
|
[EModelEndpoint.azureOpenAI]: azureEndpointSchema.optional(),
|
|
298
|
+
[EModelEndpoint.azureAssistants]: assistantEndpointSchema.optional(),
|
|
289
299
|
[EModelEndpoint.assistants]: assistantEndpointSchema.optional(),
|
|
290
300
|
custom: z.array(endpointSchema.partial()).optional(),
|
|
291
301
|
})
|
|
@@ -323,6 +333,7 @@ export enum FetchTokenConfig {
|
|
|
323
333
|
export const defaultEndpoints: EModelEndpoint[] = [
|
|
324
334
|
EModelEndpoint.openAI,
|
|
325
335
|
EModelEndpoint.assistants,
|
|
336
|
+
EModelEndpoint.azureAssistants,
|
|
326
337
|
EModelEndpoint.azureOpenAI,
|
|
327
338
|
EModelEndpoint.bingAI,
|
|
328
339
|
EModelEndpoint.chatGPTBrowser,
|
|
@@ -335,6 +346,7 @@ export const defaultEndpoints: EModelEndpoint[] = [
|
|
|
335
346
|
export const alternateName = {
|
|
336
347
|
[EModelEndpoint.openAI]: 'OpenAI',
|
|
337
348
|
[EModelEndpoint.assistants]: 'Assistants',
|
|
349
|
+
[EModelEndpoint.azureAssistants]: 'Azure Assistants',
|
|
338
350
|
[EModelEndpoint.azureOpenAI]: 'Azure OpenAI',
|
|
339
351
|
[EModelEndpoint.bingAI]: 'Bing',
|
|
340
352
|
[EModelEndpoint.chatGPTBrowser]: 'ChatGPT',
|
|
@@ -344,24 +356,27 @@ export const alternateName = {
|
|
|
344
356
|
[EModelEndpoint.custom]: 'Custom',
|
|
345
357
|
};
|
|
346
358
|
|
|
359
|
+
const sharedOpenAIModels = [
|
|
360
|
+
'gpt-3.5-turbo',
|
|
361
|
+
'gpt-3.5-turbo-0125',
|
|
362
|
+
'gpt-4-turbo',
|
|
363
|
+
'gpt-4-turbo-2024-04-09',
|
|
364
|
+
'gpt-4-0125-preview',
|
|
365
|
+
'gpt-4-turbo-preview',
|
|
366
|
+
'gpt-4-1106-preview',
|
|
367
|
+
'gpt-3.5-turbo-1106',
|
|
368
|
+
'gpt-3.5-turbo-16k-0613',
|
|
369
|
+
'gpt-3.5-turbo-16k',
|
|
370
|
+
'gpt-4',
|
|
371
|
+
'gpt-4-0314',
|
|
372
|
+
'gpt-4-32k-0314',
|
|
373
|
+
'gpt-4-0613',
|
|
374
|
+
'gpt-3.5-turbo-0613',
|
|
375
|
+
];
|
|
376
|
+
|
|
347
377
|
export const defaultModels = {
|
|
348
|
-
[EModelEndpoint.
|
|
349
|
-
|
|
350
|
-
'gpt-3.5-turbo-0125',
|
|
351
|
-
'gpt-4-turbo',
|
|
352
|
-
'gpt-4-turbo-2024-04-09',
|
|
353
|
-
'gpt-4-0125-preview',
|
|
354
|
-
'gpt-4-turbo-preview',
|
|
355
|
-
'gpt-4-1106-preview',
|
|
356
|
-
'gpt-3.5-turbo-1106',
|
|
357
|
-
'gpt-3.5-turbo-16k-0613',
|
|
358
|
-
'gpt-3.5-turbo-16k',
|
|
359
|
-
'gpt-4',
|
|
360
|
-
'gpt-4-0314',
|
|
361
|
-
'gpt-4-32k-0314',
|
|
362
|
-
'gpt-4-0613',
|
|
363
|
-
'gpt-3.5-turbo-0613',
|
|
364
|
-
],
|
|
378
|
+
[EModelEndpoint.azureAssistants]: sharedOpenAIModels,
|
|
379
|
+
[EModelEndpoint.assistants]: ['gpt-4o', ...sharedOpenAIModels],
|
|
365
380
|
[EModelEndpoint.google]: [
|
|
366
381
|
'gemini-pro',
|
|
367
382
|
'gemini-pro-vision',
|
|
@@ -389,25 +404,13 @@ export const defaultModels = {
|
|
|
389
404
|
'claude-instant-1-100k',
|
|
390
405
|
],
|
|
391
406
|
[EModelEndpoint.openAI]: [
|
|
392
|
-
'gpt-
|
|
393
|
-
|
|
394
|
-
'gpt-4-turbo-2024-04-09',
|
|
395
|
-
'gpt-3.5-turbo-16k-0613',
|
|
396
|
-
'gpt-3.5-turbo-16k',
|
|
397
|
-
'gpt-4-turbo-preview',
|
|
398
|
-
'gpt-4-0125-preview',
|
|
399
|
-
'gpt-4-1106-preview',
|
|
400
|
-
'gpt-3.5-turbo',
|
|
401
|
-
'gpt-3.5-turbo-1106',
|
|
407
|
+
'gpt-4o',
|
|
408
|
+
...sharedOpenAIModels,
|
|
402
409
|
'gpt-4-vision-preview',
|
|
403
|
-
'gpt-4',
|
|
404
410
|
'gpt-3.5-turbo-instruct-0914',
|
|
405
|
-
'gpt-3.5-turbo-0613',
|
|
406
411
|
'gpt-3.5-turbo-0301',
|
|
407
412
|
'gpt-3.5-turbo-instruct',
|
|
408
|
-
'gpt-4-0613',
|
|
409
413
|
'text-davinci-003',
|
|
410
|
-
'gpt-4-0314',
|
|
411
414
|
],
|
|
412
415
|
};
|
|
413
416
|
|
|
@@ -438,7 +441,8 @@ export const EndpointURLs: { [key in EModelEndpoint]: string } = {
|
|
|
438
441
|
[EModelEndpoint.gptPlugins]: `/api/ask/${EModelEndpoint.gptPlugins}`,
|
|
439
442
|
[EModelEndpoint.azureOpenAI]: `/api/ask/${EModelEndpoint.azureOpenAI}`,
|
|
440
443
|
[EModelEndpoint.chatGPTBrowser]: `/api/ask/${EModelEndpoint.chatGPTBrowser}`,
|
|
441
|
-
[EModelEndpoint.
|
|
444
|
+
[EModelEndpoint.azureAssistants]: '/api/assistants/v1/chat',
|
|
445
|
+
[EModelEndpoint.assistants]: '/api/assistants/v2/chat',
|
|
442
446
|
};
|
|
443
447
|
|
|
444
448
|
export const modularEndpoints = new Set<EModelEndpoint | string>([
|
|
@@ -456,10 +460,12 @@ export const supportsBalanceCheck = {
|
|
|
456
460
|
[EModelEndpoint.anthropic]: true,
|
|
457
461
|
[EModelEndpoint.gptPlugins]: true,
|
|
458
462
|
[EModelEndpoint.assistants]: true,
|
|
463
|
+
[EModelEndpoint.azureAssistants]: true,
|
|
459
464
|
[EModelEndpoint.azureOpenAI]: true,
|
|
460
465
|
};
|
|
461
466
|
|
|
462
467
|
export const visionModels = [
|
|
468
|
+
'gpt-4o',
|
|
463
469
|
'gpt-4-turbo',
|
|
464
470
|
'gpt-4-vision',
|
|
465
471
|
'llava',
|
|
@@ -677,7 +683,7 @@ export enum Constants {
|
|
|
677
683
|
/** Key for the app's version. */
|
|
678
684
|
VERSION = 'v0.7.2',
|
|
679
685
|
/** Key for the Custom Config's version (librechat.yaml). */
|
|
680
|
-
CONFIG_VERSION = '1.
|
|
686
|
+
CONFIG_VERSION = '1.1.1',
|
|
681
687
|
/** Standard value for the first message's `parentMessageId` value, to indicate no parent exists. */
|
|
682
688
|
NO_PARENT = '00000000-0000-0000-0000-000000000000',
|
|
683
689
|
/** Fixed, encoded domain length for Azure OpenAI Assistants Function name parsing. */
|
package/src/createPayload.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TSubmission, TMessage, TEndpointOption } from './types';
|
|
2
|
-
import { tConvoUpdateSchema, EModelEndpoint } from './schemas';
|
|
2
|
+
import { tConvoUpdateSchema, EModelEndpoint, isAssistantsEndpoint } from './schemas';
|
|
3
3
|
import { EndpointURLs } from './config';
|
|
4
4
|
|
|
5
5
|
export default function createPayload(submission: TSubmission) {
|
|
@@ -12,7 +12,7 @@ export default function createPayload(submission: TSubmission) {
|
|
|
12
12
|
|
|
13
13
|
let server = EndpointURLs[endpointType ?? endpoint];
|
|
14
14
|
|
|
15
|
-
if (isEdited && endpoint
|
|
15
|
+
if (isEdited && isAssistantsEndpoint(endpoint)) {
|
|
16
16
|
server += '/modify';
|
|
17
17
|
} else if (isEdited) {
|
|
18
18
|
server = server.replace('/ask/', '/edit/');
|
package/src/data-service.ts
CHANGED
|
@@ -31,6 +31,34 @@ export function getMessagesByConvoId(conversationId: string): Promise<s.TMessage
|
|
|
31
31
|
return request.get(endpoints.messages(conversationId));
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
export function getSharedMessages(shareId: string): Promise<t.TSharedMessagesResponse> {
|
|
35
|
+
return request.get(endpoints.shareMessages(shareId));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const listSharedLinks = (
|
|
39
|
+
params?: q.SharedLinkListParams,
|
|
40
|
+
): Promise<q.SharedLinksResponse> => {
|
|
41
|
+
const pageNumber = params?.pageNumber || '1'; // Default to page 1 if not provided
|
|
42
|
+
const isPublic = params?.isPublic || true; // Default to true if not provided
|
|
43
|
+
return request.get(endpoints.getSharedLinks(pageNumber, isPublic));
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export function getSharedLink(shareId: string): Promise<t.TSharedLinkResponse> {
|
|
47
|
+
return request.get(endpoints.shareMessages(shareId));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function createSharedLink(payload: t.TSharedLinkRequest): Promise<t.TSharedLinkResponse> {
|
|
51
|
+
return request.post(endpoints.createSharedLink, payload);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function updateSharedLink(payload: t.TSharedLinkRequest): Promise<t.TSharedLinkResponse> {
|
|
55
|
+
return request.patch(endpoints.updateSharedLink, payload);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function deleteSharedLink(shareId: string): Promise<t.TDeleteSharedLinkResponse> {
|
|
59
|
+
return request.delete(endpoints.shareMessages(shareId));
|
|
60
|
+
}
|
|
61
|
+
|
|
34
62
|
export function updateMessage(payload: t.TUpdateMessageRequest): Promise<unknown> {
|
|
35
63
|
const { conversationId, messageId, text } = payload;
|
|
36
64
|
if (!conversationId) {
|
|
@@ -138,39 +166,105 @@ export const getEndpointsConfigOverride = (): Promise<unknown | boolean> => {
|
|
|
138
166
|
|
|
139
167
|
/* Assistants */
|
|
140
168
|
|
|
141
|
-
export const createAssistant = (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
169
|
+
export const createAssistant = ({
|
|
170
|
+
version,
|
|
171
|
+
...data
|
|
172
|
+
}: a.AssistantCreateParams): Promise<a.Assistant> => {
|
|
173
|
+
return request.post(endpoints.assistants({ version }), data);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export const getAssistantById = ({
|
|
177
|
+
endpoint,
|
|
178
|
+
assistant_id,
|
|
179
|
+
version,
|
|
180
|
+
}: {
|
|
181
|
+
endpoint: s.AssistantsEndpoint;
|
|
182
|
+
assistant_id: string;
|
|
183
|
+
version: number | string | number;
|
|
184
|
+
}): Promise<a.Assistant> => {
|
|
185
|
+
return request.get(
|
|
186
|
+
endpoints.assistants({
|
|
187
|
+
path: assistant_id,
|
|
188
|
+
endpoint,
|
|
189
|
+
version,
|
|
190
|
+
}),
|
|
191
|
+
);
|
|
147
192
|
};
|
|
148
193
|
|
|
149
|
-
export const updateAssistant = (
|
|
150
|
-
assistant_id
|
|
151
|
-
data
|
|
152
|
-
|
|
153
|
-
|
|
194
|
+
export const updateAssistant = ({
|
|
195
|
+
assistant_id,
|
|
196
|
+
data,
|
|
197
|
+
version,
|
|
198
|
+
}: {
|
|
199
|
+
assistant_id: string;
|
|
200
|
+
data: a.AssistantUpdateParams;
|
|
201
|
+
version: number | string;
|
|
202
|
+
}): Promise<a.Assistant> => {
|
|
203
|
+
return request.patch(
|
|
204
|
+
endpoints.assistants({
|
|
205
|
+
path: assistant_id,
|
|
206
|
+
version,
|
|
207
|
+
}),
|
|
208
|
+
data,
|
|
209
|
+
);
|
|
154
210
|
};
|
|
155
211
|
|
|
156
|
-
export const deleteAssistant = (
|
|
157
|
-
|
|
212
|
+
export const deleteAssistant = ({
|
|
213
|
+
assistant_id,
|
|
214
|
+
model,
|
|
215
|
+
endpoint,
|
|
216
|
+
version,
|
|
217
|
+
}: m.DeleteAssistantBody & { version: number | string }): Promise<void> => {
|
|
218
|
+
return request.delete(
|
|
219
|
+
endpoints.assistants({
|
|
220
|
+
path: assistant_id,
|
|
221
|
+
options: { model, endpoint },
|
|
222
|
+
version,
|
|
223
|
+
}),
|
|
224
|
+
);
|
|
158
225
|
};
|
|
159
226
|
|
|
160
227
|
export const listAssistants = (
|
|
161
|
-
params
|
|
228
|
+
params: a.AssistantListParams,
|
|
229
|
+
version: number | string,
|
|
162
230
|
): Promise<a.AssistantListResponse> => {
|
|
163
|
-
return request.get(
|
|
231
|
+
return request.get(
|
|
232
|
+
endpoints.assistants({
|
|
233
|
+
version,
|
|
234
|
+
options: params,
|
|
235
|
+
}),
|
|
236
|
+
);
|
|
164
237
|
};
|
|
165
238
|
|
|
166
|
-
export function getAssistantDocs(
|
|
167
|
-
|
|
239
|
+
export function getAssistantDocs({
|
|
240
|
+
endpoint,
|
|
241
|
+
version,
|
|
242
|
+
}: {
|
|
243
|
+
endpoint: s.AssistantsEndpoint;
|
|
244
|
+
version: number | string;
|
|
245
|
+
}): Promise<a.AssistantDocument[]> {
|
|
246
|
+
return request.get(
|
|
247
|
+
endpoints.assistants({
|
|
248
|
+
path: 'documents',
|
|
249
|
+
version,
|
|
250
|
+
endpoint,
|
|
251
|
+
}),
|
|
252
|
+
);
|
|
168
253
|
}
|
|
169
254
|
|
|
170
255
|
/* Tools */
|
|
171
256
|
|
|
172
|
-
export const getAvailableTools = (
|
|
173
|
-
|
|
257
|
+
export const getAvailableTools = (
|
|
258
|
+
version: number | string,
|
|
259
|
+
endpoint: s.AssistantsEndpoint,
|
|
260
|
+
): Promise<s.TPlugin[]> => {
|
|
261
|
+
return request.get(
|
|
262
|
+
endpoints.assistants({
|
|
263
|
+
path: 'tools',
|
|
264
|
+
endpoint,
|
|
265
|
+
version,
|
|
266
|
+
}),
|
|
267
|
+
);
|
|
174
268
|
};
|
|
175
269
|
|
|
176
270
|
/* Files */
|
|
@@ -219,7 +313,11 @@ export const uploadAvatar = (data: FormData): Promise<f.AvatarUploadResponse> =>
|
|
|
219
313
|
|
|
220
314
|
export const uploadAssistantAvatar = (data: m.AssistantAvatarVariables): Promise<a.Assistant> => {
|
|
221
315
|
return request.postMultiPart(
|
|
222
|
-
endpoints.assistants(
|
|
316
|
+
endpoints.assistants({
|
|
317
|
+
path: `avatar/${data.assistant_id}`,
|
|
318
|
+
options: { model: data.model, endpoint: data.endpoint },
|
|
319
|
+
version: data.version,
|
|
320
|
+
}),
|
|
223
321
|
data.formData,
|
|
224
322
|
);
|
|
225
323
|
};
|
|
@@ -236,28 +334,55 @@ export const getFileDownload = async (userId: string, file_id: string): Promise<
|
|
|
236
334
|
export const deleteFiles = async (
|
|
237
335
|
files: f.BatchFile[],
|
|
238
336
|
assistant_id?: string,
|
|
337
|
+
tool_resource?: a.EToolResources,
|
|
239
338
|
): Promise<f.DeleteFilesResponse> =>
|
|
240
339
|
request.deleteWithOptions(endpoints.files(), {
|
|
241
|
-
data: { files, assistant_id },
|
|
340
|
+
data: { files, assistant_id, tool_resource },
|
|
242
341
|
});
|
|
243
342
|
|
|
244
343
|
/* actions */
|
|
245
344
|
|
|
246
345
|
export const updateAction = (data: m.UpdateActionVariables): Promise<m.UpdateActionResponse> => {
|
|
247
|
-
const { assistant_id, ...body } = data;
|
|
248
|
-
return request.post(
|
|
346
|
+
const { assistant_id, version, ...body } = data;
|
|
347
|
+
return request.post(
|
|
348
|
+
endpoints.assistants({
|
|
349
|
+
path: `actions/${assistant_id}`,
|
|
350
|
+
version,
|
|
351
|
+
}),
|
|
352
|
+
body,
|
|
353
|
+
);
|
|
249
354
|
};
|
|
250
355
|
|
|
251
|
-
export function getActions(
|
|
252
|
-
|
|
356
|
+
export function getActions({
|
|
357
|
+
endpoint,
|
|
358
|
+
version,
|
|
359
|
+
}: {
|
|
360
|
+
endpoint: s.AssistantsEndpoint;
|
|
361
|
+
version: number | string;
|
|
362
|
+
}): Promise<a.Action[]> {
|
|
363
|
+
return request.get(
|
|
364
|
+
endpoints.assistants({
|
|
365
|
+
path: 'actions',
|
|
366
|
+
version,
|
|
367
|
+
endpoint,
|
|
368
|
+
}),
|
|
369
|
+
);
|
|
253
370
|
}
|
|
254
371
|
|
|
255
|
-
export const deleteAction = async (
|
|
256
|
-
assistant_id
|
|
257
|
-
action_id
|
|
258
|
-
model
|
|
259
|
-
|
|
260
|
-
|
|
372
|
+
export const deleteAction = async ({
|
|
373
|
+
assistant_id,
|
|
374
|
+
action_id,
|
|
375
|
+
model,
|
|
376
|
+
version,
|
|
377
|
+
endpoint,
|
|
378
|
+
}: m.DeleteActionVariables & { version: number | string }): Promise<void> =>
|
|
379
|
+
request.delete(
|
|
380
|
+
endpoints.assistants({
|
|
381
|
+
path: `actions/${assistant_id}/${action_id}/${model}`,
|
|
382
|
+
version,
|
|
383
|
+
endpoint,
|
|
384
|
+
}),
|
|
385
|
+
);
|
|
261
386
|
|
|
262
387
|
/* conversations */
|
|
263
388
|
|
package/src/file-config.ts
CHANGED
|
@@ -7,6 +7,7 @@ export const supportsFiles = {
|
|
|
7
7
|
[EModelEndpoint.openAI]: true,
|
|
8
8
|
[EModelEndpoint.google]: true,
|
|
9
9
|
[EModelEndpoint.assistants]: true,
|
|
10
|
+
[EModelEndpoint.azureAssistants]: true,
|
|
10
11
|
[EModelEndpoint.azureOpenAI]: true,
|
|
11
12
|
[EModelEndpoint.anthropic]: true,
|
|
12
13
|
[EModelEndpoint.custom]: true,
|
|
@@ -152,24 +153,28 @@ export const megabyte = 1024 * 1024;
|
|
|
152
153
|
/** Helper function to get megabytes value */
|
|
153
154
|
export const mbToBytes = (mb: number): number => mb * megabyte;
|
|
154
155
|
|
|
156
|
+
const defaultSizeLimit = mbToBytes(512);
|
|
157
|
+
const assistantsFileConfig = {
|
|
158
|
+
fileLimit: 10,
|
|
159
|
+
fileSizeLimit: defaultSizeLimit,
|
|
160
|
+
totalSizeLimit: defaultSizeLimit,
|
|
161
|
+
supportedMimeTypes,
|
|
162
|
+
disabled: false,
|
|
163
|
+
};
|
|
164
|
+
|
|
155
165
|
export const fileConfig = {
|
|
156
166
|
endpoints: {
|
|
157
|
-
[EModelEndpoint.assistants]:
|
|
158
|
-
|
|
159
|
-
fileSizeLimit: mbToBytes(512),
|
|
160
|
-
totalSizeLimit: mbToBytes(512),
|
|
161
|
-
supportedMimeTypes,
|
|
162
|
-
disabled: false,
|
|
163
|
-
},
|
|
167
|
+
[EModelEndpoint.assistants]: assistantsFileConfig,
|
|
168
|
+
[EModelEndpoint.azureAssistants]: assistantsFileConfig,
|
|
164
169
|
default: {
|
|
165
170
|
fileLimit: 10,
|
|
166
|
-
fileSizeLimit:
|
|
167
|
-
totalSizeLimit:
|
|
171
|
+
fileSizeLimit: defaultSizeLimit,
|
|
172
|
+
totalSizeLimit: defaultSizeLimit,
|
|
168
173
|
supportedMimeTypes,
|
|
169
174
|
disabled: false,
|
|
170
175
|
},
|
|
171
176
|
},
|
|
172
|
-
serverFileSizeLimit:
|
|
177
|
+
serverFileSizeLimit: defaultSizeLimit,
|
|
173
178
|
avatarSizeLimit: mbToBytes(2),
|
|
174
179
|
checkType: function (fileType: string, supportedTypes: RegExp[] = supportedMimeTypes) {
|
|
175
180
|
return supportedTypes.some((regex) => regex.test(fileType));
|
package/src/keys.ts
CHANGED
package/src/parsers.ts
CHANGED
|
@@ -38,6 +38,7 @@ const endpointSchemas: Record<EModelEndpoint, EndpointSchema> = {
|
|
|
38
38
|
[EModelEndpoint.chatGPTBrowser]: chatGPTBrowserSchema,
|
|
39
39
|
[EModelEndpoint.gptPlugins]: gptPluginsSchema,
|
|
40
40
|
[EModelEndpoint.assistants]: assistantSchema,
|
|
41
|
+
[EModelEndpoint.azureAssistants]: assistantSchema,
|
|
41
42
|
};
|
|
42
43
|
|
|
43
44
|
// const schemaCreators: Record<EModelEndpoint, (customSchema: DefaultSchemaValues) => EndpointSchema> = {
|
|
@@ -49,6 +50,7 @@ export function getEnabledEndpoints() {
|
|
|
49
50
|
const defaultEndpoints: string[] = [
|
|
50
51
|
EModelEndpoint.openAI,
|
|
51
52
|
EModelEndpoint.assistants,
|
|
53
|
+
EModelEndpoint.azureAssistants,
|
|
52
54
|
EModelEndpoint.azureOpenAI,
|
|
53
55
|
EModelEndpoint.google,
|
|
54
56
|
EModelEndpoint.bingAI,
|
|
@@ -273,6 +275,7 @@ const compactEndpointSchemas: Record<string, CompactEndpointSchema> = {
|
|
|
273
275
|
[EModelEndpoint.azureOpenAI]: compactOpenAISchema,
|
|
274
276
|
[EModelEndpoint.custom]: compactOpenAISchema,
|
|
275
277
|
[EModelEndpoint.assistants]: compactAssistantSchema,
|
|
278
|
+
[EModelEndpoint.azureAssistants]: compactAssistantSchema,
|
|
276
279
|
[EModelEndpoint.google]: compactGoogleSchema,
|
|
277
280
|
/* BingAI needs all fields */
|
|
278
281
|
[EModelEndpoint.bingAI]: bingAISchema,
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import type {
|
|
2
3
|
UseQueryOptions,
|
|
3
|
-
useQuery,
|
|
4
|
-
useMutation,
|
|
5
|
-
useQueryClient,
|
|
6
4
|
UseMutationResult,
|
|
7
5
|
QueryObserverResult,
|
|
8
6
|
} from '@tanstack/react-query';
|
|
9
|
-
import { defaultOrderQuery } from '../types/assistants';
|
|
10
7
|
import { initialModelsConfig, LocalStorageKeys } from '../config';
|
|
8
|
+
import { defaultOrderQuery } from '../types/assistants';
|
|
11
9
|
import * as dataService from '../data-service';
|
|
12
10
|
import * as m from '../types/mutations';
|
|
13
11
|
import { QueryKeys } from '../keys';
|
|
@@ -60,6 +58,22 @@ export const useGetMessagesByConvoId = <TData = s.TMessage[]>(
|
|
|
60
58
|
);
|
|
61
59
|
};
|
|
62
60
|
|
|
61
|
+
export const useGetSharedMessages = (
|
|
62
|
+
shareId: string,
|
|
63
|
+
config?: UseQueryOptions<t.TSharedMessagesResponse>,
|
|
64
|
+
): QueryObserverResult<t.TSharedMessagesResponse> => {
|
|
65
|
+
return useQuery<t.TSharedMessagesResponse>(
|
|
66
|
+
[QueryKeys.sharedMessages, shareId],
|
|
67
|
+
() => dataService.getSharedMessages(shareId),
|
|
68
|
+
{
|
|
69
|
+
refetchOnWindowFocus: false,
|
|
70
|
+
refetchOnReconnect: false,
|
|
71
|
+
refetchOnMount: false,
|
|
72
|
+
...config,
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
63
77
|
export const useGetUserBalance = (
|
|
64
78
|
config?: UseQueryOptions<string>,
|
|
65
79
|
): QueryObserverResult<string> => {
|
|
@@ -138,8 +152,8 @@ export const useRevokeUserKeyMutation = (name: string): UseMutationResult<unknow
|
|
|
138
152
|
return useMutation(() => dataService.revokeUserKey(name), {
|
|
139
153
|
onSuccess: () => {
|
|
140
154
|
queryClient.invalidateQueries([QueryKeys.name, name]);
|
|
141
|
-
if (
|
|
142
|
-
queryClient.invalidateQueries([QueryKeys.assistants, defaultOrderQuery]);
|
|
155
|
+
if (s.isAssistantsEndpoint(name)) {
|
|
156
|
+
queryClient.invalidateQueries([QueryKeys.assistants, name, defaultOrderQuery]);
|
|
143
157
|
queryClient.invalidateQueries([QueryKeys.assistantDocs]);
|
|
144
158
|
queryClient.invalidateQueries([QueryKeys.assistants]);
|
|
145
159
|
queryClient.invalidateQueries([QueryKeys.assistant]);
|
|
@@ -155,7 +169,16 @@ export const useRevokeAllUserKeysMutation = (): UseMutationResult<unknown> => {
|
|
|
155
169
|
return useMutation(() => dataService.revokeAllUserKeys(), {
|
|
156
170
|
onSuccess: () => {
|
|
157
171
|
queryClient.invalidateQueries([QueryKeys.name]);
|
|
158
|
-
queryClient.invalidateQueries([
|
|
172
|
+
queryClient.invalidateQueries([
|
|
173
|
+
QueryKeys.assistants,
|
|
174
|
+
s.EModelEndpoint.assistants,
|
|
175
|
+
defaultOrderQuery,
|
|
176
|
+
]);
|
|
177
|
+
queryClient.invalidateQueries([
|
|
178
|
+
QueryKeys.assistants,
|
|
179
|
+
s.EModelEndpoint.azureAssistants,
|
|
180
|
+
defaultOrderQuery,
|
|
181
|
+
]);
|
|
159
182
|
queryClient.invalidateQueries([QueryKeys.assistantDocs]);
|
|
160
183
|
queryClient.invalidateQueries([QueryKeys.assistants]);
|
|
161
184
|
queryClient.invalidateQueries([QueryKeys.assistant]);
|
|
@@ -398,7 +421,9 @@ export const useUpdateUserPluginsMutation = (): UseMutationResult<
|
|
|
398
421
|
});
|
|
399
422
|
};
|
|
400
423
|
|
|
401
|
-
export const useGetStartupConfig = (
|
|
424
|
+
export const useGetStartupConfig = (
|
|
425
|
+
config?: UseQueryOptions<t.TStartupConfig>,
|
|
426
|
+
): QueryObserverResult<t.TStartupConfig> => {
|
|
402
427
|
return useQuery<t.TStartupConfig>(
|
|
403
428
|
[QueryKeys.startupConfig],
|
|
404
429
|
() => dataService.getStartupConfig(),
|
|
@@ -406,6 +431,7 @@ export const useGetStartupConfig = (): QueryObserverResult<t.TStartupConfig> =>
|
|
|
406
431
|
refetchOnWindowFocus: false,
|
|
407
432
|
refetchOnReconnect: false,
|
|
408
433
|
refetchOnMount: false,
|
|
434
|
+
...config,
|
|
409
435
|
},
|
|
410
436
|
);
|
|
411
437
|
};
|