librechat-data-provider 0.7.4 → 0.7.7
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/check_updates.sh +1 -0
- 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/dist/react-query/package.json +1 -1
- package/package.json +6 -6
- package/react-query/package.json +1 -1
- package/server-rollup.config.js +3 -3
- package/specs/actions.spec.ts +700 -36
- package/specs/azure.spec.ts +8 -5
- package/specs/filetypes.spec.ts +1 -7
- package/specs/mcp.spec.ts +52 -0
- package/specs/openapiSpecs.ts +127 -0
- package/specs/utils.spec.ts +129 -0
- package/src/actions.ts +311 -101
- package/src/api-endpoints.ts +70 -13
- package/src/artifacts.ts +3104 -0
- package/src/azure.ts +40 -33
- package/src/bedrock.ts +227 -0
- package/src/config.ts +344 -78
- package/src/createPayload.ts +3 -1
- package/src/data-service.ts +353 -90
- package/src/file-config.ts +13 -2
- package/src/generate.ts +31 -2
- package/src/index.ts +12 -4
- package/src/keys.ts +17 -0
- package/src/mcp.ts +87 -0
- package/src/models.ts +1 -1
- package/src/parsers.ts +118 -60
- package/src/react-query/react-query-service.ts +54 -115
- package/src/request.ts +31 -7
- package/src/roles.ts +91 -2
- package/src/schemas.ts +513 -340
- package/src/types/agents.ts +276 -0
- package/src/types/assistants.ts +181 -27
- package/src/types/files.ts +6 -0
- package/src/types/mutations.ts +170 -7
- package/src/types/queries.ts +43 -21
- package/src/types/runs.ts +23 -0
- package/src/types.ts +132 -67
- package/src/utils.ts +44 -0
- package/src/zod.spec.ts +526 -0
- package/src/zod.ts +86 -0
- package/tsconfig.json +1 -2
- package/specs/parsers.spec.ts +0 -48
- package/src/sse.js +0 -242
package/src/createPayload.ts
CHANGED
|
@@ -3,7 +3,8 @@ import { EndpointURLs } from './config';
|
|
|
3
3
|
import * as s from './schemas';
|
|
4
4
|
|
|
5
5
|
export default function createPayload(submission: t.TSubmission) {
|
|
6
|
-
const { conversation, userMessage, endpointOption, isEdited, isContinued } =
|
|
6
|
+
const { conversation, userMessage, endpointOption, isEdited, isContinued, isTemporary } =
|
|
7
|
+
submission;
|
|
7
8
|
const { conversationId } = s.tConvoUpdateSchema.parse(conversation);
|
|
8
9
|
const { endpoint, endpointType } = endpointOption as {
|
|
9
10
|
endpoint: s.EModelEndpoint;
|
|
@@ -23,6 +24,7 @@ export default function createPayload(submission: t.TSubmission) {
|
|
|
23
24
|
...endpointOption,
|
|
24
25
|
isContinued: !!(isEdited && isContinued),
|
|
25
26
|
conversationId,
|
|
27
|
+
isTemporary,
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
return { server, payload };
|
package/src/data-service.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { AxiosResponse } from 'axios';
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import * as m from './types/mutations';
|
|
2
|
+
import type * as t from './types';
|
|
3
|
+
import * as endpoints from './api-endpoints';
|
|
5
4
|
import * as a from './types/assistants';
|
|
6
|
-
import * as
|
|
7
|
-
import * as
|
|
8
|
-
import * as
|
|
5
|
+
import * as m from './types/mutations';
|
|
6
|
+
import * as q from './types/queries';
|
|
7
|
+
import * as f from './types/files';
|
|
8
|
+
import * as config from './config';
|
|
9
9
|
import request from './request';
|
|
10
|
-
import * as
|
|
10
|
+
import * as s from './schemas';
|
|
11
|
+
import * as r from './roles';
|
|
11
12
|
|
|
12
13
|
export function abortRequestWithMessage(
|
|
13
14
|
endpoint: string,
|
|
@@ -40,27 +41,29 @@ export function getSharedMessages(shareId: string): Promise<t.TSharedMessagesRes
|
|
|
40
41
|
return request.get(endpoints.shareMessages(shareId));
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
export const listSharedLinks = (
|
|
44
|
-
params
|
|
44
|
+
export const listSharedLinks = async (
|
|
45
|
+
params: q.SharedLinksListParams,
|
|
45
46
|
): Promise<q.SharedLinksResponse> => {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
return request.get(
|
|
47
|
+
const { pageSize, isPublic, sortBy, sortDirection, search, cursor } = params;
|
|
48
|
+
|
|
49
|
+
return request.get(
|
|
50
|
+
endpoints.getSharedLinks(pageSize, isPublic, sortBy, sortDirection, search, cursor),
|
|
51
|
+
);
|
|
49
52
|
};
|
|
50
53
|
|
|
51
|
-
export function getSharedLink(
|
|
52
|
-
return request.get(endpoints.
|
|
54
|
+
export function getSharedLink(conversationId: string): Promise<t.TSharedLinkGetResponse> {
|
|
55
|
+
return request.get(endpoints.getSharedLink(conversationId));
|
|
53
56
|
}
|
|
54
57
|
|
|
55
|
-
export function createSharedLink(
|
|
56
|
-
return request.post(endpoints.createSharedLink
|
|
58
|
+
export function createSharedLink(conversationId: string): Promise<t.TSharedLinkResponse> {
|
|
59
|
+
return request.post(endpoints.createSharedLink(conversationId));
|
|
57
60
|
}
|
|
58
61
|
|
|
59
|
-
export function updateSharedLink(
|
|
60
|
-
return request.patch(endpoints.updateSharedLink
|
|
62
|
+
export function updateSharedLink(shareId: string): Promise<t.TSharedLinkResponse> {
|
|
63
|
+
return request.patch(endpoints.updateSharedLink(shareId));
|
|
61
64
|
}
|
|
62
65
|
|
|
63
|
-
export function deleteSharedLink(shareId: string): Promise<
|
|
66
|
+
export function deleteSharedLink(shareId: string): Promise<m.TDeleteSharedLinkResponse> {
|
|
64
67
|
return request.delete(endpoints.shareMessages(shareId));
|
|
65
68
|
}
|
|
66
69
|
|
|
@@ -73,6 +76,22 @@ export function updateMessage(payload: t.TUpdateMessageRequest): Promise<unknown
|
|
|
73
76
|
return request.put(endpoints.messages(conversationId, messageId), { text });
|
|
74
77
|
}
|
|
75
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
|
+
|
|
86
|
+
export function updateMessageContent(payload: t.TUpdateMessageContent): Promise<unknown> {
|
|
87
|
+
const { conversationId, messageId, index, text } = payload;
|
|
88
|
+
if (!conversationId) {
|
|
89
|
+
throw new Error('conversationId is required');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return request.put(endpoints.messages(conversationId, messageId), { text, index });
|
|
93
|
+
}
|
|
94
|
+
|
|
76
95
|
export function updateUserKey(payload: t.TUpdateUserKeyRequest) {
|
|
77
96
|
const { value } = payload;
|
|
78
97
|
if (!value) {
|
|
@@ -114,11 +133,11 @@ export const updateTokenCount = (text: string) => {
|
|
|
114
133
|
return request.post(endpoints.tokenizer(), { arg: text });
|
|
115
134
|
};
|
|
116
135
|
|
|
117
|
-
export const login = (payload: t.TLoginUser) => {
|
|
136
|
+
export const login = (payload: t.TLoginUser): Promise<t.TLoginResponse> => {
|
|
118
137
|
return request.post(endpoints.login(), payload);
|
|
119
138
|
};
|
|
120
139
|
|
|
121
|
-
export const logout = () => {
|
|
140
|
+
export const logout = (): Promise<m.TLogoutResponse> => {
|
|
122
141
|
return request.post(endpoints.logout());
|
|
123
142
|
};
|
|
124
143
|
|
|
@@ -163,7 +182,7 @@ export const updateUserPlugins = (payload: t.TUpdateUserPlugins) => {
|
|
|
163
182
|
|
|
164
183
|
/* Config */
|
|
165
184
|
|
|
166
|
-
export const getStartupConfig = (): Promise<
|
|
185
|
+
export const getStartupConfig = (): Promise<config.TStartupConfig> => {
|
|
167
186
|
return request.get(endpoints.config());
|
|
168
187
|
};
|
|
169
188
|
|
|
@@ -255,14 +274,18 @@ export function getAssistantDocs({
|
|
|
255
274
|
endpoint,
|
|
256
275
|
version,
|
|
257
276
|
}: {
|
|
258
|
-
endpoint: s.AssistantsEndpoint;
|
|
277
|
+
endpoint: s.AssistantsEndpoint | string;
|
|
259
278
|
version: number | string;
|
|
260
279
|
}): Promise<a.AssistantDocument[]> {
|
|
280
|
+
if (!s.isAssistantsEndpoint(endpoint)) {
|
|
281
|
+
return Promise.resolve([]);
|
|
282
|
+
}
|
|
261
283
|
return request.get(
|
|
262
284
|
endpoints.assistants({
|
|
263
285
|
path: 'documents',
|
|
264
286
|
version,
|
|
265
|
-
endpoint,
|
|
287
|
+
options: { endpoint },
|
|
288
|
+
endpoint: endpoint as s.AssistantsEndpoint,
|
|
266
289
|
}),
|
|
267
290
|
);
|
|
268
291
|
}
|
|
@@ -270,14 +293,56 @@ export function getAssistantDocs({
|
|
|
270
293
|
/* Tools */
|
|
271
294
|
|
|
272
295
|
export const getAvailableTools = (
|
|
273
|
-
|
|
274
|
-
|
|
296
|
+
_endpoint: s.AssistantsEndpoint | s.EModelEndpoint.agents,
|
|
297
|
+
version?: number | string,
|
|
275
298
|
): Promise<s.TPlugin[]> => {
|
|
276
|
-
|
|
277
|
-
|
|
299
|
+
let path = '';
|
|
300
|
+
if (s.isAssistantsEndpoint(_endpoint)) {
|
|
301
|
+
const endpoint = _endpoint as s.AssistantsEndpoint;
|
|
302
|
+
path = endpoints.assistants({
|
|
278
303
|
path: 'tools',
|
|
279
|
-
endpoint,
|
|
280
|
-
version,
|
|
304
|
+
endpoint: endpoint,
|
|
305
|
+
version: version ?? config.defaultAssistantsVersion[endpoint],
|
|
306
|
+
});
|
|
307
|
+
} else {
|
|
308
|
+
path = endpoints.agents({
|
|
309
|
+
path: 'tools',
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return request.get(path);
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
export const getVerifyAgentToolAuth = (
|
|
317
|
+
params: q.VerifyToolAuthParams,
|
|
318
|
+
): Promise<q.VerifyToolAuthResponse> => {
|
|
319
|
+
return request.get(
|
|
320
|
+
endpoints.agents({
|
|
321
|
+
path: `tools/${params.toolId}/auth`,
|
|
322
|
+
}),
|
|
323
|
+
);
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
export const callTool = <T extends m.ToolId>({
|
|
327
|
+
toolId,
|
|
328
|
+
toolParams,
|
|
329
|
+
}: {
|
|
330
|
+
toolId: T;
|
|
331
|
+
toolParams: m.ToolParams<T>;
|
|
332
|
+
}): Promise<m.ToolCallResponse> => {
|
|
333
|
+
return request.post(
|
|
334
|
+
endpoints.agents({
|
|
335
|
+
path: `tools/${toolId}/call`,
|
|
336
|
+
}),
|
|
337
|
+
toolParams,
|
|
338
|
+
);
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
export const getToolCalls = (params: q.GetToolCallParams): Promise<q.ToolCallResults> => {
|
|
342
|
+
return request.get(
|
|
343
|
+
endpoints.agents({
|
|
344
|
+
path: 'tools/calls',
|
|
345
|
+
options: params,
|
|
281
346
|
}),
|
|
282
347
|
);
|
|
283
348
|
};
|
|
@@ -292,14 +357,146 @@ export const getFileConfig = (): Promise<f.FileConfig> => {
|
|
|
292
357
|
return request.get(`${endpoints.files()}/config`);
|
|
293
358
|
};
|
|
294
359
|
|
|
295
|
-
export const uploadImage = (
|
|
296
|
-
|
|
360
|
+
export const uploadImage = (
|
|
361
|
+
data: FormData,
|
|
362
|
+
signal?: AbortSignal | null,
|
|
363
|
+
): Promise<f.TFileUpload> => {
|
|
364
|
+
const requestConfig = signal ? { signal } : undefined;
|
|
365
|
+
return request.postMultiPart(endpoints.images(), data, requestConfig);
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
export const uploadFile = (data: FormData, signal?: AbortSignal | null): Promise<f.TFileUpload> => {
|
|
369
|
+
const requestConfig = signal ? { signal } : undefined;
|
|
370
|
+
return request.postMultiPart(endpoints.files(), data, requestConfig);
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
/* actions */
|
|
374
|
+
|
|
375
|
+
export const updateAction = (data: m.UpdateActionVariables): Promise<m.UpdateActionResponse> => {
|
|
376
|
+
const { assistant_id, version, ...body } = data;
|
|
377
|
+
return request.post(
|
|
378
|
+
endpoints.assistants({
|
|
379
|
+
path: `actions/${assistant_id}`,
|
|
380
|
+
version,
|
|
381
|
+
}),
|
|
382
|
+
body,
|
|
383
|
+
);
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
export function getActions(): Promise<a.Action[]> {
|
|
387
|
+
return request.get(
|
|
388
|
+
endpoints.agents({
|
|
389
|
+
path: 'actions',
|
|
390
|
+
}),
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export const deleteAction = async ({
|
|
395
|
+
assistant_id,
|
|
396
|
+
action_id,
|
|
397
|
+
model,
|
|
398
|
+
version,
|
|
399
|
+
endpoint,
|
|
400
|
+
}: m.DeleteActionVariables & { version: number | string }): Promise<void> =>
|
|
401
|
+
request.delete(
|
|
402
|
+
endpoints.assistants({
|
|
403
|
+
path: `actions/${assistant_id}/${action_id}/${model}`,
|
|
404
|
+
version,
|
|
405
|
+
endpoint,
|
|
406
|
+
}),
|
|
407
|
+
);
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Agents
|
|
411
|
+
*/
|
|
412
|
+
|
|
413
|
+
export const createAgent = ({ ...data }: a.AgentCreateParams): Promise<a.Agent> => {
|
|
414
|
+
return request.post(endpoints.agents({}), data);
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
export const getAgentById = ({ agent_id }: { agent_id: string }): Promise<a.Agent> => {
|
|
418
|
+
return request.get(
|
|
419
|
+
endpoints.agents({
|
|
420
|
+
path: agent_id,
|
|
421
|
+
}),
|
|
422
|
+
);
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
export const updateAgent = ({
|
|
426
|
+
agent_id,
|
|
427
|
+
data,
|
|
428
|
+
}: {
|
|
429
|
+
agent_id: string;
|
|
430
|
+
data: a.AgentUpdateParams;
|
|
431
|
+
}): Promise<a.Agent> => {
|
|
432
|
+
return request.patch(
|
|
433
|
+
endpoints.agents({
|
|
434
|
+
path: agent_id,
|
|
435
|
+
}),
|
|
436
|
+
data,
|
|
437
|
+
);
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
export const duplicateAgent = ({
|
|
441
|
+
agent_id,
|
|
442
|
+
}: m.DuplicateAgentBody): Promise<{ agent: a.Agent; actions: a.Action[] }> => {
|
|
443
|
+
return request.post(
|
|
444
|
+
endpoints.agents({
|
|
445
|
+
path: `${agent_id}/duplicate`,
|
|
446
|
+
}),
|
|
447
|
+
);
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
export const deleteAgent = ({ agent_id }: m.DeleteAgentBody): Promise<void> => {
|
|
451
|
+
return request.delete(
|
|
452
|
+
endpoints.agents({
|
|
453
|
+
path: agent_id,
|
|
454
|
+
}),
|
|
455
|
+
);
|
|
297
456
|
};
|
|
298
457
|
|
|
299
|
-
export const
|
|
300
|
-
return request.
|
|
458
|
+
export const listAgents = (params: a.AgentListParams): Promise<a.AgentListResponse> => {
|
|
459
|
+
return request.get(
|
|
460
|
+
endpoints.agents({
|
|
461
|
+
options: params,
|
|
462
|
+
}),
|
|
463
|
+
);
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
/* Tools */
|
|
467
|
+
|
|
468
|
+
export const getAvailableAgentTools = (): Promise<s.TPlugin[]> => {
|
|
469
|
+
return request.get(
|
|
470
|
+
endpoints.agents({
|
|
471
|
+
path: 'tools',
|
|
472
|
+
}),
|
|
473
|
+
);
|
|
301
474
|
};
|
|
302
475
|
|
|
476
|
+
/* Actions */
|
|
477
|
+
|
|
478
|
+
export const updateAgentAction = (
|
|
479
|
+
data: m.UpdateAgentActionVariables,
|
|
480
|
+
): Promise<m.UpdateAgentActionResponse> => {
|
|
481
|
+
const { agent_id, ...body } = data;
|
|
482
|
+
return request.post(
|
|
483
|
+
endpoints.agents({
|
|
484
|
+
path: `actions/${agent_id}`,
|
|
485
|
+
}),
|
|
486
|
+
body,
|
|
487
|
+
);
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
export const deleteAgentAction = async ({
|
|
491
|
+
agent_id,
|
|
492
|
+
action_id,
|
|
493
|
+
}: m.DeleteAgentActionVariables): Promise<void> =>
|
|
494
|
+
request.delete(
|
|
495
|
+
endpoints.agents({
|
|
496
|
+
path: `actions/${agent_id}/${action_id}`,
|
|
497
|
+
}),
|
|
498
|
+
);
|
|
499
|
+
|
|
303
500
|
/**
|
|
304
501
|
* Imports a conversations file.
|
|
305
502
|
*
|
|
@@ -317,7 +514,8 @@ export const uploadAvatar = (data: FormData): Promise<f.AvatarUploadResponse> =>
|
|
|
317
514
|
export const uploadAssistantAvatar = (data: m.AssistantAvatarVariables): Promise<a.Assistant> => {
|
|
318
515
|
return request.postMultiPart(
|
|
319
516
|
endpoints.assistants({
|
|
320
|
-
|
|
517
|
+
isAvatar: true,
|
|
518
|
+
path: `${data.assistant_id}/avatar`,
|
|
321
519
|
options: { model: data.model, endpoint: data.endpoint },
|
|
322
520
|
version: data.version,
|
|
323
521
|
}),
|
|
@@ -325,6 +523,13 @@ export const uploadAssistantAvatar = (data: m.AssistantAvatarVariables): Promise
|
|
|
325
523
|
);
|
|
326
524
|
};
|
|
327
525
|
|
|
526
|
+
export const uploadAgentAvatar = (data: m.AgentAvatarVariables): Promise<a.Agent> => {
|
|
527
|
+
return request.postMultiPart(
|
|
528
|
+
`${endpoints.images()}/agents/${data.agent_id}/avatar`,
|
|
529
|
+
data.formData,
|
|
530
|
+
);
|
|
531
|
+
};
|
|
532
|
+
|
|
328
533
|
export const getFileDownload = async (userId: string, file_id: string): Promise<AxiosResponse> => {
|
|
329
534
|
return request.getResponse(`${endpoints.files()}/download/${userId}/${file_id}`, {
|
|
330
535
|
responseType: 'blob',
|
|
@@ -334,15 +539,27 @@ export const getFileDownload = async (userId: string, file_id: string): Promise<
|
|
|
334
539
|
});
|
|
335
540
|
};
|
|
336
541
|
|
|
337
|
-
export const
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
542
|
+
export const getCodeOutputDownload = async (url: string): Promise<AxiosResponse> => {
|
|
543
|
+
return request.getResponse(url, {
|
|
544
|
+
responseType: 'blob',
|
|
545
|
+
headers: {
|
|
546
|
+
Accept: 'application/octet-stream',
|
|
547
|
+
},
|
|
548
|
+
});
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
export const deleteFiles = async (payload: {
|
|
552
|
+
files: f.BatchFile[];
|
|
553
|
+
agent_id?: string;
|
|
554
|
+
assistant_id?: string;
|
|
555
|
+
tool_resource?: a.EToolResources;
|
|
556
|
+
}): Promise<f.DeleteFilesResponse> =>
|
|
342
557
|
request.deleteWithOptions(endpoints.files(), {
|
|
343
|
-
data:
|
|
558
|
+
data: payload,
|
|
344
559
|
});
|
|
345
560
|
|
|
561
|
+
/* Speech */
|
|
562
|
+
|
|
346
563
|
export const speechToText = (data: FormData): Promise<f.SpeechToTextResponse> => {
|
|
347
564
|
return request.postMultiPart(endpoints.speechToText(), data);
|
|
348
565
|
};
|
|
@@ -359,52 +576,14 @@ export const getCustomConfigSpeech = (): Promise<t.TCustomConfigSpeechResponse>
|
|
|
359
576
|
return request.get(endpoints.getCustomConfigSpeech());
|
|
360
577
|
};
|
|
361
578
|
|
|
362
|
-
/*
|
|
363
|
-
|
|
364
|
-
export const updateAction = (data: m.UpdateActionVariables): Promise<m.UpdateActionResponse> => {
|
|
365
|
-
const { assistant_id, version, ...body } = data;
|
|
366
|
-
return request.post(
|
|
367
|
-
endpoints.assistants({
|
|
368
|
-
path: `actions/${assistant_id}`,
|
|
369
|
-
version,
|
|
370
|
-
}),
|
|
371
|
-
body,
|
|
372
|
-
);
|
|
373
|
-
};
|
|
579
|
+
/* conversations */
|
|
374
580
|
|
|
375
|
-
export function
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
endpoint: s.AssistantsEndpoint;
|
|
380
|
-
version: number | string;
|
|
381
|
-
}): Promise<a.Action[]> {
|
|
382
|
-
return request.get(
|
|
383
|
-
endpoints.assistants({
|
|
384
|
-
path: 'actions',
|
|
385
|
-
version,
|
|
386
|
-
endpoint,
|
|
387
|
-
}),
|
|
388
|
-
);
|
|
581
|
+
export function duplicateConversation(
|
|
582
|
+
payload: t.TDuplicateConvoRequest,
|
|
583
|
+
): Promise<t.TDuplicateConvoResponse> {
|
|
584
|
+
return request.post(endpoints.duplicateConversation(), payload);
|
|
389
585
|
}
|
|
390
586
|
|
|
391
|
-
export const deleteAction = async ({
|
|
392
|
-
assistant_id,
|
|
393
|
-
action_id,
|
|
394
|
-
model,
|
|
395
|
-
version,
|
|
396
|
-
endpoint,
|
|
397
|
-
}: m.DeleteActionVariables & { version: number | string }): Promise<void> =>
|
|
398
|
-
request.delete(
|
|
399
|
-
endpoints.assistants({
|
|
400
|
-
path: `actions/${assistant_id}/${action_id}/${model}`,
|
|
401
|
-
version,
|
|
402
|
-
endpoint,
|
|
403
|
-
}),
|
|
404
|
-
);
|
|
405
|
-
|
|
406
|
-
/* conversations */
|
|
407
|
-
|
|
408
587
|
export function forkConversation(payload: t.TForkConvoRequest): Promise<t.TForkConvoResponse> {
|
|
409
588
|
return request.post(endpoints.forkConversation(), payload);
|
|
410
589
|
}
|
|
@@ -422,16 +601,17 @@ export const listConversations = (
|
|
|
422
601
|
params?: q.ConversationListParams,
|
|
423
602
|
): Promise<q.ConversationListResponse> => {
|
|
424
603
|
// Assuming params has a pageNumber property
|
|
425
|
-
const pageNumber = params?.pageNumber || '1'; // Default to page 1 if not provided
|
|
426
|
-
const isArchived = params?.isArchived
|
|
427
|
-
|
|
604
|
+
const pageNumber = (params?.pageNumber ?? '1') || '1'; // Default to page 1 if not provided
|
|
605
|
+
const isArchived = params?.isArchived ?? false; // Default to false if not provided
|
|
606
|
+
const tags = params?.tags || []; // Default to an empty array if not provided
|
|
607
|
+
return request.get(endpoints.conversations(pageNumber, isArchived, tags));
|
|
428
608
|
};
|
|
429
609
|
|
|
430
610
|
export const listConversationsByQuery = (
|
|
431
611
|
params?: q.ConversationListParams & { searchQuery?: string },
|
|
432
612
|
): Promise<q.ConversationListResponse> => {
|
|
433
|
-
const pageNumber = params?.pageNumber || '1'; // Default to page 1 if not provided
|
|
434
|
-
const searchQuery = params?.searchQuery
|
|
613
|
+
const pageNumber = (params?.pageNumber ?? '1') || '1'; // Default to page 1 if not provided
|
|
614
|
+
const searchQuery = params?.searchQuery ?? ''; // If no search query is provided, default to an empty string
|
|
435
615
|
// Update the endpoint to handle a search query
|
|
436
616
|
if (searchQuery !== '') {
|
|
437
617
|
return request.get(endpoints.search(searchQuery, pageNumber));
|
|
@@ -538,6 +718,89 @@ export function getRole(roleName: string): Promise<r.TRole> {
|
|
|
538
718
|
|
|
539
719
|
export function updatePromptPermissions(
|
|
540
720
|
variables: m.UpdatePromptPermVars,
|
|
541
|
-
): Promise<m.
|
|
721
|
+
): Promise<m.UpdatePermResponse> {
|
|
542
722
|
return request.put(endpoints.updatePromptPermissions(variables.roleName), variables.updates);
|
|
543
723
|
}
|
|
724
|
+
|
|
725
|
+
export function updateAgentPermissions(
|
|
726
|
+
variables: m.UpdateAgentPermVars,
|
|
727
|
+
): Promise<m.UpdatePermResponse> {
|
|
728
|
+
return request.put(endpoints.updateAgentPermissions(variables.roleName), variables.updates);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/* Tags */
|
|
732
|
+
export function getConversationTags(): Promise<t.TConversationTagsResponse> {
|
|
733
|
+
return request.get(endpoints.conversationTags());
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
export function createConversationTag(
|
|
737
|
+
payload: t.TConversationTagRequest,
|
|
738
|
+
): Promise<t.TConversationTagResponse> {
|
|
739
|
+
return request.post(endpoints.conversationTags(), payload);
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
export function updateConversationTag(
|
|
743
|
+
tag: string,
|
|
744
|
+
payload: t.TConversationTagRequest,
|
|
745
|
+
): Promise<t.TConversationTagResponse> {
|
|
746
|
+
return request.put(endpoints.conversationTags(tag), payload);
|
|
747
|
+
}
|
|
748
|
+
export function deleteConversationTag(tag: string): Promise<t.TConversationTagResponse> {
|
|
749
|
+
return request.delete(endpoints.conversationTags(tag));
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
export function addTagToConversation(
|
|
753
|
+
conversationId: string,
|
|
754
|
+
payload: t.TTagConversationRequest,
|
|
755
|
+
): Promise<t.TTagConversationResponse> {
|
|
756
|
+
return request.put(endpoints.addTagToConversation(conversationId), payload);
|
|
757
|
+
}
|
|
758
|
+
export function rebuildConversationTags(): Promise<t.TConversationTagsResponse> {
|
|
759
|
+
return request.post(endpoints.conversationTags('rebuild'));
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
export function healthCheck(): Promise<string> {
|
|
763
|
+
return request.get(endpoints.health());
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
export function getUserTerms(): Promise<t.TUserTermsResponse> {
|
|
767
|
+
return request.get(endpoints.userTerms());
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
export function acceptTerms(): Promise<t.TAcceptTermsResponse> {
|
|
771
|
+
return request.post(endpoints.acceptUserTerms());
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
export function getBanner(): Promise<t.TBannerResponse> {
|
|
775
|
+
return request.get(endpoints.banner());
|
|
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
|
+
}
|
package/src/file-config.ts
CHANGED
|
@@ -8,9 +8,11 @@ export const supportsFiles = {
|
|
|
8
8
|
[EModelEndpoint.google]: true,
|
|
9
9
|
[EModelEndpoint.assistants]: true,
|
|
10
10
|
[EModelEndpoint.azureAssistants]: true,
|
|
11
|
+
[EModelEndpoint.agents]: true,
|
|
11
12
|
[EModelEndpoint.azureOpenAI]: true,
|
|
12
13
|
[EModelEndpoint.anthropic]: true,
|
|
13
14
|
[EModelEndpoint.custom]: true,
|
|
15
|
+
[EModelEndpoint.bedrock]: true,
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
export const excelFileTypes = [
|
|
@@ -43,6 +45,7 @@ export const fullMimeTypesList = [
|
|
|
43
45
|
'text/x-tex',
|
|
44
46
|
'text/plain',
|
|
45
47
|
'text/css',
|
|
48
|
+
'text/vtt',
|
|
46
49
|
'image/jpeg',
|
|
47
50
|
'text/javascript',
|
|
48
51
|
'image/gif',
|
|
@@ -51,6 +54,8 @@ export const fullMimeTypesList = [
|
|
|
51
54
|
'application/typescript',
|
|
52
55
|
'application/xml',
|
|
53
56
|
'application/zip',
|
|
57
|
+
'image/svg',
|
|
58
|
+
'image/svg+xml',
|
|
54
59
|
...excelFileTypes,
|
|
55
60
|
];
|
|
56
61
|
|
|
@@ -107,7 +112,7 @@ export const excelMimeTypes =
|
|
|
107
112
|
/^application\/(vnd\.ms-excel|msexcel|x-msexcel|x-ms-excel|x-excel|x-dos_ms_excel|xls|x-xls|vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet)$/;
|
|
108
113
|
|
|
109
114
|
export const textMimeTypes =
|
|
110
|
-
/^(text\/(x-c|x-c\+\+|x-java|html|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain|css|javascript|csv))$/;
|
|
115
|
+
/^(text\/(x-c|x-csharp|x-c\+\+|x-java|html|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain|css|vtt|javascript|csv))$/;
|
|
111
116
|
|
|
112
117
|
export const applicationMimeTypes =
|
|
113
118
|
/^(application\/(epub\+zip|csv|json|pdf|x-tar|typescript|vnd\.openxmlformats-officedocument\.(wordprocessingml\.document|presentationml\.presentation|spreadsheetml\.sheet)|xml|zip))$/;
|
|
@@ -119,6 +124,8 @@ export const supportedMimeTypes = [
|
|
|
119
124
|
excelMimeTypes,
|
|
120
125
|
applicationMimeTypes,
|
|
121
126
|
imageMimeTypes,
|
|
127
|
+
/** Supported by LC Code Interpreter PAI */
|
|
128
|
+
/^image\/(svg|svg\+xml)$/,
|
|
122
129
|
];
|
|
123
130
|
|
|
124
131
|
export const codeInterpreterMimeTypes = [
|
|
@@ -142,10 +149,13 @@ export const codeTypeMapping: { [key: string]: string } = {
|
|
|
142
149
|
ts: 'application/typescript',
|
|
143
150
|
tar: 'application/x-tar',
|
|
144
151
|
zip: 'application/zip',
|
|
152
|
+
yml: 'application/x-yaml',
|
|
153
|
+
yaml: 'application/x-yaml',
|
|
154
|
+
log: 'text/plain',
|
|
145
155
|
};
|
|
146
156
|
|
|
147
157
|
export const retrievalMimeTypes = [
|
|
148
|
-
/^(text\/(x-c|x-c\+\+|html|x-java|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain|xml))$/,
|
|
158
|
+
/^(text\/(x-c|x-c\+\+|html|x-java|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain|vtt|xml))$/,
|
|
149
159
|
/^(application\/(json|pdf|vnd\.openxmlformats-officedocument\.(wordprocessingml\.document|presentationml\.presentation)))$/,
|
|
150
160
|
];
|
|
151
161
|
|
|
@@ -166,6 +176,7 @@ export const fileConfig = {
|
|
|
166
176
|
endpoints: {
|
|
167
177
|
[EModelEndpoint.assistants]: assistantsFileConfig,
|
|
168
178
|
[EModelEndpoint.azureAssistants]: assistantsFileConfig,
|
|
179
|
+
[EModelEndpoint.agents]: assistantsFileConfig,
|
|
169
180
|
default: {
|
|
170
181
|
fileLimit: 10,
|
|
171
182
|
fileSizeLimit: defaultSizeLimit,
|