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/schemas.ts
CHANGED
|
@@ -8,7 +8,7 @@ export const isUUID = z.string().uuid();
|
|
|
8
8
|
export enum AuthType {
|
|
9
9
|
OVERRIDE_AUTH = 'override_auth',
|
|
10
10
|
USER_PROVIDED = 'user_provided',
|
|
11
|
-
SYSTEM_DEFINED = '
|
|
11
|
+
SYSTEM_DEFINED = 'system_defined',
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const authTypeSchema = z.nativeEnum(AuthType);
|
|
@@ -16,31 +16,104 @@ export const authTypeSchema = z.nativeEnum(AuthType);
|
|
|
16
16
|
export enum EModelEndpoint {
|
|
17
17
|
azureOpenAI = 'azureOpenAI',
|
|
18
18
|
openAI = 'openAI',
|
|
19
|
-
bingAI = 'bingAI',
|
|
20
|
-
chatGPTBrowser = 'chatGPTBrowser',
|
|
21
19
|
google = 'google',
|
|
22
|
-
gptPlugins = 'gptPlugins',
|
|
23
20
|
anthropic = 'anthropic',
|
|
24
21
|
assistants = 'assistants',
|
|
25
22
|
azureAssistants = 'azureAssistants',
|
|
23
|
+
agents = 'agents',
|
|
26
24
|
custom = 'custom',
|
|
25
|
+
bedrock = 'bedrock',
|
|
26
|
+
/** @deprecated */
|
|
27
|
+
chatGPTBrowser = 'chatGPTBrowser',
|
|
28
|
+
/** @deprecated */
|
|
29
|
+
gptPlugins = 'gptPlugins',
|
|
27
30
|
}
|
|
28
31
|
|
|
32
|
+
export const paramEndpoints = new Set<EModelEndpoint | string>([
|
|
33
|
+
EModelEndpoint.agents,
|
|
34
|
+
EModelEndpoint.openAI,
|
|
35
|
+
EModelEndpoint.bedrock,
|
|
36
|
+
EModelEndpoint.azureOpenAI,
|
|
37
|
+
EModelEndpoint.anthropic,
|
|
38
|
+
EModelEndpoint.custom,
|
|
39
|
+
EModelEndpoint.google,
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
export enum BedrockProviders {
|
|
43
|
+
AI21 = 'ai21',
|
|
44
|
+
Amazon = 'amazon',
|
|
45
|
+
Anthropic = 'anthropic',
|
|
46
|
+
Cohere = 'cohere',
|
|
47
|
+
Meta = 'meta',
|
|
48
|
+
MistralAI = 'mistral',
|
|
49
|
+
StabilityAI = 'stability',
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const getModelKey = (endpoint: EModelEndpoint | string, model: string) => {
|
|
53
|
+
if (endpoint === EModelEndpoint.bedrock) {
|
|
54
|
+
const parts = model.split('.');
|
|
55
|
+
const provider = [parts[0], parts[1]].find((part) =>
|
|
56
|
+
Object.values(BedrockProviders).includes(part as BedrockProviders),
|
|
57
|
+
);
|
|
58
|
+
return (provider ?? parts[0]) as BedrockProviders;
|
|
59
|
+
}
|
|
60
|
+
return model;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const getSettingsKeys = (endpoint: EModelEndpoint | string, model: string) => {
|
|
64
|
+
const endpointKey = endpoint;
|
|
65
|
+
const modelKey = getModelKey(endpointKey, model);
|
|
66
|
+
const combinedKey = `${endpointKey}-${modelKey}`;
|
|
67
|
+
return [combinedKey, endpointKey];
|
|
68
|
+
};
|
|
69
|
+
|
|
29
70
|
export type AssistantsEndpoint = EModelEndpoint.assistants | EModelEndpoint.azureAssistants;
|
|
30
71
|
|
|
31
|
-
export const isAssistantsEndpoint = (
|
|
72
|
+
export const isAssistantsEndpoint = (_endpoint?: AssistantsEndpoint | null | string): boolean => {
|
|
73
|
+
const endpoint = _endpoint ?? '';
|
|
32
74
|
if (!endpoint) {
|
|
33
75
|
return false;
|
|
34
76
|
}
|
|
35
77
|
return endpoint.toLowerCase().endsWith(EModelEndpoint.assistants);
|
|
36
78
|
};
|
|
37
79
|
|
|
80
|
+
export type AgentProvider = Exclude<keyof typeof EModelEndpoint, EModelEndpoint.agents> | string;
|
|
81
|
+
|
|
82
|
+
export const isAgentsEndpoint = (_endpoint?: EModelEndpoint.agents | null | string): boolean => {
|
|
83
|
+
const endpoint = _endpoint ?? '';
|
|
84
|
+
if (!endpoint) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return endpoint === EModelEndpoint.agents;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const isParamEndpoint = (
|
|
91
|
+
endpoint: EModelEndpoint | string,
|
|
92
|
+
endpointType?: EModelEndpoint | string,
|
|
93
|
+
): boolean => {
|
|
94
|
+
if (paramEndpoints.has(endpoint)) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (endpointType != null) {
|
|
99
|
+
return paramEndpoints.has(endpointType);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return false;
|
|
103
|
+
};
|
|
104
|
+
|
|
38
105
|
export enum ImageDetail {
|
|
39
106
|
low = 'low',
|
|
40
107
|
auto = 'auto',
|
|
41
108
|
high = 'high',
|
|
42
109
|
}
|
|
43
110
|
|
|
111
|
+
export enum ReasoningEffort {
|
|
112
|
+
low = 'low',
|
|
113
|
+
medium = 'medium',
|
|
114
|
+
high = 'high',
|
|
115
|
+
}
|
|
116
|
+
|
|
44
117
|
export const imageDetailNumeric = {
|
|
45
118
|
[ImageDetail.low]: 0,
|
|
46
119
|
[ImageDetail.auto]: 1,
|
|
@@ -54,6 +127,7 @@ export const imageDetailValue = {
|
|
|
54
127
|
};
|
|
55
128
|
|
|
56
129
|
export const eImageDetailSchema = z.nativeEnum(ImageDetail);
|
|
130
|
+
export const eReasoningEffortSchema = z.nativeEnum(ReasoningEffort);
|
|
57
131
|
|
|
58
132
|
export const defaultAssistantFormValues = {
|
|
59
133
|
assistant: '',
|
|
@@ -61,11 +135,30 @@ export const defaultAssistantFormValues = {
|
|
|
61
135
|
name: '',
|
|
62
136
|
description: '',
|
|
63
137
|
instructions: '',
|
|
138
|
+
conversation_starters: [],
|
|
64
139
|
model: '',
|
|
65
140
|
functions: [],
|
|
66
141
|
code_interpreter: false,
|
|
67
142
|
image_vision: false,
|
|
68
143
|
retrieval: false,
|
|
144
|
+
append_current_datetime: false,
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export const defaultAgentFormValues = {
|
|
148
|
+
agent: {},
|
|
149
|
+
id: '',
|
|
150
|
+
name: '',
|
|
151
|
+
description: '',
|
|
152
|
+
instructions: '',
|
|
153
|
+
model: '',
|
|
154
|
+
model_parameters: {},
|
|
155
|
+
tools: [],
|
|
156
|
+
provider: {},
|
|
157
|
+
projectIds: [],
|
|
158
|
+
artifacts: '',
|
|
159
|
+
isCollaborative: false,
|
|
160
|
+
[Tools.execute_code]: false,
|
|
161
|
+
[Tools.file_search]: false,
|
|
69
162
|
};
|
|
70
163
|
|
|
71
164
|
export const ImageVisionTool: FunctionTool = {
|
|
@@ -82,38 +175,38 @@ export const ImageVisionTool: FunctionTool = {
|
|
|
82
175
|
};
|
|
83
176
|
|
|
84
177
|
export const isImageVisionTool = (tool: FunctionTool | FunctionToolCall) =>
|
|
85
|
-
tool.type === 'function' && tool.function?.name === ImageVisionTool
|
|
178
|
+
tool.type === 'function' && tool.function?.name === ImageVisionTool.function?.name;
|
|
86
179
|
|
|
87
180
|
export const openAISettings = {
|
|
88
181
|
model: {
|
|
89
|
-
default: 'gpt-4o',
|
|
182
|
+
default: 'gpt-4o-mini' as const,
|
|
90
183
|
},
|
|
91
184
|
temperature: {
|
|
92
|
-
min: 0,
|
|
93
|
-
max:
|
|
94
|
-
step: 0.01,
|
|
95
|
-
default: 1,
|
|
185
|
+
min: 0 as const,
|
|
186
|
+
max: 2 as const,
|
|
187
|
+
step: 0.01 as const,
|
|
188
|
+
default: 1 as const,
|
|
96
189
|
},
|
|
97
190
|
top_p: {
|
|
98
|
-
min: 0,
|
|
99
|
-
max: 1,
|
|
100
|
-
step: 0.01,
|
|
101
|
-
default: 1,
|
|
191
|
+
min: 0 as const,
|
|
192
|
+
max: 1 as const,
|
|
193
|
+
step: 0.01 as const,
|
|
194
|
+
default: 1 as const,
|
|
102
195
|
},
|
|
103
196
|
presence_penalty: {
|
|
104
|
-
min: 0,
|
|
105
|
-
max: 2,
|
|
106
|
-
step: 0.01,
|
|
107
|
-
default: 0,
|
|
197
|
+
min: 0 as const,
|
|
198
|
+
max: 2 as const,
|
|
199
|
+
step: 0.01 as const,
|
|
200
|
+
default: 0 as const,
|
|
108
201
|
},
|
|
109
202
|
frequency_penalty: {
|
|
110
|
-
min: 0,
|
|
111
|
-
max: 2,
|
|
112
|
-
step: 0.01,
|
|
113
|
-
default: 0,
|
|
203
|
+
min: 0 as const,
|
|
204
|
+
max: 2 as const,
|
|
205
|
+
step: 0.01 as const,
|
|
206
|
+
default: 0 as const,
|
|
114
207
|
},
|
|
115
208
|
resendFiles: {
|
|
116
|
-
default: true,
|
|
209
|
+
default: true as const,
|
|
117
210
|
},
|
|
118
211
|
maxContextTokens: {
|
|
119
212
|
default: undefined,
|
|
@@ -122,66 +215,85 @@ export const openAISettings = {
|
|
|
122
215
|
default: undefined,
|
|
123
216
|
},
|
|
124
217
|
imageDetail: {
|
|
125
|
-
default: ImageDetail.auto,
|
|
218
|
+
default: ImageDetail.auto as const,
|
|
219
|
+
min: 0 as const,
|
|
220
|
+
max: 2 as const,
|
|
221
|
+
step: 1 as const,
|
|
126
222
|
},
|
|
127
223
|
};
|
|
128
224
|
|
|
129
225
|
export const googleSettings = {
|
|
130
226
|
model: {
|
|
131
|
-
default: 'gemini-1.5-flash-latest',
|
|
227
|
+
default: 'gemini-1.5-flash-latest' as const,
|
|
132
228
|
},
|
|
133
229
|
maxOutputTokens: {
|
|
134
|
-
min: 1,
|
|
135
|
-
max: 8192,
|
|
136
|
-
step: 1,
|
|
137
|
-
default: 8192,
|
|
230
|
+
min: 1 as const,
|
|
231
|
+
max: 8192 as const,
|
|
232
|
+
step: 1 as const,
|
|
233
|
+
default: 8192 as const,
|
|
138
234
|
},
|
|
139
235
|
temperature: {
|
|
140
|
-
min: 0,
|
|
141
|
-
max: 2,
|
|
142
|
-
step: 0.01,
|
|
143
|
-
default: 1,
|
|
236
|
+
min: 0 as const,
|
|
237
|
+
max: 2 as const,
|
|
238
|
+
step: 0.01 as const,
|
|
239
|
+
default: 1 as const,
|
|
144
240
|
},
|
|
145
241
|
topP: {
|
|
146
|
-
min: 0,
|
|
147
|
-
max: 1,
|
|
148
|
-
step: 0.01,
|
|
149
|
-
default: 0.95,
|
|
242
|
+
min: 0 as const,
|
|
243
|
+
max: 1 as const,
|
|
244
|
+
step: 0.01 as const,
|
|
245
|
+
default: 0.95 as const,
|
|
150
246
|
},
|
|
151
247
|
topK: {
|
|
152
|
-
min: 1,
|
|
153
|
-
max: 40,
|
|
154
|
-
step:
|
|
155
|
-
default: 40,
|
|
248
|
+
min: 1 as const,
|
|
249
|
+
max: 40 as const,
|
|
250
|
+
step: 1 as const,
|
|
251
|
+
default: 40 as const,
|
|
156
252
|
},
|
|
157
253
|
};
|
|
158
254
|
|
|
159
|
-
const ANTHROPIC_MAX_OUTPUT =
|
|
160
|
-
const
|
|
255
|
+
const ANTHROPIC_MAX_OUTPUT = 128000 as const;
|
|
256
|
+
const DEFAULT_MAX_OUTPUT = 8192 as const;
|
|
257
|
+
const LEGACY_ANTHROPIC_MAX_OUTPUT = 4096 as const;
|
|
161
258
|
export const anthropicSettings = {
|
|
162
259
|
model: {
|
|
163
|
-
default: 'claude-3-5-sonnet-
|
|
260
|
+
default: 'claude-3-5-sonnet-latest' as const,
|
|
164
261
|
},
|
|
165
262
|
temperature: {
|
|
166
|
-
min: 0,
|
|
167
|
-
max: 1,
|
|
168
|
-
step: 0.01,
|
|
169
|
-
default: 1,
|
|
263
|
+
min: 0 as const,
|
|
264
|
+
max: 1 as const,
|
|
265
|
+
step: 0.01 as const,
|
|
266
|
+
default: 1 as const,
|
|
267
|
+
},
|
|
268
|
+
promptCache: {
|
|
269
|
+
default: true as const,
|
|
270
|
+
},
|
|
271
|
+
thinking: {
|
|
272
|
+
default: true as const,
|
|
273
|
+
},
|
|
274
|
+
thinkingBudget: {
|
|
275
|
+
min: 1024 as const,
|
|
276
|
+
step: 100 as const,
|
|
277
|
+
max: 200000 as const,
|
|
278
|
+
default: 2000 as const,
|
|
170
279
|
},
|
|
171
280
|
maxOutputTokens: {
|
|
172
|
-
min: 1,
|
|
281
|
+
min: 1 as const,
|
|
173
282
|
max: ANTHROPIC_MAX_OUTPUT,
|
|
174
|
-
step: 1,
|
|
175
|
-
default:
|
|
283
|
+
step: 1 as const,
|
|
284
|
+
default: DEFAULT_MAX_OUTPUT,
|
|
176
285
|
reset: (modelName: string) => {
|
|
177
|
-
if (
|
|
178
|
-
return
|
|
286
|
+
if (/claude-3[-.]5-sonnet/.test(modelName) || /claude-3[-.]7/.test(modelName)) {
|
|
287
|
+
return DEFAULT_MAX_OUTPUT;
|
|
179
288
|
}
|
|
180
289
|
|
|
181
290
|
return 4096;
|
|
182
291
|
},
|
|
183
292
|
set: (value: number, modelName: string) => {
|
|
184
|
-
if (
|
|
293
|
+
if (
|
|
294
|
+
!(/claude-3[-.]5-sonnet/.test(modelName) || /claude-3[-.]7/.test(modelName)) &&
|
|
295
|
+
value > LEGACY_ANTHROPIC_MAX_OUTPUT
|
|
296
|
+
) {
|
|
185
297
|
return LEGACY_ANTHROPIC_MAX_OUTPUT;
|
|
186
298
|
}
|
|
187
299
|
|
|
@@ -189,37 +301,81 @@ export const anthropicSettings = {
|
|
|
189
301
|
},
|
|
190
302
|
},
|
|
191
303
|
topP: {
|
|
192
|
-
min: 0,
|
|
193
|
-
max: 1,
|
|
194
|
-
step: 0.01,
|
|
195
|
-
default: 0.7,
|
|
304
|
+
min: 0 as const,
|
|
305
|
+
max: 1 as const,
|
|
306
|
+
step: 0.01 as const,
|
|
307
|
+
default: 0.7 as const,
|
|
196
308
|
},
|
|
197
309
|
topK: {
|
|
198
|
-
min: 1,
|
|
199
|
-
max: 40,
|
|
200
|
-
step: 1,
|
|
201
|
-
default: 5,
|
|
310
|
+
min: 1 as const,
|
|
311
|
+
max: 40 as const,
|
|
312
|
+
step: 1 as const,
|
|
313
|
+
default: 5 as const,
|
|
202
314
|
},
|
|
203
315
|
resendFiles: {
|
|
204
|
-
default: true,
|
|
316
|
+
default: true as const,
|
|
205
317
|
},
|
|
206
318
|
maxContextTokens: {
|
|
207
319
|
default: undefined,
|
|
208
320
|
},
|
|
209
321
|
legacy: {
|
|
210
322
|
maxOutputTokens: {
|
|
211
|
-
min: 1,
|
|
323
|
+
min: 1 as const,
|
|
212
324
|
max: LEGACY_ANTHROPIC_MAX_OUTPUT,
|
|
213
|
-
step: 1,
|
|
325
|
+
step: 1 as const,
|
|
214
326
|
default: LEGACY_ANTHROPIC_MAX_OUTPUT,
|
|
215
327
|
},
|
|
216
328
|
},
|
|
217
329
|
};
|
|
218
330
|
|
|
331
|
+
export const agentsSettings = {
|
|
332
|
+
model: {
|
|
333
|
+
default: 'gpt-3.5-turbo-test' as const,
|
|
334
|
+
},
|
|
335
|
+
temperature: {
|
|
336
|
+
min: 0 as const,
|
|
337
|
+
max: 1 as const,
|
|
338
|
+
step: 0.01 as const,
|
|
339
|
+
default: 1 as const,
|
|
340
|
+
},
|
|
341
|
+
top_p: {
|
|
342
|
+
min: 0 as const,
|
|
343
|
+
max: 1 as const,
|
|
344
|
+
step: 0.01 as const,
|
|
345
|
+
default: 1 as const,
|
|
346
|
+
},
|
|
347
|
+
presence_penalty: {
|
|
348
|
+
min: 0 as const,
|
|
349
|
+
max: 2 as const,
|
|
350
|
+
step: 0.01 as const,
|
|
351
|
+
default: 0 as const,
|
|
352
|
+
},
|
|
353
|
+
frequency_penalty: {
|
|
354
|
+
min: 0 as const,
|
|
355
|
+
max: 2 as const,
|
|
356
|
+
step: 0.01 as const,
|
|
357
|
+
default: 0 as const,
|
|
358
|
+
},
|
|
359
|
+
resendFiles: {
|
|
360
|
+
default: true as const,
|
|
361
|
+
},
|
|
362
|
+
maxContextTokens: {
|
|
363
|
+
default: undefined,
|
|
364
|
+
},
|
|
365
|
+
max_tokens: {
|
|
366
|
+
default: undefined,
|
|
367
|
+
},
|
|
368
|
+
imageDetail: {
|
|
369
|
+
default: ImageDetail.auto as const,
|
|
370
|
+
},
|
|
371
|
+
};
|
|
372
|
+
|
|
219
373
|
export const endpointSettings = {
|
|
220
374
|
[EModelEndpoint.openAI]: openAISettings,
|
|
221
375
|
[EModelEndpoint.google]: googleSettings,
|
|
222
376
|
[EModelEndpoint.anthropic]: anthropicSettings,
|
|
377
|
+
[EModelEndpoint.agents]: agentsSettings,
|
|
378
|
+
[EModelEndpoint.bedrock]: agentsSettings,
|
|
223
379
|
};
|
|
224
380
|
|
|
225
381
|
const google = endpointSettings[EModelEndpoint.google];
|
|
@@ -240,10 +396,11 @@ export const tPluginSchema = z.object({
|
|
|
240
396
|
name: z.string(),
|
|
241
397
|
pluginKey: z.string(),
|
|
242
398
|
description: z.string(),
|
|
243
|
-
icon: z.string(),
|
|
244
|
-
authConfig: z.array(tPluginAuthConfigSchema),
|
|
399
|
+
icon: z.string().optional(),
|
|
400
|
+
authConfig: z.array(tPluginAuthConfigSchema).optional(),
|
|
245
401
|
authenticated: z.boolean().optional(),
|
|
246
402
|
isButton: z.boolean().optional(),
|
|
403
|
+
toolkit: z.boolean().optional(),
|
|
247
404
|
});
|
|
248
405
|
|
|
249
406
|
export type TPlugin = z.infer<typeof tPluginSchema>;
|
|
@@ -317,12 +474,12 @@ export const tMessageSchema = z.object({
|
|
|
317
474
|
bg: z.string().nullable().optional(),
|
|
318
475
|
model: z.string().nullable().optional(),
|
|
319
476
|
title: z.string().nullable().or(z.literal('New Chat')).default('New Chat'),
|
|
320
|
-
sender: z.string(),
|
|
477
|
+
sender: z.string().optional(),
|
|
321
478
|
text: z.string(),
|
|
322
479
|
generation: z.string().nullable().optional(),
|
|
323
|
-
isEdited: z.boolean().optional(),
|
|
324
480
|
isCreatedByUser: z.boolean(),
|
|
325
|
-
error: z.boolean(),
|
|
481
|
+
error: z.boolean().optional(),
|
|
482
|
+
clientTimestamp: z.string().optional(),
|
|
326
483
|
createdAt: z
|
|
327
484
|
.string()
|
|
328
485
|
.optional()
|
|
@@ -338,9 +495,16 @@ export const tMessageSchema = z.object({
|
|
|
338
495
|
/* assistant */
|
|
339
496
|
thread_id: z.string().optional(),
|
|
340
497
|
/* frontend components */
|
|
341
|
-
iconURL: z.string().optional(),
|
|
498
|
+
iconURL: z.string().nullable().optional(),
|
|
342
499
|
});
|
|
343
500
|
|
|
501
|
+
export type TAttachmentMetadata = { messageId: string; toolCallId: string };
|
|
502
|
+
export type TAttachment =
|
|
503
|
+
| (TFile & TAttachmentMetadata)
|
|
504
|
+
| (Pick<TFile, 'filename' | 'filepath' | 'conversationId'> & {
|
|
505
|
+
expiresAt: number;
|
|
506
|
+
} & TAttachmentMetadata);
|
|
507
|
+
|
|
344
508
|
export type TMessage = z.input<typeof tMessageSchema> & {
|
|
345
509
|
children?: TMessage[];
|
|
346
510
|
plugin?: TResPlugin | null;
|
|
@@ -349,6 +513,8 @@ export type TMessage = z.input<typeof tMessageSchema> & {
|
|
|
349
513
|
files?: Partial<TFile>[];
|
|
350
514
|
depth?: number;
|
|
351
515
|
siblingIndex?: number;
|
|
516
|
+
attachments?: TAttachment[];
|
|
517
|
+
clientTimestamp?: string;
|
|
352
518
|
};
|
|
353
519
|
|
|
354
520
|
export const coerceNumber = z.union([z.number(), z.string()]).transform((val) => {
|
|
@@ -358,69 +524,96 @@ export const coerceNumber = z.union([z.number(), z.string()]).transform((val) =>
|
|
|
358
524
|
return val;
|
|
359
525
|
});
|
|
360
526
|
|
|
527
|
+
type DocumentTypeValue =
|
|
528
|
+
| null
|
|
529
|
+
| boolean
|
|
530
|
+
| number
|
|
531
|
+
| string
|
|
532
|
+
| DocumentTypeValue[]
|
|
533
|
+
| { [key: string]: DocumentTypeValue };
|
|
534
|
+
|
|
535
|
+
const DocumentType: z.ZodType<DocumentTypeValue> = z.lazy(() =>
|
|
536
|
+
z.union([
|
|
537
|
+
z.null(),
|
|
538
|
+
z.boolean(),
|
|
539
|
+
z.number(),
|
|
540
|
+
z.string(),
|
|
541
|
+
z.array(z.lazy(() => DocumentType)),
|
|
542
|
+
z.record(z.lazy(() => DocumentType)),
|
|
543
|
+
]),
|
|
544
|
+
);
|
|
545
|
+
|
|
361
546
|
export const tConversationSchema = z.object({
|
|
362
547
|
conversationId: z.string().nullable(),
|
|
548
|
+
endpoint: eModelEndpointSchema.nullable(),
|
|
549
|
+
endpointType: eModelEndpointSchema.nullable().optional(),
|
|
550
|
+
isArchived: z.boolean().optional(),
|
|
363
551
|
title: z.string().nullable().or(z.literal('New Chat')).default('New Chat'),
|
|
364
552
|
user: z.string().optional(),
|
|
365
|
-
endpoint: eModelEndpointSchema.nullable(),
|
|
366
|
-
endpointType: eModelEndpointSchema.optional(),
|
|
367
|
-
suggestions: z.array(z.string()).optional(),
|
|
368
553
|
messages: z.array(z.string()).optional(),
|
|
369
554
|
tools: z.union([z.array(tPluginSchema), z.array(z.string())]).optional(),
|
|
370
|
-
createdAt: z.string(),
|
|
371
|
-
updatedAt: z.string(),
|
|
372
555
|
modelLabel: z.string().nullable().optional(),
|
|
373
|
-
examples: z.array(tExampleSchema).optional(),
|
|
374
|
-
/* Prefer modelLabel over chatGptLabel */
|
|
375
|
-
chatGptLabel: z.string().nullable().optional(),
|
|
376
556
|
userLabel: z.string().optional(),
|
|
377
557
|
model: z.string().nullable().optional(),
|
|
378
558
|
promptPrefix: z.string().nullable().optional(),
|
|
379
559
|
temperature: z.number().optional(),
|
|
380
560
|
topP: z.number().optional(),
|
|
381
561
|
topK: z.number().optional(),
|
|
382
|
-
context: z.string().nullable().optional(),
|
|
383
562
|
top_p: z.number().optional(),
|
|
384
563
|
frequency_penalty: z.number().optional(),
|
|
385
564
|
presence_penalty: z.number().optional(),
|
|
386
565
|
parentMessageId: z.string().optional(),
|
|
387
|
-
maxOutputTokens:
|
|
388
|
-
agentOptions: tAgentOptionsSchema.nullable().optional(),
|
|
389
|
-
file_ids: z.array(z.string()).optional(),
|
|
566
|
+
maxOutputTokens: coerceNumber.optional(),
|
|
390
567
|
maxContextTokens: coerceNumber.optional(),
|
|
391
568
|
max_tokens: coerceNumber.optional(),
|
|
392
|
-
/*
|
|
569
|
+
/* Anthropic */
|
|
570
|
+
promptCache: z.boolean().optional(),
|
|
571
|
+
system: z.string().optional(),
|
|
572
|
+
thinking: z.boolean().optional(),
|
|
573
|
+
thinkingBudget: coerceNumber.optional(),
|
|
574
|
+
/* artifacts */
|
|
575
|
+
artifacts: z.string().optional(),
|
|
576
|
+
/* google */
|
|
577
|
+
context: z.string().nullable().optional(),
|
|
578
|
+
examples: z.array(tExampleSchema).optional(),
|
|
579
|
+
/* DB */
|
|
580
|
+
tags: z.array(z.string()).optional(),
|
|
581
|
+
createdAt: z.string(),
|
|
582
|
+
updatedAt: z.string(),
|
|
583
|
+
/* Files */
|
|
393
584
|
resendFiles: z.boolean().optional(),
|
|
585
|
+
file_ids: z.array(z.string()).optional(),
|
|
586
|
+
/* vision */
|
|
394
587
|
imageDetail: eImageDetailSchema.optional(),
|
|
588
|
+
/* OpenAI: o1 only */
|
|
589
|
+
reasoning_effort: eReasoningEffortSchema.optional(),
|
|
395
590
|
/* assistant */
|
|
396
591
|
assistant_id: z.string().optional(),
|
|
592
|
+
/* agents */
|
|
593
|
+
agent_id: z.string().optional(),
|
|
594
|
+
/* AWS Bedrock */
|
|
595
|
+
region: z.string().optional(),
|
|
596
|
+
maxTokens: coerceNumber.optional(),
|
|
597
|
+
additionalModelRequestFields: DocumentType.optional(),
|
|
598
|
+
/* assistants */
|
|
397
599
|
instructions: z.string().optional(),
|
|
600
|
+
additional_instructions: z.string().optional(),
|
|
601
|
+
append_current_datetime: z.boolean().optional(),
|
|
398
602
|
/** Used to overwrite active conversation settings when saving a Preset */
|
|
399
603
|
presetOverride: z.record(z.unknown()).optional(),
|
|
400
604
|
stop: z.array(z.string()).optional(),
|
|
401
605
|
/* frontend components */
|
|
402
|
-
iconURL: z.string().optional(),
|
|
403
606
|
greeting: z.string().optional(),
|
|
404
|
-
spec: z.string().optional(),
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
/** @deprecated */
|
|
409
|
-
systemMessage: z.string().nullable().optional(),
|
|
410
|
-
/** @deprecated */
|
|
411
|
-
jailbreak: z.boolean().optional(),
|
|
412
|
-
/** @deprecated */
|
|
413
|
-
jailbreakConversationId: z.string().nullable().optional(),
|
|
414
|
-
/** @deprecated */
|
|
415
|
-
conversationSignature: z.string().nullable().optional(),
|
|
416
|
-
/** @deprecated */
|
|
417
|
-
clientId: z.string().nullable().optional(),
|
|
418
|
-
/** @deprecated */
|
|
419
|
-
invocationId: z.number().nullable().optional(),
|
|
420
|
-
/** @deprecated */
|
|
421
|
-
toneStyle: z.string().nullable().optional(),
|
|
607
|
+
spec: z.string().nullable().optional(),
|
|
608
|
+
iconURL: z.string().nullable().optional(),
|
|
609
|
+
/* temporary chat */
|
|
610
|
+
expiredAt: z.string().nullable().optional(),
|
|
422
611
|
/** @deprecated */
|
|
423
612
|
resendImages: z.boolean().optional(),
|
|
613
|
+
/** @deprecated */
|
|
614
|
+
agentOptions: tAgentOptionsSchema.nullable().optional(),
|
|
615
|
+
/** @deprecated Prefer `modelLabel` over `chatGptLabel` */
|
|
616
|
+
chatGptLabel: z.string().nullable().optional(),
|
|
424
617
|
});
|
|
425
618
|
|
|
426
619
|
export const tPresetSchema = tConversationSchema
|
|
@@ -447,11 +640,79 @@ export const tConvoUpdateSchema = tConversationSchema.merge(
|
|
|
447
640
|
}),
|
|
448
641
|
);
|
|
449
642
|
|
|
450
|
-
export const
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
643
|
+
export const tQueryParamsSchema = tConversationSchema
|
|
644
|
+
.pick({
|
|
645
|
+
// librechat settings
|
|
646
|
+
/** The AI context window, overrides the system-defined window as determined by `model` value */
|
|
647
|
+
maxContextTokens: true,
|
|
648
|
+
/**
|
|
649
|
+
* Whether or not to re-submit files from previous messages on subsequent messages
|
|
650
|
+
* */
|
|
651
|
+
resendFiles: true,
|
|
652
|
+
/**
|
|
653
|
+
* @endpoints openAI, custom, azureOpenAI
|
|
654
|
+
*
|
|
655
|
+
* System parameter that only affects the above endpoints.
|
|
656
|
+
* Image detail for re-sizing according to OpenAI spec, defaults to `auto`
|
|
657
|
+
* */
|
|
658
|
+
imageDetail: true,
|
|
659
|
+
/**
|
|
660
|
+
* AKA Custom Instructions, dynamically added to chat history as a system message;
|
|
661
|
+
* for `bedrock` endpoint, this is used as the `system` model param if the provider uses it;
|
|
662
|
+
* for `assistants` endpoint, this is used as the `additional_instructions` model param:
|
|
663
|
+
* https://platform.openai.com/docs/api-reference/runs/createRun#runs-createrun-additional_instructions
|
|
664
|
+
* ; otherwise, a message with `system` role is added to the chat history
|
|
665
|
+
*/
|
|
666
|
+
promptPrefix: true,
|
|
667
|
+
// Model parameters
|
|
668
|
+
/** @endpoints openAI, custom, azureOpenAI, google, anthropic, assistants, azureAssistants, bedrock */
|
|
669
|
+
model: true,
|
|
670
|
+
/** @endpoints openAI, custom, azureOpenAI, google, anthropic, bedrock */
|
|
671
|
+
temperature: true,
|
|
672
|
+
/** @endpoints openAI, custom, azureOpenAI */
|
|
673
|
+
presence_penalty: true,
|
|
674
|
+
/** @endpoints openAI, custom, azureOpenAI */
|
|
675
|
+
frequency_penalty: true,
|
|
676
|
+
/** @endpoints openAI, custom, azureOpenAI */
|
|
677
|
+
stop: true,
|
|
678
|
+
/** @endpoints openAI, custom, azureOpenAI */
|
|
679
|
+
top_p: true,
|
|
680
|
+
/** @endpoints openAI, custom, azureOpenAI */
|
|
681
|
+
max_tokens: true,
|
|
682
|
+
/** @endpoints google, anthropic, bedrock */
|
|
683
|
+
topP: true,
|
|
684
|
+
/** @endpoints google, anthropic */
|
|
685
|
+
topK: true,
|
|
686
|
+
/** @endpoints google, anthropic */
|
|
687
|
+
maxOutputTokens: true,
|
|
688
|
+
/** @endpoints anthropic */
|
|
689
|
+
promptCache: true,
|
|
690
|
+
thinking: true,
|
|
691
|
+
thinkingBudget: true,
|
|
692
|
+
/** @endpoints bedrock */
|
|
693
|
+
region: true,
|
|
694
|
+
/** @endpoints bedrock */
|
|
695
|
+
maxTokens: true,
|
|
696
|
+
/** @endpoints agents */
|
|
697
|
+
agent_id: true,
|
|
698
|
+
/** @endpoints assistants, azureAssistants */
|
|
699
|
+
assistant_id: true,
|
|
700
|
+
/** @endpoints assistants, azureAssistants */
|
|
701
|
+
append_current_datetime: true,
|
|
702
|
+
/**
|
|
703
|
+
* @endpoints assistants, azureAssistants
|
|
704
|
+
*
|
|
705
|
+
* Overrides existing assistant instructions, only used for the current run:
|
|
706
|
+
* https://platform.openai.com/docs/api-reference/runs/createRun#runs-createrun-instructions
|
|
707
|
+
* */
|
|
708
|
+
instructions: true,
|
|
709
|
+
})
|
|
710
|
+
.merge(
|
|
711
|
+
z.object({
|
|
712
|
+
/** @endpoints openAI, custom, azureOpenAI, google, anthropic, assistants, azureAssistants, bedrock, agents */
|
|
713
|
+
endpoint: extendedModelEndpointSchema.nullable(),
|
|
714
|
+
}),
|
|
715
|
+
);
|
|
455
716
|
|
|
456
717
|
export type TPreset = z.infer<typeof tPresetSchema>;
|
|
457
718
|
|
|
@@ -467,78 +728,25 @@ export const tSharedLinkSchema = z.object({
|
|
|
467
728
|
conversationId: z.string(),
|
|
468
729
|
shareId: z.string(),
|
|
469
730
|
messages: z.array(z.string()),
|
|
470
|
-
isAnonymous: z.boolean(),
|
|
471
731
|
isPublic: z.boolean(),
|
|
472
|
-
isVisible: z.boolean(),
|
|
473
732
|
title: z.string(),
|
|
474
733
|
createdAt: z.string(),
|
|
475
734
|
updatedAt: z.string(),
|
|
476
735
|
});
|
|
477
|
-
export type TSharedLink = z.infer<typeof tSharedLinkSchema>;
|
|
478
736
|
|
|
479
|
-
export
|
|
480
|
-
.pick({
|
|
481
|
-
model: true,
|
|
482
|
-
modelLabel: true,
|
|
483
|
-
chatGptLabel: true,
|
|
484
|
-
promptPrefix: true,
|
|
485
|
-
temperature: true,
|
|
486
|
-
top_p: true,
|
|
487
|
-
presence_penalty: true,
|
|
488
|
-
frequency_penalty: true,
|
|
489
|
-
resendFiles: true,
|
|
490
|
-
imageDetail: true,
|
|
491
|
-
stop: true,
|
|
492
|
-
iconURL: true,
|
|
493
|
-
greeting: true,
|
|
494
|
-
spec: true,
|
|
495
|
-
maxContextTokens: true,
|
|
496
|
-
max_tokens: true,
|
|
497
|
-
})
|
|
498
|
-
.transform((obj) => {
|
|
499
|
-
const result = {
|
|
500
|
-
...obj,
|
|
501
|
-
model: obj.model ?? openAISettings.model.default,
|
|
502
|
-
chatGptLabel: obj.chatGptLabel ?? obj.modelLabel ?? null,
|
|
503
|
-
promptPrefix: obj.promptPrefix ?? null,
|
|
504
|
-
temperature: obj.temperature ?? openAISettings.temperature.default,
|
|
505
|
-
top_p: obj.top_p ?? openAISettings.top_p.default,
|
|
506
|
-
presence_penalty: obj.presence_penalty ?? openAISettings.presence_penalty.default,
|
|
507
|
-
frequency_penalty: obj.frequency_penalty ?? openAISettings.frequency_penalty.default,
|
|
508
|
-
resendFiles:
|
|
509
|
-
typeof obj.resendFiles === 'boolean' ? obj.resendFiles : openAISettings.resendFiles.default,
|
|
510
|
-
imageDetail: obj.imageDetail ?? openAISettings.imageDetail.default,
|
|
511
|
-
stop: obj.stop ?? undefined,
|
|
512
|
-
iconURL: obj.iconURL ?? undefined,
|
|
513
|
-
greeting: obj.greeting ?? undefined,
|
|
514
|
-
spec: obj.spec ?? undefined,
|
|
515
|
-
maxContextTokens: obj.maxContextTokens ?? undefined,
|
|
516
|
-
max_tokens: obj.max_tokens ?? undefined,
|
|
517
|
-
};
|
|
518
|
-
|
|
519
|
-
if (obj.modelLabel) {
|
|
520
|
-
result.modelLabel = null;
|
|
521
|
-
}
|
|
737
|
+
export type TSharedLink = z.infer<typeof tSharedLinkSchema>;
|
|
522
738
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
.
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
imageDetail: openAISettings.imageDetail.default,
|
|
535
|
-
stop: undefined,
|
|
536
|
-
iconURL: undefined,
|
|
537
|
-
greeting: undefined,
|
|
538
|
-
spec: undefined,
|
|
539
|
-
maxContextTokens: undefined,
|
|
540
|
-
max_tokens: undefined,
|
|
541
|
-
}));
|
|
739
|
+
export const tConversationTagSchema = z.object({
|
|
740
|
+
_id: z.string(),
|
|
741
|
+
user: z.string(),
|
|
742
|
+
tag: z.string(),
|
|
743
|
+
description: z.string().optional(),
|
|
744
|
+
createdAt: z.string(),
|
|
745
|
+
updatedAt: z.string(),
|
|
746
|
+
count: z.number(),
|
|
747
|
+
position: z.number(),
|
|
748
|
+
});
|
|
749
|
+
export type TConversationTag = z.infer<typeof tConversationTagSchema>;
|
|
542
750
|
|
|
543
751
|
export const googleSchema = tConversationSchema
|
|
544
752
|
.pick({
|
|
@@ -548,6 +756,7 @@ export const googleSchema = tConversationSchema
|
|
|
548
756
|
examples: true,
|
|
549
757
|
temperature: true,
|
|
550
758
|
maxOutputTokens: true,
|
|
759
|
+
artifacts: true,
|
|
551
760
|
topP: true,
|
|
552
761
|
topK: true,
|
|
553
762
|
iconURL: true,
|
|
@@ -555,123 +764,27 @@ export const googleSchema = tConversationSchema
|
|
|
555
764
|
spec: true,
|
|
556
765
|
maxContextTokens: true,
|
|
557
766
|
})
|
|
558
|
-
.transform((obj) =>
|
|
559
|
-
|
|
560
|
-
...obj,
|
|
561
|
-
model: obj.model ?? google.model.default,
|
|
562
|
-
modelLabel: obj.modelLabel ?? null,
|
|
563
|
-
promptPrefix: obj.promptPrefix ?? null,
|
|
564
|
-
examples: obj.examples ?? [{ input: { content: '' }, output: { content: '' } }],
|
|
565
|
-
temperature: obj.temperature ?? google.temperature.default,
|
|
566
|
-
maxOutputTokens: obj.maxOutputTokens ?? google.maxOutputTokens.default,
|
|
567
|
-
topP: obj.topP ?? google.topP.default,
|
|
568
|
-
topK: obj.topK ?? google.topK.default,
|
|
569
|
-
iconURL: obj.iconURL ?? undefined,
|
|
570
|
-
greeting: obj.greeting ?? undefined,
|
|
571
|
-
spec: obj.spec ?? undefined,
|
|
572
|
-
maxContextTokens: obj.maxContextTokens ?? undefined,
|
|
573
|
-
};
|
|
574
|
-
})
|
|
575
|
-
.catch(() => ({
|
|
576
|
-
model: google.model.default,
|
|
577
|
-
modelLabel: null,
|
|
578
|
-
promptPrefix: null,
|
|
579
|
-
examples: [{ input: { content: '' }, output: { content: '' } }],
|
|
580
|
-
temperature: google.temperature.default,
|
|
581
|
-
maxOutputTokens: google.maxOutputTokens.default,
|
|
582
|
-
topP: google.topP.default,
|
|
583
|
-
topK: google.topK.default,
|
|
584
|
-
iconURL: undefined,
|
|
585
|
-
greeting: undefined,
|
|
586
|
-
spec: undefined,
|
|
587
|
-
maxContextTokens: undefined,
|
|
588
|
-
}));
|
|
767
|
+
.transform((obj: Partial<TConversation>) => removeNullishValues(obj))
|
|
768
|
+
.catch(() => ({}));
|
|
589
769
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
770
|
+
/**
|
|
771
|
+
* TODO: Map the following fields:
|
|
772
|
+
- presence_penalty -> presencePenalty
|
|
773
|
+
- frequency_penalty -> frequencyPenalty
|
|
774
|
+
- stop -> stopSequences
|
|
775
|
+
*/
|
|
776
|
+
export const googleGenConfigSchema = z
|
|
777
|
+
.object({
|
|
778
|
+
maxOutputTokens: coerceNumber.optional(),
|
|
779
|
+
temperature: coerceNumber.optional(),
|
|
780
|
+
topP: coerceNumber.optional(),
|
|
781
|
+
topK: coerceNumber.optional(),
|
|
782
|
+
presencePenalty: coerceNumber.optional(),
|
|
783
|
+
frequencyPenalty: coerceNumber.optional(),
|
|
784
|
+
stopSequences: z.array(z.string()).optional(),
|
|
600
785
|
})
|
|
601
|
-
.
|
|
602
|
-
|
|
603
|
-
model: '',
|
|
604
|
-
jailbreak: obj.jailbreak ?? false,
|
|
605
|
-
systemMessage: obj.systemMessage ?? null,
|
|
606
|
-
context: obj.context ?? null,
|
|
607
|
-
toneStyle: obj.toneStyle ?? 'creative',
|
|
608
|
-
jailbreakConversationId: obj.jailbreakConversationId ?? null,
|
|
609
|
-
conversationSignature: obj.conversationSignature ?? null,
|
|
610
|
-
clientId: obj.clientId ?? null,
|
|
611
|
-
invocationId: obj.invocationId ?? 1,
|
|
612
|
-
}))
|
|
613
|
-
.catch(() => ({
|
|
614
|
-
model: '',
|
|
615
|
-
jailbreak: false,
|
|
616
|
-
systemMessage: null,
|
|
617
|
-
context: null,
|
|
618
|
-
toneStyle: 'creative',
|
|
619
|
-
jailbreakConversationId: null,
|
|
620
|
-
conversationSignature: null,
|
|
621
|
-
clientId: null,
|
|
622
|
-
invocationId: 1,
|
|
623
|
-
}));
|
|
624
|
-
|
|
625
|
-
export const anthropicSchema = tConversationSchema
|
|
626
|
-
.pick({
|
|
627
|
-
model: true,
|
|
628
|
-
modelLabel: true,
|
|
629
|
-
promptPrefix: true,
|
|
630
|
-
temperature: true,
|
|
631
|
-
maxOutputTokens: true,
|
|
632
|
-
topP: true,
|
|
633
|
-
topK: true,
|
|
634
|
-
resendFiles: true,
|
|
635
|
-
iconURL: true,
|
|
636
|
-
greeting: true,
|
|
637
|
-
spec: true,
|
|
638
|
-
maxContextTokens: true,
|
|
639
|
-
})
|
|
640
|
-
.transform((obj) => {
|
|
641
|
-
const model = obj.model ?? anthropicSettings.model.default;
|
|
642
|
-
return {
|
|
643
|
-
...obj,
|
|
644
|
-
model,
|
|
645
|
-
modelLabel: obj.modelLabel ?? null,
|
|
646
|
-
promptPrefix: obj.promptPrefix ?? null,
|
|
647
|
-
temperature: obj.temperature ?? anthropicSettings.temperature.default,
|
|
648
|
-
maxOutputTokens: obj.maxOutputTokens ?? anthropicSettings.maxOutputTokens.reset(model),
|
|
649
|
-
topP: obj.topP ?? anthropicSettings.topP.default,
|
|
650
|
-
topK: obj.topK ?? anthropicSettings.topK.default,
|
|
651
|
-
resendFiles:
|
|
652
|
-
typeof obj.resendFiles === 'boolean'
|
|
653
|
-
? obj.resendFiles
|
|
654
|
-
: anthropicSettings.resendFiles.default,
|
|
655
|
-
iconURL: obj.iconURL ?? undefined,
|
|
656
|
-
greeting: obj.greeting ?? undefined,
|
|
657
|
-
spec: obj.spec ?? undefined,
|
|
658
|
-
maxContextTokens: obj.maxContextTokens ?? anthropicSettings.maxContextTokens.default,
|
|
659
|
-
};
|
|
660
|
-
})
|
|
661
|
-
.catch(() => ({
|
|
662
|
-
model: anthropicSettings.model.default,
|
|
663
|
-
modelLabel: null,
|
|
664
|
-
promptPrefix: null,
|
|
665
|
-
temperature: anthropicSettings.temperature.default,
|
|
666
|
-
maxOutputTokens: anthropicSettings.maxOutputTokens.default,
|
|
667
|
-
topP: anthropicSettings.topP.default,
|
|
668
|
-
topK: anthropicSettings.topK.default,
|
|
669
|
-
resendFiles: anthropicSettings.resendFiles.default,
|
|
670
|
-
iconURL: undefined,
|
|
671
|
-
greeting: undefined,
|
|
672
|
-
spec: undefined,
|
|
673
|
-
maxContextTokens: anthropicSettings.maxContextTokens.default,
|
|
674
|
-
}));
|
|
786
|
+
.strip()
|
|
787
|
+
.optional();
|
|
675
788
|
|
|
676
789
|
export const chatGPTBrowserSchema = tConversationSchema
|
|
677
790
|
.pick({
|
|
@@ -692,6 +805,7 @@ export const gptPluginsSchema = tConversationSchema
|
|
|
692
805
|
chatGptLabel: true,
|
|
693
806
|
promptPrefix: true,
|
|
694
807
|
temperature: true,
|
|
808
|
+
artifacts: true,
|
|
695
809
|
top_p: true,
|
|
696
810
|
presence_penalty: true,
|
|
697
811
|
frequency_penalty: true,
|
|
@@ -725,7 +839,7 @@ export const gptPluginsSchema = tConversationSchema
|
|
|
725
839
|
maxContextTokens: obj.maxContextTokens ?? undefined,
|
|
726
840
|
};
|
|
727
841
|
|
|
728
|
-
if (obj.modelLabel) {
|
|
842
|
+
if (obj.modelLabel != null && obj.modelLabel !== '') {
|
|
729
843
|
result.modelLabel = null;
|
|
730
844
|
}
|
|
731
845
|
|
|
@@ -752,16 +866,23 @@ export const gptPluginsSchema = tConversationSchema
|
|
|
752
866
|
maxContextTokens: undefined,
|
|
753
867
|
}));
|
|
754
868
|
|
|
755
|
-
export function removeNullishValues<T extends
|
|
869
|
+
export function removeNullishValues<T extends Record<string, unknown>>(
|
|
870
|
+
obj: T,
|
|
871
|
+
removeEmptyStrings?: boolean,
|
|
872
|
+
): Partial<T> {
|
|
756
873
|
const newObj: Partial<T> = { ...obj };
|
|
757
874
|
|
|
758
875
|
(Object.keys(newObj) as Array<keyof T>).forEach((key) => {
|
|
759
|
-
|
|
876
|
+
const value = newObj[key];
|
|
877
|
+
if (value === undefined || value === null) {
|
|
878
|
+
delete newObj[key];
|
|
879
|
+
}
|
|
880
|
+
if (removeEmptyStrings && typeof value === 'string' && value === '') {
|
|
760
881
|
delete newObj[key];
|
|
761
882
|
}
|
|
762
883
|
});
|
|
763
884
|
|
|
764
|
-
return newObj
|
|
885
|
+
return newObj;
|
|
765
886
|
}
|
|
766
887
|
|
|
767
888
|
export const assistantSchema = tConversationSchema
|
|
@@ -769,10 +890,12 @@ export const assistantSchema = tConversationSchema
|
|
|
769
890
|
model: true,
|
|
770
891
|
assistant_id: true,
|
|
771
892
|
instructions: true,
|
|
893
|
+
artifacts: true,
|
|
772
894
|
promptPrefix: true,
|
|
773
895
|
iconURL: true,
|
|
774
896
|
greeting: true,
|
|
775
897
|
spec: true,
|
|
898
|
+
append_current_datetime: true,
|
|
776
899
|
})
|
|
777
900
|
.transform((obj) => ({
|
|
778
901
|
...obj,
|
|
@@ -783,6 +906,7 @@ export const assistantSchema = tConversationSchema
|
|
|
783
906
|
iconURL: obj.iconURL ?? undefined,
|
|
784
907
|
greeting: obj.greeting ?? undefined,
|
|
785
908
|
spec: obj.spec ?? undefined,
|
|
909
|
+
append_current_datetime: obj.append_current_datetime ?? false,
|
|
786
910
|
}))
|
|
787
911
|
.catch(() => ({
|
|
788
912
|
model: openAISettings.model.default,
|
|
@@ -792,6 +916,7 @@ export const assistantSchema = tConversationSchema
|
|
|
792
916
|
iconURL: undefined,
|
|
793
917
|
greeting: undefined,
|
|
794
918
|
spec: undefined,
|
|
919
|
+
append_current_datetime: false,
|
|
795
920
|
}));
|
|
796
921
|
|
|
797
922
|
export const compactAssistantSchema = tConversationSchema
|
|
@@ -800,17 +925,70 @@ export const compactAssistantSchema = tConversationSchema
|
|
|
800
925
|
assistant_id: true,
|
|
801
926
|
instructions: true,
|
|
802
927
|
promptPrefix: true,
|
|
928
|
+
artifacts: true,
|
|
803
929
|
iconURL: true,
|
|
804
930
|
greeting: true,
|
|
805
931
|
spec: true,
|
|
806
932
|
})
|
|
807
|
-
|
|
808
|
-
.transform(removeNullishValues)
|
|
933
|
+
.transform((obj) => removeNullishValues(obj))
|
|
809
934
|
.catch(() => ({}));
|
|
810
935
|
|
|
811
|
-
export const
|
|
936
|
+
export const agentsSchema = tConversationSchema
|
|
937
|
+
.pick({
|
|
938
|
+
model: true,
|
|
939
|
+
modelLabel: true,
|
|
940
|
+
temperature: true,
|
|
941
|
+
top_p: true,
|
|
942
|
+
presence_penalty: true,
|
|
943
|
+
frequency_penalty: true,
|
|
944
|
+
resendFiles: true,
|
|
945
|
+
imageDetail: true,
|
|
946
|
+
agent_id: true,
|
|
947
|
+
instructions: true,
|
|
948
|
+
promptPrefix: true,
|
|
949
|
+
iconURL: true,
|
|
950
|
+
greeting: true,
|
|
951
|
+
maxContextTokens: true,
|
|
952
|
+
})
|
|
953
|
+
.transform((obj) => ({
|
|
954
|
+
...obj,
|
|
955
|
+
model: obj.model ?? agentsSettings.model.default,
|
|
956
|
+
modelLabel: obj.modelLabel ?? null,
|
|
957
|
+
temperature: obj.temperature ?? 1,
|
|
958
|
+
top_p: obj.top_p ?? 1,
|
|
959
|
+
presence_penalty: obj.presence_penalty ?? 0,
|
|
960
|
+
frequency_penalty: obj.frequency_penalty ?? 0,
|
|
961
|
+
resendFiles:
|
|
962
|
+
typeof obj.resendFiles === 'boolean' ? obj.resendFiles : agentsSettings.resendFiles.default,
|
|
963
|
+
imageDetail: obj.imageDetail ?? ImageDetail.auto,
|
|
964
|
+
agent_id: obj.agent_id ?? undefined,
|
|
965
|
+
instructions: obj.instructions ?? undefined,
|
|
966
|
+
promptPrefix: obj.promptPrefix ?? null,
|
|
967
|
+
iconURL: obj.iconURL ?? undefined,
|
|
968
|
+
greeting: obj.greeting ?? undefined,
|
|
969
|
+
maxContextTokens: obj.maxContextTokens ?? undefined,
|
|
970
|
+
}))
|
|
971
|
+
.catch(() => ({
|
|
972
|
+
model: agentsSettings.model.default,
|
|
973
|
+
modelLabel: null,
|
|
974
|
+
temperature: 1,
|
|
975
|
+
top_p: 1,
|
|
976
|
+
presence_penalty: 0,
|
|
977
|
+
frequency_penalty: 0,
|
|
978
|
+
resendFiles: agentsSettings.resendFiles.default,
|
|
979
|
+
imageDetail: ImageDetail.auto,
|
|
980
|
+
agent_id: undefined,
|
|
981
|
+
instructions: undefined,
|
|
982
|
+
promptPrefix: null,
|
|
983
|
+
iconURL: undefined,
|
|
984
|
+
greeting: undefined,
|
|
985
|
+
maxContextTokens: undefined,
|
|
986
|
+
}));
|
|
987
|
+
|
|
988
|
+
export const openAISchema = tConversationSchema
|
|
812
989
|
.pick({
|
|
813
990
|
model: true,
|
|
991
|
+
modelLabel: true,
|
|
814
992
|
chatGptLabel: true,
|
|
815
993
|
promptPrefix: true,
|
|
816
994
|
temperature: true,
|
|
@@ -818,6 +996,7 @@ export const compactOpenAISchema = tConversationSchema
|
|
|
818
996
|
presence_penalty: true,
|
|
819
997
|
frequency_penalty: true,
|
|
820
998
|
resendFiles: true,
|
|
999
|
+
artifacts: true,
|
|
821
1000
|
imageDetail: true,
|
|
822
1001
|
stop: true,
|
|
823
1002
|
iconURL: true,
|
|
@@ -825,30 +1004,9 @@ export const compactOpenAISchema = tConversationSchema
|
|
|
825
1004
|
spec: true,
|
|
826
1005
|
maxContextTokens: true,
|
|
827
1006
|
max_tokens: true,
|
|
1007
|
+
reasoning_effort: true,
|
|
828
1008
|
})
|
|
829
|
-
.transform((obj: Partial<TConversation>) =>
|
|
830
|
-
const newObj: Partial<TConversation> = { ...obj };
|
|
831
|
-
if (newObj.temperature === 1) {
|
|
832
|
-
delete newObj.temperature;
|
|
833
|
-
}
|
|
834
|
-
if (newObj.top_p === 1) {
|
|
835
|
-
delete newObj.top_p;
|
|
836
|
-
}
|
|
837
|
-
if (newObj.presence_penalty === 0) {
|
|
838
|
-
delete newObj.presence_penalty;
|
|
839
|
-
}
|
|
840
|
-
if (newObj.frequency_penalty === 0) {
|
|
841
|
-
delete newObj.frequency_penalty;
|
|
842
|
-
}
|
|
843
|
-
if (newObj.resendFiles === true) {
|
|
844
|
-
delete newObj.resendFiles;
|
|
845
|
-
}
|
|
846
|
-
if (newObj.imageDetail === ImageDetail.auto) {
|
|
847
|
-
delete newObj.imageDetail;
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
return removeNullishValues(newObj);
|
|
851
|
-
})
|
|
1009
|
+
.transform((obj: Partial<TConversation>) => removeNullishValues(obj))
|
|
852
1010
|
.catch(() => ({}));
|
|
853
1011
|
|
|
854
1012
|
export const compactGoogleSchema = tConversationSchema
|
|
@@ -859,6 +1017,7 @@ export const compactGoogleSchema = tConversationSchema
|
|
|
859
1017
|
examples: true,
|
|
860
1018
|
temperature: true,
|
|
861
1019
|
maxOutputTokens: true,
|
|
1020
|
+
artifacts: true,
|
|
862
1021
|
topP: true,
|
|
863
1022
|
topK: true,
|
|
864
1023
|
iconURL: true,
|
|
@@ -885,7 +1044,7 @@ export const compactGoogleSchema = tConversationSchema
|
|
|
885
1044
|
})
|
|
886
1045
|
.catch(() => ({}));
|
|
887
1046
|
|
|
888
|
-
export const
|
|
1047
|
+
export const anthropicSchema = tConversationSchema
|
|
889
1048
|
.pick({
|
|
890
1049
|
model: true,
|
|
891
1050
|
modelLabel: true,
|
|
@@ -895,31 +1054,16 @@ export const compactAnthropicSchema = tConversationSchema
|
|
|
895
1054
|
topP: true,
|
|
896
1055
|
topK: true,
|
|
897
1056
|
resendFiles: true,
|
|
1057
|
+
promptCache: true,
|
|
1058
|
+
thinking: true,
|
|
1059
|
+
thinkingBudget: true,
|
|
1060
|
+
artifacts: true,
|
|
898
1061
|
iconURL: true,
|
|
899
1062
|
greeting: true,
|
|
900
1063
|
spec: true,
|
|
901
1064
|
maxContextTokens: true,
|
|
902
1065
|
})
|
|
903
|
-
.transform((obj) =>
|
|
904
|
-
const newObj: Partial<TConversation> = { ...obj };
|
|
905
|
-
if (newObj.temperature === anthropicSettings.temperature.default) {
|
|
906
|
-
delete newObj.temperature;
|
|
907
|
-
}
|
|
908
|
-
if (newObj.maxOutputTokens === anthropicSettings.legacy.maxOutputTokens.default) {
|
|
909
|
-
delete newObj.maxOutputTokens;
|
|
910
|
-
}
|
|
911
|
-
if (newObj.topP === anthropicSettings.topP.default) {
|
|
912
|
-
delete newObj.topP;
|
|
913
|
-
}
|
|
914
|
-
if (newObj.topK === anthropicSettings.topK.default) {
|
|
915
|
-
delete newObj.topK;
|
|
916
|
-
}
|
|
917
|
-
if (newObj.resendFiles === anthropicSettings.resendFiles.default) {
|
|
918
|
-
delete newObj.resendFiles;
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
return removeNullishValues(newObj);
|
|
922
|
-
})
|
|
1066
|
+
.transform((obj) => removeNullishValues(obj))
|
|
923
1067
|
.catch(() => ({}));
|
|
924
1068
|
|
|
925
1069
|
export const compactChatGPTSchema = tConversationSchema
|
|
@@ -935,6 +1079,7 @@ export const compactChatGPTSchema = tConversationSchema
|
|
|
935
1079
|
export const compactPluginsSchema = tConversationSchema
|
|
936
1080
|
.pick({
|
|
937
1081
|
model: true,
|
|
1082
|
+
modelLabel: true,
|
|
938
1083
|
chatGptLabel: true,
|
|
939
1084
|
promptPrefix: true,
|
|
940
1085
|
temperature: true,
|
|
@@ -950,6 +1095,9 @@ export const compactPluginsSchema = tConversationSchema
|
|
|
950
1095
|
})
|
|
951
1096
|
.transform((obj) => {
|
|
952
1097
|
const newObj: Partial<TConversation> = { ...obj };
|
|
1098
|
+
if (newObj.modelLabel === null) {
|
|
1099
|
+
delete newObj.modelLabel;
|
|
1100
|
+
}
|
|
953
1101
|
if (newObj.chatGptLabel === null) {
|
|
954
1102
|
delete newObj.chatGptLabel;
|
|
955
1103
|
}
|
|
@@ -985,3 +1133,28 @@ export const compactPluginsSchema = tConversationSchema
|
|
|
985
1133
|
return removeNullishValues(newObj);
|
|
986
1134
|
})
|
|
987
1135
|
.catch(() => ({}));
|
|
1136
|
+
|
|
1137
|
+
export const tBannerSchema = z.object({
|
|
1138
|
+
bannerId: z.string(),
|
|
1139
|
+
message: z.string(),
|
|
1140
|
+
displayFrom: z.string(),
|
|
1141
|
+
displayTo: z.string(),
|
|
1142
|
+
createdAt: z.string(),
|
|
1143
|
+
updatedAt: z.string(),
|
|
1144
|
+
isPublic: z.boolean(),
|
|
1145
|
+
});
|
|
1146
|
+
export type TBanner = z.infer<typeof tBannerSchema>;
|
|
1147
|
+
|
|
1148
|
+
export const compactAgentsSchema = tConversationSchema
|
|
1149
|
+
.pick({
|
|
1150
|
+
spec: true,
|
|
1151
|
+
// model: true,
|
|
1152
|
+
iconURL: true,
|
|
1153
|
+
greeting: true,
|
|
1154
|
+
agent_id: true,
|
|
1155
|
+
resendFiles: true,
|
|
1156
|
+
instructions: true,
|
|
1157
|
+
additional_instructions: true,
|
|
1158
|
+
})
|
|
1159
|
+
.transform((obj) => removeNullishValues(obj))
|
|
1160
|
+
.catch(() => ({}));
|