librechat-data-provider 0.6.3 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/schemas.ts CHANGED
@@ -22,9 +22,19 @@ export enum EModelEndpoint {
22
22
  gptPlugins = 'gptPlugins',
23
23
  anthropic = 'anthropic',
24
24
  assistants = 'assistants',
25
+ azureAssistants = 'azureAssistants',
25
26
  custom = 'custom',
26
27
  }
27
28
 
29
+ export type AssistantsEndpoint = EModelEndpoint.assistants | EModelEndpoint.azureAssistants;
30
+
31
+ export const isAssistantsEndpoint = (endpoint?: AssistantsEndpoint | null | string): boolean => {
32
+ if (!endpoint) {
33
+ return false;
34
+ }
35
+ return endpoint.toLowerCase().endsWith(EModelEndpoint.assistants);
36
+ };
37
+
28
38
  export enum ImageDetail {
29
39
  low = 'low',
30
40
  auto = 'auto',
@@ -76,7 +86,7 @@ export const isImageVisionTool = (tool: FunctionTool | FunctionToolCall) =>
76
86
 
77
87
  export const openAISettings = {
78
88
  model: {
79
- default: 'gpt-3.5-turbo',
89
+ default: 'gpt-4o',
80
90
  },
81
91
  temperature: {
82
92
  min: 0,
@@ -211,7 +221,7 @@ export enum EAgent {
211
221
 
212
222
  export const agentOptionSettings = {
213
223
  model: {
214
- default: 'gpt-4-turbo',
224
+ default: 'gpt-4o',
215
225
  },
216
226
  temperature: {
217
227
  min: 0,
@@ -381,6 +391,19 @@ export type TConversation = z.infer<typeof tConversationSchema> & {
381
391
  presetOverride?: Partial<TPreset>;
382
392
  };
383
393
 
394
+ export const tSharedLinkSchema = z.object({
395
+ conversationId: z.string(),
396
+ shareId: z.string(),
397
+ messages: z.array(z.string()),
398
+ isAnonymous: z.boolean(),
399
+ isPublic: z.boolean(),
400
+ isVisible: z.boolean(),
401
+ title: z.string(),
402
+ createdAt: z.string(),
403
+ updatedAt: z.string(),
404
+ });
405
+ export type TSharedLink = z.infer<typeof tSharedLinkSchema>;
406
+
384
407
  export const openAISchema = tConversationSchema
385
408
  .pick({
386
409
  model: true,
@@ -400,25 +423,33 @@ export const openAISchema = tConversationSchema
400
423
  maxContextTokens: true,
401
424
  max_tokens: true,
402
425
  })
403
- .transform((obj) => ({
404
- ...obj,
405
- model: obj.model ?? openAISettings.model.default,
406
- chatGptLabel: obj.modelLabel ?? obj.chatGptLabel ?? null,
407
- promptPrefix: obj.promptPrefix ?? null,
408
- temperature: obj.temperature ?? openAISettings.temperature.default,
409
- top_p: obj.top_p ?? openAISettings.top_p.default,
410
- presence_penalty: obj.presence_penalty ?? openAISettings.presence_penalty.default,
411
- frequency_penalty: obj.frequency_penalty ?? openAISettings.frequency_penalty.default,
412
- resendFiles:
413
- typeof obj.resendFiles === 'boolean' ? obj.resendFiles : openAISettings.resendFiles.default,
414
- imageDetail: obj.imageDetail ?? openAISettings.imageDetail.default,
415
- stop: obj.stop ?? undefined,
416
- iconURL: obj.iconURL ?? undefined,
417
- greeting: obj.greeting ?? undefined,
418
- spec: obj.spec ?? undefined,
419
- maxContextTokens: obj.maxContextTokens ?? undefined,
420
- max_tokens: obj.max_tokens ?? undefined,
421
- }))
426
+ .transform((obj) => {
427
+ const result = {
428
+ ...obj,
429
+ model: obj.model ?? openAISettings.model.default,
430
+ chatGptLabel: obj.chatGptLabel ?? obj.modelLabel ?? null,
431
+ promptPrefix: obj.promptPrefix ?? null,
432
+ temperature: obj.temperature ?? openAISettings.temperature.default,
433
+ top_p: obj.top_p ?? openAISettings.top_p.default,
434
+ presence_penalty: obj.presence_penalty ?? openAISettings.presence_penalty.default,
435
+ frequency_penalty: obj.frequency_penalty ?? openAISettings.frequency_penalty.default,
436
+ resendFiles:
437
+ typeof obj.resendFiles === 'boolean' ? obj.resendFiles : openAISettings.resendFiles.default,
438
+ imageDetail: obj.imageDetail ?? openAISettings.imageDetail.default,
439
+ stop: obj.stop ?? undefined,
440
+ iconURL: obj.iconURL ?? undefined,
441
+ greeting: obj.greeting ?? undefined,
442
+ spec: obj.spec ?? undefined,
443
+ maxContextTokens: obj.maxContextTokens ?? undefined,
444
+ max_tokens: obj.max_tokens ?? undefined,
445
+ };
446
+
447
+ if (obj.modelLabel) {
448
+ result.modelLabel = null;
449
+ }
450
+
451
+ return result;
452
+ })
422
453
  .catch(() => ({
423
454
  model: openAISettings.model.default,
424
455
  chatGptLabel: null,
@@ -605,27 +636,35 @@ export const gptPluginsSchema = tConversationSchema
605
636
  spec: true,
606
637
  maxContextTokens: true,
607
638
  })
608
- .transform((obj) => ({
609
- ...obj,
610
- model: obj.model ?? 'gpt-3.5-turbo',
611
- chatGptLabel: obj.modelLabel ?? obj.chatGptLabel ?? null,
612
- promptPrefix: obj.promptPrefix ?? null,
613
- temperature: obj.temperature ?? 0.8,
614
- top_p: obj.top_p ?? 1,
615
- presence_penalty: obj.presence_penalty ?? 0,
616
- frequency_penalty: obj.frequency_penalty ?? 0,
617
- tools: obj.tools ?? [],
618
- agentOptions: obj.agentOptions ?? {
619
- agent: EAgent.functions,
620
- skipCompletion: true,
621
- model: 'gpt-3.5-turbo',
622
- temperature: 0,
623
- },
624
- iconURL: obj.iconURL ?? undefined,
625
- greeting: obj.greeting ?? undefined,
626
- spec: obj.spec ?? undefined,
627
- maxContextTokens: obj.maxContextTokens ?? undefined,
628
- }))
639
+ .transform((obj) => {
640
+ const result = {
641
+ ...obj,
642
+ model: obj.model ?? 'gpt-3.5-turbo',
643
+ chatGptLabel: obj.chatGptLabel ?? obj.modelLabel ?? null,
644
+ promptPrefix: obj.promptPrefix ?? null,
645
+ temperature: obj.temperature ?? 0.8,
646
+ top_p: obj.top_p ?? 1,
647
+ presence_penalty: obj.presence_penalty ?? 0,
648
+ frequency_penalty: obj.frequency_penalty ?? 0,
649
+ tools: obj.tools ?? [],
650
+ agentOptions: obj.agentOptions ?? {
651
+ agent: EAgent.functions,
652
+ skipCompletion: true,
653
+ model: 'gpt-3.5-turbo',
654
+ temperature: 0,
655
+ },
656
+ iconURL: obj.iconURL ?? undefined,
657
+ greeting: obj.greeting ?? undefined,
658
+ spec: obj.spec ?? undefined,
659
+ maxContextTokens: obj.maxContextTokens ?? undefined,
660
+ };
661
+
662
+ if (obj.modelLabel) {
663
+ result.modelLabel = null;
664
+ }
665
+
666
+ return result;
667
+ })
629
668
  .catch(() => ({
630
669
  model: 'gpt-3.5-turbo',
631
670
  chatGptLabel: null,
@@ -1,4 +1,5 @@
1
1
  import type { OpenAPIV3 } from 'openapi-types';
2
+ import type { AssistantsEndpoint } from 'src/schemas';
2
3
  import type { TFile } from './files';
3
4
 
4
5
  export type Schema = OpenAPIV3.SchemaObject & { description?: string };
@@ -10,10 +11,16 @@ export type Metadata = {
10
11
 
11
12
  export enum Tools {
12
13
  code_interpreter = 'code_interpreter',
14
+ file_search = 'file_search',
13
15
  retrieval = 'retrieval',
14
16
  function = 'function',
15
17
  }
16
18
 
19
+ export enum EToolResources {
20
+ code_interpreter = 'code_interpreter',
21
+ file_search = 'file_search',
22
+ }
23
+
17
24
  export type Tool = {
18
25
  [type: string]: Tools;
19
26
  };
@@ -27,6 +34,35 @@ export type FunctionTool = {
27
34
  };
28
35
  };
29
36
 
37
+ /**
38
+ * A set of resources that are used by the assistant's tools. The resources are
39
+ * specific to the type of tool. For example, the `code_interpreter` tool requires
40
+ * a list of file IDs, while the `file_search` tool requires a list of vector store
41
+ * IDs.
42
+ */
43
+ export interface ToolResources {
44
+ code_interpreter?: CodeInterpreterResource;
45
+ file_search?: FileSearchResource;
46
+ }
47
+ export interface CodeInterpreterResource {
48
+ /**
49
+ * A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
50
+ * available to the `code_interpreter`` tool. There can be a maximum of 20 files
51
+ * associated with the tool.
52
+ */
53
+ file_ids?: Array<string>;
54
+ }
55
+
56
+ export interface FileSearchResource {
57
+ /**
58
+ * The ID of the
59
+ * [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
60
+ * attached to this assistant. There can be a maximum of 1 vector store attached to
61
+ * the assistant.
62
+ */
63
+ vector_store_ids?: Array<string>;
64
+ }
65
+
30
66
  export type Assistant = {
31
67
  id: string;
32
68
  created_at: number;
@@ -38,8 +74,11 @@ export type Assistant = {
38
74
  name: string | null;
39
75
  object: string;
40
76
  tools: FunctionTool[];
77
+ tool_resources?: ToolResources;
41
78
  };
42
79
 
80
+ export type TAssistantsMap = Record<AssistantsEndpoint, Record<string, Assistant>>;
81
+
43
82
  export type AssistantCreateParams = {
44
83
  model: string;
45
84
  description?: string | null;
@@ -48,6 +87,8 @@ export type AssistantCreateParams = {
48
87
  metadata?: Metadata | null;
49
88
  name?: string | null;
50
89
  tools?: Array<FunctionTool | string>;
90
+ endpoint: AssistantsEndpoint;
91
+ version: number | string;
51
92
  };
52
93
 
53
94
  export type AssistantUpdateParams = {
@@ -58,6 +99,8 @@ export type AssistantUpdateParams = {
58
99
  metadata?: Metadata | null;
59
100
  name?: string | null;
60
101
  tools?: Array<FunctionTool | string>;
102
+ tool_resources?: ToolResources;
103
+ endpoint: AssistantsEndpoint;
61
104
  };
62
105
 
63
106
  export type AssistantListParams = {
@@ -65,6 +108,7 @@ export type AssistantListParams = {
65
108
  before?: string | null;
66
109
  after?: string | null;
67
110
  order?: 'asc' | 'desc';
111
+ endpoint: AssistantsEndpoint;
68
112
  };
69
113
 
70
114
  export type AssistantListResponse = {
@@ -123,12 +167,22 @@ export type RetrievalToolCall = {
123
167
  type: 'retrieval'; // The type of tool call, always 'retrieval'.
124
168
  };
125
169
 
170
+ /**
171
+ * Details of a Retrieval tool call the run step was involved in.
172
+ * Includes the tool call ID and the type of tool call.
173
+ */
174
+ export type FileSearchToolCall = {
175
+ id: string; // The ID of the tool call object.
176
+ file_search: unknown; // An empty object for now.
177
+ type: 'file_search'; // The type of tool call, always 'retrieval'.
178
+ };
179
+
126
180
  /**
127
181
  * Details of the tool calls involved in a run step.
128
182
  * Can be associated with one of three types of tools: `code_interpreter`, `retrieval`, or `function`.
129
183
  */
130
184
  export type ToolCallsStepDetails = {
131
- tool_calls: Array<CodeToolCall | RetrievalToolCall | FunctionToolCall>; // An array of tool calls the run step was involved in.
185
+ tool_calls: Array<CodeToolCall | RetrievalToolCall | FileSearchToolCall | FunctionToolCall>; // An array of tool calls the run step was involved in.
132
186
  type: 'tool_calls'; // Always 'tool_calls'.
133
187
  };
134
188
 
@@ -203,6 +257,7 @@ export enum StepTypes {
203
257
  export enum ToolCallTypes {
204
258
  FUNCTION = 'function',
205
259
  RETRIEVAL = 'retrieval',
260
+ FILE_SEARCH = 'file_search',
206
261
  CODE_INTERPRETER = 'code_interpreter',
207
262
  }
208
263
 
@@ -239,7 +294,14 @@ export type PartMetadata = {
239
294
  action?: boolean;
240
295
  };
241
296
 
242
- export type ContentPart = (CodeToolCall | RetrievalToolCall | FunctionToolCall | ImageFile | Text) &
297
+ export type ContentPart = (
298
+ | CodeToolCall
299
+ | RetrievalToolCall
300
+ | FileSearchToolCall
301
+ | FunctionToolCall
302
+ | ImageFile
303
+ | Text
304
+ ) &
243
305
  PartMetadata;
244
306
 
245
307
  export type TMessageContentParts =
@@ -247,7 +309,8 @@ export type TMessageContentParts =
247
309
  | { type: ContentTypes.TEXT; text: Text & PartMetadata }
248
310
  | {
249
311
  type: ContentTypes.TOOL_CALL;
250
- tool_call: (CodeToolCall | RetrievalToolCall | FunctionToolCall) & PartMetadata;
312
+ tool_call: (CodeToolCall | RetrievalToolCall | FileSearchToolCall | FunctionToolCall) &
313
+ PartMetadata;
251
314
  }
252
315
  | { type: ContentTypes.IMAGE_FILE; image_file: ImageFile & PartMetadata };
253
316
 
@@ -315,6 +378,7 @@ export type Action = {
315
378
  type?: string;
316
379
  settings?: Record<string, unknown>;
317
380
  metadata: ActionMetadata;
381
+ version: number | string;
318
382
  };
319
383
 
320
384
  export type AssistantAvatar = {
@@ -334,6 +398,7 @@ export type AssistantDocument = {
334
398
  };
335
399
 
336
400
  export enum FilePurpose {
401
+ Vision = 'vision',
337
402
  FineTune = 'fine-tune',
338
403
  FineTuneResults = 'fine-tune-results',
339
404
  Assistants = 'assistants',
@@ -1,11 +1,17 @@
1
+ import { EToolResources } from './assistants';
2
+
1
3
  export enum FileSources {
2
4
  local = 'local',
3
5
  firebase = 'firebase',
6
+ azure = 'azure',
4
7
  openai = 'openai',
5
8
  s3 = 's3',
6
9
  vectordb = 'vectordb',
7
10
  }
8
11
 
12
+ export const checkOpenAIStorage = (source: string) =>
13
+ source === FileSources.openai || source === FileSources.azure;
14
+
9
15
  export enum FileContext {
10
16
  avatar = 'avatar',
11
17
  unknown = 'unknown',
@@ -54,6 +60,7 @@ export type TFile = {
54
60
  usage: number;
55
61
  context?: FileContext;
56
62
  source?: FileSources;
63
+ filterSource?: FileSources;
57
64
  width?: number;
58
65
  height?: number;
59
66
  expiresAt?: string | Date;
@@ -97,6 +104,7 @@ export type BatchFile = {
97
104
  export type DeleteFilesBody = {
98
105
  files: BatchFile[];
99
106
  assistant_id?: string;
107
+ tool_resource?: EToolResources;
100
108
  };
101
109
 
102
110
  export type DeleteMutationOptions = {
@@ -45,6 +45,8 @@ export type AssistantAvatarVariables = {
45
45
  model: string;
46
46
  formData: FormData;
47
47
  postCreation?: boolean;
48
+ endpoint: types.AssistantsEndpoint;
49
+ version: number | string;
48
50
  };
49
51
 
50
52
  export type UpdateActionVariables = {
@@ -53,6 +55,8 @@ export type UpdateActionVariables = {
53
55
  metadata: ActionMetadata;
54
56
  action_id?: string;
55
57
  model: string;
58
+ endpoint: types.AssistantsEndpoint;
59
+ version: number | string;
56
60
  };
57
61
 
58
62
  export type UploadAssistantAvatarOptions = MutationOptions<Assistant, AssistantAvatarVariables>;
@@ -66,7 +70,11 @@ export type UpdateAssistantVariables = {
66
70
 
67
71
  export type UpdateAssistantMutationOptions = MutationOptions<Assistant, UpdateAssistantVariables>;
68
72
 
69
- export type DeleteAssistantBody = { assistant_id: string; model: string };
73
+ export type DeleteAssistantBody = {
74
+ assistant_id: string;
75
+ model: string;
76
+ endpoint: types.AssistantsEndpoint;
77
+ };
70
78
 
71
79
  export type DeleteAssistantMutationOptions = MutationOptions<
72
80
  void,
@@ -77,6 +85,7 @@ export type UpdateActionResponse = [AssistantDocument, Assistant, Action];
77
85
  export type UpdateActionOptions = MutationOptions<UpdateActionResponse, UpdateActionVariables>;
78
86
 
79
87
  export type DeleteActionVariables = {
88
+ endpoint: types.AssistantsEndpoint;
80
89
  assistant_id: string;
81
90
  action_id: string;
82
91
  model: string;
@@ -90,3 +99,13 @@ export type DeleteConversationOptions = MutationOptions<
90
99
  >;
91
100
 
92
101
  export type ForkConvoOptions = MutationOptions<types.TForkConvoResponse, types.TForkConvoRequest>;
102
+
103
+ export type CreateSharedLinkOptions = MutationOptions<
104
+ types.TSharedLink,
105
+ Partial<types.TSharedLink>
106
+ >;
107
+ export type UpdateSharedLinkOptions = MutationOptions<
108
+ types.TSharedLink,
109
+ Partial<types.TSharedLink>
110
+ >;
111
+ export type DeleteSharedLinkOptions = MutationOptions<types.TSharedLink, { shareId: string }>;
@@ -1,5 +1,5 @@
1
1
  import type { InfiniteData } from '@tanstack/react-query';
2
- import type { TMessage, TConversation } from '../schemas';
2
+ import type { TMessage, TConversation, TSharedLink } from '../schemas';
3
3
  export type Conversation = {
4
4
  id: string;
5
5
  createdAt: number;
@@ -16,7 +16,7 @@ export type ConversationListParams = {
16
16
  order?: 'asc' | 'desc';
17
17
  pageNumber: string; // Add this line
18
18
  conversationId?: string;
19
- isArchived: boolean;
19
+ isArchived?: boolean;
20
20
  };
21
21
 
22
22
  // Type for the response from the conversation list API
@@ -33,3 +33,24 @@ export type ConversationUpdater = (
33
33
  data: ConversationData,
34
34
  conversation: TConversation,
35
35
  ) => ConversationData;
36
+
37
+ export type SharedMessagesResponse = Omit<TSharedLink, 'messages'> & {
38
+ messages: TMessage[];
39
+ };
40
+ export type SharedLinkListParams = Omit<ConversationListParams, 'isArchived' | 'conversationId'> & {
41
+ isPublic?: boolean;
42
+ };
43
+
44
+ export type SharedLinksResponse = Omit<ConversationListResponse, 'conversations' | 'messages'> & {
45
+ sharedLinks: TSharedLink[];
46
+ };
47
+
48
+ // Type for the response from the conversation list API
49
+ export type SharedLinkListResponse = {
50
+ sharedLinks: TSharedLink[];
51
+ pageNumber: string;
52
+ pageSize: string | number;
53
+ pages: string | number;
54
+ };
55
+
56
+ export type SharedLinkListData = InfiniteData<SharedLinkListResponse>;
package/src/types.ts CHANGED
@@ -1,5 +1,12 @@
1
1
  import OpenAI from 'openai';
2
- import type { TResPlugin, TMessage, TConversation, EModelEndpoint, ImageDetail } from './schemas';
2
+ import type {
3
+ TResPlugin,
4
+ TMessage,
5
+ TConversation,
6
+ EModelEndpoint,
7
+ ImageDetail,
8
+ TSharedLink,
9
+ } from './schemas';
3
10
  import type { TSpecsConfig } from './models';
4
11
  export type TOpenAIMessage = OpenAI.Chat.ChatCompletionMessageParam;
5
12
  export type TOpenAIFunction = OpenAI.Chat.ChatCompletionCreateParams.Function;
@@ -133,6 +140,19 @@ export type TArchiveConversationRequest = {
133
140
 
134
141
  export type TArchiveConversationResponse = TConversation;
135
142
 
143
+ export type TSharedMessagesResponse = Omit<TSharedLink, 'messages'> & {
144
+ messages: TMessage[];
145
+ };
146
+ export type TSharedLinkRequest = Partial<
147
+ Omit<TSharedLink, 'messages' | 'createdAt' | 'updatedAt'>
148
+ > & {
149
+ conversationId: string;
150
+ };
151
+
152
+ export type TSharedLinkResponse = TSharedLink;
153
+ export type TSharedLinksResponse = TSharedLink[];
154
+ export type TDeleteSharedLinkResponse = TSharedLink;
155
+
136
156
  export type TForkConvoRequest = {
137
157
  messageId: string;
138
158
  conversationId: string;
@@ -163,6 +183,7 @@ export type TConfig = {
163
183
  plugins?: Record<string, string>;
164
184
  name?: string;
165
185
  iconURL?: string;
186
+ version?: string;
166
187
  modelDisplayLabel?: string;
167
188
  userProvide?: boolean | null;
168
189
  userProvideURL?: boolean | null;