librechat-data-provider 0.4.0 → 0.4.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/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 +2 -1
- package/package.json +4 -1
- package/specs/actions.spec.ts +475 -0
- package/specs/filetypes.spec.ts +181 -0
- package/specs/openapiSpecs.ts +350 -0
- package/src/actions.ts +347 -0
- package/src/config.ts +125 -12
- package/src/createPayload.ts +1 -5
- package/src/data-service.ts +39 -2
- package/src/file-config.ts +264 -0
- package/src/index.ts +2 -0
- package/src/keys.ts +8 -1
- package/src/parsers.ts +10 -10
- package/src/react-query/index.ts +0 -1
- package/src/react-query/react-query-service.ts +16 -1
- package/src/schemas.ts +31 -14
- package/src/types/assistants.ts +255 -3
- package/src/types/files.ts +46 -13
- package/src/types/mutations.ts +90 -1
- package/src/types.ts +6 -0
- package/tsconfig.spec.json +10 -0
- package/src/react-query/assistants.ts +0 -138
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import * as t from '../types';
|
|
10
10
|
import * as s from '../schemas';
|
|
11
11
|
import * as m from '../types/mutations';
|
|
12
|
+
import { defaultOrderQuery } from '../config';
|
|
12
13
|
import * as dataService from '../data-service';
|
|
13
14
|
import request from '../request';
|
|
14
15
|
import { QueryKeys } from '../keys';
|
|
@@ -136,6 +137,14 @@ export const useRevokeUserKeyMutation = (name: string): UseMutationResult<unknow
|
|
|
136
137
|
return useMutation(() => dataService.revokeUserKey(name), {
|
|
137
138
|
onSuccess: () => {
|
|
138
139
|
queryClient.invalidateQueries([QueryKeys.name]);
|
|
140
|
+
if (name === s.EModelEndpoint.assistants) {
|
|
141
|
+
queryClient.invalidateQueries([QueryKeys.assistants, defaultOrderQuery]);
|
|
142
|
+
queryClient.invalidateQueries([QueryKeys.assistantDocs]);
|
|
143
|
+
queryClient.invalidateQueries([QueryKeys.assistants]);
|
|
144
|
+
queryClient.invalidateQueries([QueryKeys.assistant]);
|
|
145
|
+
queryClient.invalidateQueries([QueryKeys.actions]);
|
|
146
|
+
queryClient.invalidateQueries([QueryKeys.tools]);
|
|
147
|
+
}
|
|
139
148
|
},
|
|
140
149
|
});
|
|
141
150
|
};
|
|
@@ -145,6 +154,12 @@ export const useRevokeAllUserKeysMutation = (): UseMutationResult<unknown> => {
|
|
|
145
154
|
return useMutation(() => dataService.revokeAllUserKeys(), {
|
|
146
155
|
onSuccess: () => {
|
|
147
156
|
queryClient.invalidateQueries([QueryKeys.name]);
|
|
157
|
+
queryClient.invalidateQueries([QueryKeys.assistants, defaultOrderQuery]);
|
|
158
|
+
queryClient.invalidateQueries([QueryKeys.assistantDocs]);
|
|
159
|
+
queryClient.invalidateQueries([QueryKeys.assistants]);
|
|
160
|
+
queryClient.invalidateQueries([QueryKeys.assistant]);
|
|
161
|
+
queryClient.invalidateQueries([QueryKeys.actions]);
|
|
162
|
+
queryClient.invalidateQueries([QueryKeys.tools]);
|
|
148
163
|
},
|
|
149
164
|
});
|
|
150
165
|
};
|
|
@@ -277,7 +292,7 @@ export const useLoginUserMutation = (): UseMutationResult<
|
|
|
277
292
|
localStorage.removeItem('lastSelectedModel');
|
|
278
293
|
localStorage.removeItem('lastSelectedTools');
|
|
279
294
|
localStorage.removeItem('filesToDelete');
|
|
280
|
-
localStorage.removeItem('lastAssistant');
|
|
295
|
+
// localStorage.removeItem('lastAssistant');
|
|
281
296
|
},
|
|
282
297
|
});
|
|
283
298
|
};
|
package/src/schemas.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import type { TMessageContentParts } from './types/assistants';
|
|
3
|
+
import type { TFile } from './types/files';
|
|
4
|
+
|
|
5
|
+
export const isUUID = z.string().uuid();
|
|
2
6
|
|
|
3
7
|
export enum EModelEndpoint {
|
|
4
8
|
azureOpenAI = 'azureOpenAI',
|
|
@@ -8,10 +12,22 @@ export enum EModelEndpoint {
|
|
|
8
12
|
google = 'google',
|
|
9
13
|
gptPlugins = 'gptPlugins',
|
|
10
14
|
anthropic = 'anthropic',
|
|
11
|
-
|
|
15
|
+
assistants = 'assistants',
|
|
12
16
|
custom = 'custom',
|
|
13
17
|
}
|
|
14
18
|
|
|
19
|
+
export const defaultAssistantFormValues = {
|
|
20
|
+
assistant: '',
|
|
21
|
+
id: '',
|
|
22
|
+
name: '',
|
|
23
|
+
description: '',
|
|
24
|
+
instructions: '',
|
|
25
|
+
model: 'gpt-3.5-turbo-1106',
|
|
26
|
+
functions: [],
|
|
27
|
+
code_interpreter: false,
|
|
28
|
+
retrieval: false,
|
|
29
|
+
};
|
|
30
|
+
|
|
15
31
|
export const endpointSettings = {
|
|
16
32
|
[EModelEndpoint.google]: {
|
|
17
33
|
model: {
|
|
@@ -153,21 +169,16 @@ export const tMessageSchema = z.object({
|
|
|
153
169
|
unfinished: z.boolean().optional(),
|
|
154
170
|
searchResult: z.boolean().optional(),
|
|
155
171
|
finish_reason: z.string().optional(),
|
|
172
|
+
/* assistant */
|
|
173
|
+
thread_id: z.string().optional(),
|
|
156
174
|
});
|
|
157
175
|
|
|
158
176
|
export type TMessage = z.input<typeof tMessageSchema> & {
|
|
159
177
|
children?: TMessage[];
|
|
160
178
|
plugin?: TResPlugin | null;
|
|
161
179
|
plugins?: TResPlugin[];
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
type?: string;
|
|
165
|
-
filename?: string;
|
|
166
|
-
preview?: string;
|
|
167
|
-
filepath?: string;
|
|
168
|
-
height?: number;
|
|
169
|
-
width?: number;
|
|
170
|
-
}[];
|
|
180
|
+
content?: TMessageContentParts[];
|
|
181
|
+
files?: Partial<TFile>[];
|
|
171
182
|
};
|
|
172
183
|
|
|
173
184
|
export const tConversationSchema = z.object({
|
|
@@ -204,16 +215,17 @@ export const tConversationSchema = z.object({
|
|
|
204
215
|
toneStyle: z.string().nullable().optional(),
|
|
205
216
|
maxOutputTokens: z.number().optional(),
|
|
206
217
|
agentOptions: tAgentOptionsSchema.nullable().optional(),
|
|
218
|
+
file_ids: z.array(z.string()).optional(),
|
|
207
219
|
/* vision */
|
|
208
220
|
resendImages: z.boolean().optional(),
|
|
209
221
|
imageDetail: eImageDetailSchema.optional(),
|
|
210
222
|
/* assistant */
|
|
211
223
|
assistant_id: z.string().optional(),
|
|
212
|
-
|
|
224
|
+
instructions: z.string().optional(),
|
|
225
|
+
/** Used to overwrite active conversation settings when saving a Preset */
|
|
226
|
+
presetOverride: z.record(z.unknown()).optional(),
|
|
213
227
|
});
|
|
214
228
|
|
|
215
|
-
export type TConversation = z.infer<typeof tConversationSchema>;
|
|
216
|
-
|
|
217
229
|
export const tPresetSchema = tConversationSchema
|
|
218
230
|
.omit({
|
|
219
231
|
conversationId: true,
|
|
@@ -246,6 +258,10 @@ export const tPresetUpdateSchema = tConversationSchema.merge(
|
|
|
246
258
|
|
|
247
259
|
export type TPreset = z.infer<typeof tPresetSchema>;
|
|
248
260
|
|
|
261
|
+
export type TConversation = z.infer<typeof tConversationSchema> & {
|
|
262
|
+
presetOverride?: Partial<TPreset>;
|
|
263
|
+
};
|
|
264
|
+
|
|
249
265
|
// type DefaultSchemaValues = Partial<typeof google>;
|
|
250
266
|
|
|
251
267
|
export const openAISchema = tConversationSchema
|
|
@@ -470,7 +486,8 @@ export const assistantSchema = tConversationSchema
|
|
|
470
486
|
.pick({
|
|
471
487
|
model: true,
|
|
472
488
|
assistant_id: true,
|
|
473
|
-
|
|
489
|
+
instructions: true,
|
|
490
|
+
promptPrefix: true,
|
|
474
491
|
})
|
|
475
492
|
.transform(removeNullishValues)
|
|
476
493
|
.catch(() => ({}));
|
package/src/types/assistants.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
+
|
|
3
|
+
export type Schema = OpenAPIV3.SchemaObject & { description?: string };
|
|
4
|
+
export type Reference = OpenAPIV3.ReferenceObject & { description?: string };
|
|
5
|
+
|
|
1
6
|
export type Metadata = {
|
|
2
7
|
[key: string]: unknown;
|
|
3
8
|
};
|
|
@@ -12,6 +17,15 @@ export type Tool = {
|
|
|
12
17
|
[type: string]: Tools;
|
|
13
18
|
};
|
|
14
19
|
|
|
20
|
+
export type FunctionTool = {
|
|
21
|
+
type: Tools;
|
|
22
|
+
function?: {
|
|
23
|
+
description: string;
|
|
24
|
+
name: string;
|
|
25
|
+
parameters: Record<string, unknown>;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
15
29
|
export type Assistant = {
|
|
16
30
|
id: string;
|
|
17
31
|
created_at: number;
|
|
@@ -22,7 +36,7 @@ export type Assistant = {
|
|
|
22
36
|
model: string;
|
|
23
37
|
name: string | null;
|
|
24
38
|
object: string;
|
|
25
|
-
tools:
|
|
39
|
+
tools: FunctionTool[];
|
|
26
40
|
};
|
|
27
41
|
|
|
28
42
|
export type AssistantCreateParams = {
|
|
@@ -32,7 +46,7 @@ export type AssistantCreateParams = {
|
|
|
32
46
|
instructions?: string | null;
|
|
33
47
|
metadata?: Metadata | null;
|
|
34
48
|
name?: string | null;
|
|
35
|
-
tools?:
|
|
49
|
+
tools?: Array<FunctionTool | string>;
|
|
36
50
|
};
|
|
37
51
|
|
|
38
52
|
export type AssistantUpdateParams = {
|
|
@@ -42,7 +56,7 @@ export type AssistantUpdateParams = {
|
|
|
42
56
|
instructions?: string | null;
|
|
43
57
|
metadata?: Metadata | null;
|
|
44
58
|
name?: string | null;
|
|
45
|
-
tools?:
|
|
59
|
+
tools?: Array<FunctionTool | string>;
|
|
46
60
|
};
|
|
47
61
|
|
|
48
62
|
export type AssistantListParams = {
|
|
@@ -70,3 +84,241 @@ export type File = {
|
|
|
70
84
|
object: string;
|
|
71
85
|
purpose: 'fine-tune' | 'fine-tune-results' | 'assistants' | 'assistants_output';
|
|
72
86
|
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Details of the Code Interpreter tool call the run step was involved in.
|
|
90
|
+
* Includes the tool call ID, the code interpreter definition, and the type of tool call.
|
|
91
|
+
*/
|
|
92
|
+
export type CodeToolCall = {
|
|
93
|
+
id: string; // The ID of the tool call.
|
|
94
|
+
code_interpreter: {
|
|
95
|
+
input: string; // The input to the Code Interpreter tool call.
|
|
96
|
+
outputs: Array<Record<string, unknown>>; // The outputs from the Code Interpreter tool call.
|
|
97
|
+
};
|
|
98
|
+
type: 'code_interpreter'; // The type of tool call, always 'code_interpreter'.
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Details of a Function tool call the run step was involved in.
|
|
103
|
+
* Includes the tool call ID, the function definition, and the type of tool call.
|
|
104
|
+
*/
|
|
105
|
+
export type FunctionToolCall = {
|
|
106
|
+
id: string; // The ID of the tool call object.
|
|
107
|
+
function: {
|
|
108
|
+
arguments: string; // The arguments passed to the function.
|
|
109
|
+
name: string; // The name of the function.
|
|
110
|
+
output: string | null; // The output of the function, null if not submitted.
|
|
111
|
+
};
|
|
112
|
+
type: 'function'; // The type of tool call, always 'function'.
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Details of a Retrieval tool call the run step was involved in.
|
|
117
|
+
* Includes the tool call ID and the type of tool call.
|
|
118
|
+
*/
|
|
119
|
+
export type RetrievalToolCall = {
|
|
120
|
+
id: string; // The ID of the tool call object.
|
|
121
|
+
retrieval: unknown; // An empty object for now.
|
|
122
|
+
type: 'retrieval'; // The type of tool call, always 'retrieval'.
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Details of the tool calls involved in a run step.
|
|
127
|
+
* Can be associated with one of three types of tools: `code_interpreter`, `retrieval`, or `function`.
|
|
128
|
+
*/
|
|
129
|
+
export type ToolCallsStepDetails = {
|
|
130
|
+
tool_calls: Array<CodeToolCall | RetrievalToolCall | FunctionToolCall>; // An array of tool calls the run step was involved in.
|
|
131
|
+
type: 'tool_calls'; // Always 'tool_calls'.
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export type ImageFile = {
|
|
135
|
+
/**
|
|
136
|
+
* The [File](https://platform.openai.com/docs/api-reference/files) ID of the image
|
|
137
|
+
* in the message content.
|
|
138
|
+
*/
|
|
139
|
+
file_id: string;
|
|
140
|
+
filename: string;
|
|
141
|
+
filepath: string;
|
|
142
|
+
height: number;
|
|
143
|
+
width: number;
|
|
144
|
+
/**
|
|
145
|
+
* Prompt used to generate the image if applicable.
|
|
146
|
+
*/
|
|
147
|
+
prompt?: string;
|
|
148
|
+
/**
|
|
149
|
+
* Additional metadata used to generate or about the image/tool_call.
|
|
150
|
+
*/
|
|
151
|
+
metadata?: Record<string, unknown>;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// FileCitation.ts
|
|
155
|
+
export type FileCitation = {
|
|
156
|
+
end_index: number;
|
|
157
|
+
file_citation: FileCitationDetails;
|
|
158
|
+
start_index: number;
|
|
159
|
+
text: string;
|
|
160
|
+
type: 'file_citation';
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export type FileCitationDetails = {
|
|
164
|
+
file_id: string;
|
|
165
|
+
quote: string;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export type FilePath = {
|
|
169
|
+
end_index: number;
|
|
170
|
+
file_path: FilePathDetails;
|
|
171
|
+
start_index: number;
|
|
172
|
+
text: string;
|
|
173
|
+
type: 'file_path';
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export type FilePathDetails = {
|
|
177
|
+
file_id: string;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export type Text = {
|
|
181
|
+
annotations?: Array<FileCitation | FilePath>;
|
|
182
|
+
value: string;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export enum ContentTypes {
|
|
186
|
+
TEXT = 'text',
|
|
187
|
+
TOOL_CALL = 'tool_call',
|
|
188
|
+
IMAGE_FILE = 'image_file',
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export enum StepTypes {
|
|
192
|
+
TOOL_CALLS = 'tool_calls',
|
|
193
|
+
MESSAGE_CREATION = 'message_creation',
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export enum ToolCallTypes {
|
|
197
|
+
FUNCTION = 'function',
|
|
198
|
+
RETRIEVAL = 'retrieval',
|
|
199
|
+
CODE_INTERPRETER = 'code_interpreter',
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export enum StepStatus {
|
|
203
|
+
IN_PROGRESS = 'in_progress',
|
|
204
|
+
CANCELLED = 'cancelled',
|
|
205
|
+
FAILED = 'failed',
|
|
206
|
+
COMPLETED = 'completed',
|
|
207
|
+
EXPIRED = 'expired',
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export enum MessageContentTypes {
|
|
211
|
+
TEXT = 'text',
|
|
212
|
+
IMAGE_FILE = 'image_file',
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
//enum for RunStatus
|
|
216
|
+
// The status of the run: queued, in_progress, requires_action, cancelling, cancelled, failed, completed, or expired.
|
|
217
|
+
export enum RunStatus {
|
|
218
|
+
QUEUED = 'queued',
|
|
219
|
+
IN_PROGRESS = 'in_progress',
|
|
220
|
+
REQUIRES_ACTION = 'requires_action',
|
|
221
|
+
CANCELLING = 'cancelling',
|
|
222
|
+
CANCELLED = 'cancelled',
|
|
223
|
+
FAILED = 'failed',
|
|
224
|
+
COMPLETED = 'completed',
|
|
225
|
+
EXPIRED = 'expired',
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export type PartMetadata = {
|
|
229
|
+
progress?: number;
|
|
230
|
+
asset_pointer?: string;
|
|
231
|
+
status?: string;
|
|
232
|
+
action?: boolean;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
export type ContentPart = (CodeToolCall | RetrievalToolCall | FunctionToolCall | ImageFile | Text) &
|
|
236
|
+
PartMetadata;
|
|
237
|
+
|
|
238
|
+
export type TMessageContentParts =
|
|
239
|
+
| { type: ContentTypes.TEXT; text: Text & PartMetadata }
|
|
240
|
+
| {
|
|
241
|
+
type: ContentTypes.TOOL_CALL;
|
|
242
|
+
tool_call: (CodeToolCall | RetrievalToolCall | FunctionToolCall) & PartMetadata;
|
|
243
|
+
}
|
|
244
|
+
| { type: ContentTypes.IMAGE_FILE; image_file: ImageFile & PartMetadata };
|
|
245
|
+
|
|
246
|
+
export type TContentData = TMessageContentParts & {
|
|
247
|
+
messageId: string;
|
|
248
|
+
conversationId: string;
|
|
249
|
+
userMessageId: string;
|
|
250
|
+
thread_id: string;
|
|
251
|
+
index: number;
|
|
252
|
+
stream?: boolean;
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
export const actionDelimiter = '_action_';
|
|
256
|
+
|
|
257
|
+
export enum AuthTypeEnum {
|
|
258
|
+
ServiceHttp = 'service_http',
|
|
259
|
+
OAuth = 'oauth',
|
|
260
|
+
None = 'none',
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export enum AuthorizationTypeEnum {
|
|
264
|
+
Bearer = 'bearer',
|
|
265
|
+
Basic = 'basic',
|
|
266
|
+
Custom = 'custom',
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export enum TokenExchangeMethodEnum {
|
|
270
|
+
DefaultPost = 'default_post',
|
|
271
|
+
BasicAuthHeader = 'basic_auth_header',
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export type ActionAuth = {
|
|
275
|
+
authorization_type?: AuthorizationTypeEnum;
|
|
276
|
+
custom_auth_header?: string;
|
|
277
|
+
type?: AuthTypeEnum;
|
|
278
|
+
authorization_content_type?: string;
|
|
279
|
+
authorization_url?: string;
|
|
280
|
+
client_url?: string;
|
|
281
|
+
scope?: string;
|
|
282
|
+
token_exchange_method?: TokenExchangeMethodEnum;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
export type ActionMetadata = {
|
|
286
|
+
api_key?: string;
|
|
287
|
+
auth?: ActionAuth;
|
|
288
|
+
domain?: string;
|
|
289
|
+
privacy_policy_url?: string;
|
|
290
|
+
raw_spec?: string;
|
|
291
|
+
oauth_client_id?: string;
|
|
292
|
+
oauth_client_secret?: string;
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
export type Action = {
|
|
296
|
+
action_id: string;
|
|
297
|
+
assistant_id: string;
|
|
298
|
+
type?: string;
|
|
299
|
+
settings?: Record<string, unknown>;
|
|
300
|
+
metadata: ActionMetadata;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
export type AssistantAvatar = {
|
|
304
|
+
filepath: string;
|
|
305
|
+
source: string;
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
export type AssistantDocument = {
|
|
309
|
+
user: string;
|
|
310
|
+
assistant_id: string;
|
|
311
|
+
avatar?: AssistantAvatar;
|
|
312
|
+
access_level?: number;
|
|
313
|
+
file_ids?: string[];
|
|
314
|
+
actions?: string[];
|
|
315
|
+
createdAt?: Date;
|
|
316
|
+
updatedAt?: Date;
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
export enum FilePurpose {
|
|
320
|
+
FineTune = 'fine-tune',
|
|
321
|
+
FineTuneResults = 'fine-tune-results',
|
|
322
|
+
Assistants = 'assistants',
|
|
323
|
+
AssistantsOutput = 'assistants_output',
|
|
324
|
+
}
|
package/src/types/files.ts
CHANGED
|
@@ -5,17 +5,54 @@ export enum FileSources {
|
|
|
5
5
|
s3 = 's3',
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
export enum FileContext {
|
|
9
|
+
avatar = 'avatar',
|
|
10
|
+
unknown = 'unknown',
|
|
11
|
+
assistants = 'assistants',
|
|
12
|
+
image_generation = 'image_generation',
|
|
13
|
+
assistants_output = 'assistants_output',
|
|
14
|
+
message_attachment = 'message_attachment',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type EndpointFileConfig = {
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
fileLimit?: number;
|
|
20
|
+
fileSizeLimit?: number;
|
|
21
|
+
totalSizeLimit?: number;
|
|
22
|
+
supportedMimeTypes?: RegExp[];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type FileConfig = {
|
|
26
|
+
endpoints: {
|
|
27
|
+
[key: string]: EndpointFileConfig;
|
|
28
|
+
};
|
|
29
|
+
serverFileSizeLimit?: number;
|
|
30
|
+
avatarSizeLimit?: number;
|
|
31
|
+
checkType?: (fileType: string, supportedTypes: RegExp[]) => boolean;
|
|
32
|
+
};
|
|
33
|
+
|
|
8
34
|
export type TFile = {
|
|
9
|
-
|
|
35
|
+
_id?: string;
|
|
36
|
+
__v?: number;
|
|
37
|
+
user: string;
|
|
38
|
+
conversationId?: string;
|
|
39
|
+
message?: string;
|
|
10
40
|
file_id: string;
|
|
11
|
-
|
|
41
|
+
temp_file_id?: string;
|
|
42
|
+
bytes: number;
|
|
12
43
|
filename: string;
|
|
44
|
+
filepath: string;
|
|
45
|
+
object: 'file';
|
|
13
46
|
type: string;
|
|
14
|
-
|
|
15
|
-
|
|
47
|
+
usage: number;
|
|
48
|
+
context?: FileContext;
|
|
16
49
|
source?: FileSources;
|
|
17
|
-
height?: number;
|
|
18
50
|
width?: number;
|
|
51
|
+
height?: number;
|
|
52
|
+
expiresAt?: string | Date;
|
|
53
|
+
preview?: string;
|
|
54
|
+
createdAt?: string | Date;
|
|
55
|
+
updatedAt?: string | Date;
|
|
19
56
|
};
|
|
20
57
|
|
|
21
58
|
export type TFileUpload = TFile & {
|
|
@@ -26,15 +63,10 @@ export type AvatarUploadResponse = {
|
|
|
26
63
|
url: string;
|
|
27
64
|
};
|
|
28
65
|
|
|
29
|
-
export type FileUploadBody = {
|
|
30
|
-
formData: FormData;
|
|
31
|
-
file_id: string;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
66
|
export type UploadMutationOptions = {
|
|
35
|
-
onSuccess?: (data: TFileUpload, variables:
|
|
36
|
-
onMutate?: (variables:
|
|
37
|
-
onError?: (error: unknown, variables:
|
|
67
|
+
onSuccess?: (data: TFileUpload, variables: FormData, context?: unknown) => void;
|
|
68
|
+
onMutate?: (variables: FormData) => void | Promise<unknown>;
|
|
69
|
+
onError?: (error: unknown, variables: FormData, context?: unknown) => void;
|
|
38
70
|
};
|
|
39
71
|
|
|
40
72
|
export type UploadAvatarOptions = {
|
|
@@ -56,6 +88,7 @@ export type BatchFile = {
|
|
|
56
88
|
|
|
57
89
|
export type DeleteFilesBody = {
|
|
58
90
|
files: BatchFile[];
|
|
91
|
+
assistant_id?: string;
|
|
59
92
|
};
|
|
60
93
|
|
|
61
94
|
export type DeleteMutationOptions = {
|
package/src/types/mutations.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import { TPreset } from '../types';
|
|
1
|
+
import { TPreset, TDeleteConversationResponse, TDeleteConversationRequest } from '../types';
|
|
2
|
+
import {
|
|
3
|
+
Assistant,
|
|
4
|
+
AssistantCreateParams,
|
|
5
|
+
AssistantUpdateParams,
|
|
6
|
+
ActionMetadata,
|
|
7
|
+
FunctionTool,
|
|
8
|
+
AssistantDocument,
|
|
9
|
+
Action,
|
|
10
|
+
} from './assistants';
|
|
2
11
|
|
|
3
12
|
export type TGenTitleRequest = {
|
|
4
13
|
conversationId: string;
|
|
@@ -34,3 +43,83 @@ export type LogoutOptions = {
|
|
|
34
43
|
onMutate?: (variables: undefined) => void | Promise<unknown>;
|
|
35
44
|
onError?: (error: unknown, variables: undefined, context?: unknown) => void;
|
|
36
45
|
};
|
|
46
|
+
|
|
47
|
+
export type AssistantAvatarVariables = {
|
|
48
|
+
assistant_id: string;
|
|
49
|
+
formData: FormData;
|
|
50
|
+
postCreation?: boolean;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type UpdateActionVariables = {
|
|
54
|
+
assistant_id: string;
|
|
55
|
+
functions: FunctionTool[];
|
|
56
|
+
metadata: ActionMetadata;
|
|
57
|
+
action_id?: string;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type UploadAssistantAvatarOptions = {
|
|
61
|
+
onSuccess?: (data: Assistant, variables: AssistantAvatarVariables, context?: unknown) => void;
|
|
62
|
+
onMutate?: (variables: AssistantAvatarVariables) => void | Promise<unknown>;
|
|
63
|
+
onError?: (error: unknown, variables: AssistantAvatarVariables, context?: unknown) => void;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export type CreateAssistantMutationOptions = {
|
|
67
|
+
onSuccess?: (data: Assistant, variables: AssistantCreateParams, context?: unknown) => void;
|
|
68
|
+
onMutate?: (variables: AssistantCreateParams) => void | Promise<unknown>;
|
|
69
|
+
onError?: (error: unknown, variables: AssistantCreateParams, context?: unknown) => void;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type UpdateAssistantMutationOptions = {
|
|
73
|
+
onSuccess?: (
|
|
74
|
+
data: Assistant,
|
|
75
|
+
variables: { assistant_id: string; data: AssistantUpdateParams },
|
|
76
|
+
context?: unknown,
|
|
77
|
+
) => void;
|
|
78
|
+
onMutate?: (variables: {
|
|
79
|
+
assistant_id: string;
|
|
80
|
+
data: AssistantUpdateParams;
|
|
81
|
+
}) => void | Promise<unknown>;
|
|
82
|
+
onError?: (
|
|
83
|
+
error: unknown,
|
|
84
|
+
variables: { assistant_id: string; data: AssistantUpdateParams },
|
|
85
|
+
context?: unknown,
|
|
86
|
+
) => void;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export type DeleteAssistantMutationOptions = {
|
|
90
|
+
onSuccess?: (data: void, variables: { assistant_id: string }, context?: unknown) => void;
|
|
91
|
+
onMutate?: (variables: { assistant_id: string }) => void | Promise<unknown>;
|
|
92
|
+
onError?: (error: unknown, variables: { assistant_id: string }, context?: unknown) => void;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export type UpdateActionResponse = [AssistantDocument, Assistant, Action];
|
|
96
|
+
export type UpdateActionOptions = {
|
|
97
|
+
onSuccess?: (
|
|
98
|
+
data: UpdateActionResponse,
|
|
99
|
+
variables: UpdateActionVariables,
|
|
100
|
+
context?: unknown,
|
|
101
|
+
) => void;
|
|
102
|
+
onMutate?: (variables: UpdateActionVariables) => void | Promise<unknown>;
|
|
103
|
+
onError?: (error: unknown, variables: UpdateActionVariables, context?: unknown) => void;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export type DeleteActionVariables = {
|
|
107
|
+
assistant_id: string;
|
|
108
|
+
action_id: string;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export type DeleteActionOptions = {
|
|
112
|
+
onSuccess?: (data: void, variables: DeleteActionVariables, context?: unknown) => void;
|
|
113
|
+
onMutate?: (variables: DeleteActionVariables) => void | Promise<unknown>;
|
|
114
|
+
onError?: (error: unknown, variables: DeleteActionVariables, context?: unknown) => void;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export type DeleteConversationOptions = {
|
|
118
|
+
onSuccess?: (
|
|
119
|
+
data: TDeleteConversationResponse,
|
|
120
|
+
variables: TDeleteConversationRequest,
|
|
121
|
+
context?: unknown,
|
|
122
|
+
) => void;
|
|
123
|
+
onMutate?: (variables: TDeleteConversationRequest) => void | Promise<unknown>;
|
|
124
|
+
onError?: (error: unknown, variables: TDeleteConversationRequest, context?: unknown) => void;
|
|
125
|
+
};
|
package/src/types.ts
CHANGED
|
@@ -25,6 +25,8 @@ export type TEndpointOption = {
|
|
|
25
25
|
modelLabel?: string | null;
|
|
26
26
|
jailbreak?: boolean;
|
|
27
27
|
key?: string | null;
|
|
28
|
+
/* assistant */
|
|
29
|
+
thread_id?: string;
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
export type TSubmission = {
|
|
@@ -45,11 +47,13 @@ export type TPluginAction = {
|
|
|
45
47
|
pluginKey: string;
|
|
46
48
|
action: 'install' | 'uninstall';
|
|
47
49
|
auth?: unknown;
|
|
50
|
+
isAssistantTool?: boolean;
|
|
48
51
|
};
|
|
49
52
|
|
|
50
53
|
export type GroupedConversations = [key: string, TConversation[]][];
|
|
51
54
|
|
|
52
55
|
export type TUpdateUserPlugins = {
|
|
56
|
+
isAssistantTool?: boolean;
|
|
53
57
|
pluginKey: string;
|
|
54
58
|
action: string;
|
|
55
59
|
auth?: unknown;
|
|
@@ -108,6 +112,7 @@ export type TUpdateConversationResponse = TConversation;
|
|
|
108
112
|
|
|
109
113
|
export type TDeleteConversationRequest = {
|
|
110
114
|
conversationId?: string;
|
|
115
|
+
thread_id?: string;
|
|
111
116
|
source?: string;
|
|
112
117
|
};
|
|
113
118
|
|
|
@@ -140,6 +145,7 @@ export type TConfig = {
|
|
|
140
145
|
modelDisplayLabel?: string;
|
|
141
146
|
userProvide?: boolean | null;
|
|
142
147
|
userProvideURL?: boolean | null;
|
|
148
|
+
disableBuilder?: boolean;
|
|
143
149
|
};
|
|
144
150
|
|
|
145
151
|
export type TEndpointsConfig =
|