librechat-data-provider 0.7.78 → 0.7.82

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
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { Tools } from './types/assistants';
3
3
  import type { TMessageContentParts, FunctionTool, FunctionToolCall } from './types/assistants';
4
+ import type { TEphemeralAgent } from './types';
4
5
  import type { TFile } from './types/files';
5
6
 
6
7
  export const isUUID = z.string().uuid();
@@ -88,6 +89,21 @@ export const isAgentsEndpoint = (_endpoint?: EModelEndpoint.agents | null | stri
88
89
  return endpoint === EModelEndpoint.agents;
89
90
  };
90
91
 
92
+ export const isEphemeralAgent = (
93
+ endpoint?: EModelEndpoint.agents | null | string,
94
+ ephemeralAgent?: TEphemeralAgent | null,
95
+ ) => {
96
+ if (!ephemeralAgent) {
97
+ return false;
98
+ }
99
+ if (isAgentsEndpoint(endpoint)) {
100
+ return false;
101
+ }
102
+ const hasMCPSelected = (ephemeralAgent?.mcp?.length ?? 0) > 0;
103
+ const hasCodeSelected = (ephemeralAgent?.execute_code ?? false) === true;
104
+ return hasMCPSelected || hasCodeSelected;
105
+ };
106
+
91
107
  export const isParamEndpoint = (
92
108
  endpoint: EModelEndpoint | string,
93
109
  endpointType?: EModelEndpoint | string,
@@ -401,6 +417,7 @@ export const tPluginSchema = z.object({
401
417
  icon: z.string().optional(),
402
418
  authConfig: z.array(tPluginAuthConfigSchema).optional(),
403
419
  authenticated: z.boolean().optional(),
420
+ chatMenu: z.boolean().optional(),
404
421
  isButton: z.boolean().optional(),
405
422
  toolkit: z.boolean().optional(),
406
423
  });
@@ -639,6 +656,8 @@ export const tPresetSchema = tConversationSchema
639
656
  export const tConvoUpdateSchema = tConversationSchema.merge(
640
657
  z.object({
641
658
  endpoint: extendedModelEndpointSchema.nullable(),
659
+ createdAt: z.string().optional(),
660
+ updatedAt: z.string().optional(),
642
661
  }),
643
662
  );
644
663
 
@@ -752,22 +771,23 @@ export const tConversationTagSchema = z.object({
752
771
  });
753
772
  export type TConversationTag = z.infer<typeof tConversationTagSchema>;
754
773
 
755
- export const googleSchema = tConversationSchema
756
- .pick({
757
- model: true,
758
- modelLabel: true,
759
- promptPrefix: true,
760
- examples: true,
761
- temperature: true,
762
- maxOutputTokens: true,
763
- artifacts: true,
764
- topP: true,
765
- topK: true,
766
- iconURL: true,
767
- greeting: true,
768
- spec: true,
769
- maxContextTokens: true,
770
- })
774
+ export const googleBaseSchema = tConversationSchema.pick({
775
+ model: true,
776
+ modelLabel: true,
777
+ promptPrefix: true,
778
+ examples: true,
779
+ temperature: true,
780
+ maxOutputTokens: true,
781
+ artifacts: true,
782
+ topP: true,
783
+ topK: true,
784
+ iconURL: true,
785
+ greeting: true,
786
+ spec: true,
787
+ maxContextTokens: true,
788
+ });
789
+
790
+ export const googleSchema = googleBaseSchema
771
791
  .transform((obj: Partial<TConversation>) => removeNullishValues(obj))
772
792
  .catch(() => ({}));
773
793
 
@@ -790,36 +810,25 @@ export const googleGenConfigSchema = z
790
810
  .strip()
791
811
  .optional();
792
812
 
793
- export const chatGPTBrowserSchema = tConversationSchema
794
- .pick({
795
- model: true,
796
- })
797
- .transform((obj) => ({
798
- ...obj,
799
- model: obj.model ?? 'text-davinci-002-render-sha',
800
- }))
801
- .catch(() => ({
802
- model: 'text-davinci-002-render-sha',
803
- }));
813
+ const gptPluginsBaseSchema = tConversationSchema.pick({
814
+ model: true,
815
+ modelLabel: true,
816
+ chatGptLabel: true,
817
+ promptPrefix: true,
818
+ temperature: true,
819
+ artifacts: true,
820
+ top_p: true,
821
+ presence_penalty: true,
822
+ frequency_penalty: true,
823
+ tools: true,
824
+ agentOptions: true,
825
+ iconURL: true,
826
+ greeting: true,
827
+ spec: true,
828
+ maxContextTokens: true,
829
+ });
804
830
 
805
- export const gptPluginsSchema = tConversationSchema
806
- .pick({
807
- model: true,
808
- modelLabel: true,
809
- chatGptLabel: true,
810
- promptPrefix: true,
811
- temperature: true,
812
- artifacts: true,
813
- top_p: true,
814
- presence_penalty: true,
815
- frequency_penalty: true,
816
- tools: true,
817
- agentOptions: true,
818
- iconURL: true,
819
- greeting: true,
820
- spec: true,
821
- maxContextTokens: true,
822
- })
831
+ export const gptPluginsSchema = gptPluginsBaseSchema
823
832
  .transform((obj) => {
824
833
  const result = {
825
834
  ...obj,
@@ -889,18 +898,19 @@ export function removeNullishValues<T extends Record<string, unknown>>(
889
898
  return newObj;
890
899
  }
891
900
 
892
- export const assistantSchema = tConversationSchema
893
- .pick({
894
- model: true,
895
- assistant_id: true,
896
- instructions: true,
897
- artifacts: true,
898
- promptPrefix: true,
899
- iconURL: true,
900
- greeting: true,
901
- spec: true,
902
- append_current_datetime: true,
903
- })
901
+ const assistantBaseSchema = tConversationSchema.pick({
902
+ model: true,
903
+ assistant_id: true,
904
+ instructions: true,
905
+ artifacts: true,
906
+ promptPrefix: true,
907
+ iconURL: true,
908
+ greeting: true,
909
+ spec: true,
910
+ append_current_datetime: true,
911
+ });
912
+
913
+ export const assistantSchema = assistantBaseSchema
904
914
  .transform((obj) => ({
905
915
  ...obj,
906
916
  model: obj.model ?? openAISettings.model.default,
@@ -923,37 +933,39 @@ export const assistantSchema = tConversationSchema
923
933
  append_current_datetime: false,
924
934
  }));
925
935
 
926
- export const compactAssistantSchema = tConversationSchema
927
- .pick({
928
- model: true,
929
- assistant_id: true,
930
- instructions: true,
931
- promptPrefix: true,
932
- artifacts: true,
933
- iconURL: true,
934
- greeting: true,
935
- spec: true,
936
- })
936
+ const compactAssistantBaseSchema = tConversationSchema.pick({
937
+ model: true,
938
+ assistant_id: true,
939
+ instructions: true,
940
+ promptPrefix: true,
941
+ artifacts: true,
942
+ iconURL: true,
943
+ greeting: true,
944
+ spec: true,
945
+ });
946
+
947
+ export const compactAssistantSchema = compactAssistantBaseSchema
937
948
  .transform((obj) => removeNullishValues(obj))
938
949
  .catch(() => ({}));
939
950
 
940
- export const agentsSchema = tConversationSchema
941
- .pick({
942
- model: true,
943
- modelLabel: true,
944
- temperature: true,
945
- top_p: true,
946
- presence_penalty: true,
947
- frequency_penalty: true,
948
- resendFiles: true,
949
- imageDetail: true,
950
- agent_id: true,
951
- instructions: true,
952
- promptPrefix: true,
953
- iconURL: true,
954
- greeting: true,
955
- maxContextTokens: true,
956
- })
951
+ export const agentsBaseSchema = tConversationSchema.pick({
952
+ model: true,
953
+ modelLabel: true,
954
+ temperature: true,
955
+ top_p: true,
956
+ presence_penalty: true,
957
+ frequency_penalty: true,
958
+ resendFiles: true,
959
+ imageDetail: true,
960
+ agent_id: true,
961
+ instructions: true,
962
+ promptPrefix: true,
963
+ iconURL: true,
964
+ greeting: true,
965
+ maxContextTokens: true,
966
+ });
967
+
968
+ export const agentsSchema = agentsBaseSchema
957
969
  .transform((obj) => ({
958
970
  ...obj,
959
971
  model: obj.model ?? agentsSettings.model.default,
@@ -989,46 +1001,32 @@ export const agentsSchema = tConversationSchema
989
1001
  maxContextTokens: undefined,
990
1002
  }));
991
1003
 
992
- export const openAISchema = tConversationSchema
993
- .pick({
994
- model: true,
995
- modelLabel: true,
996
- chatGptLabel: true,
997
- promptPrefix: true,
998
- temperature: true,
999
- top_p: true,
1000
- presence_penalty: true,
1001
- frequency_penalty: true,
1002
- resendFiles: true,
1003
- artifacts: true,
1004
- imageDetail: true,
1005
- stop: true,
1006
- iconURL: true,
1007
- greeting: true,
1008
- spec: true,
1009
- maxContextTokens: true,
1010
- max_tokens: true,
1011
- reasoning_effort: true,
1012
- })
1004
+ export const openAIBaseSchema = tConversationSchema.pick({
1005
+ model: true,
1006
+ modelLabel: true,
1007
+ chatGptLabel: true,
1008
+ promptPrefix: true,
1009
+ temperature: true,
1010
+ top_p: true,
1011
+ presence_penalty: true,
1012
+ frequency_penalty: true,
1013
+ resendFiles: true,
1014
+ artifacts: true,
1015
+ imageDetail: true,
1016
+ stop: true,
1017
+ iconURL: true,
1018
+ greeting: true,
1019
+ spec: true,
1020
+ maxContextTokens: true,
1021
+ max_tokens: true,
1022
+ reasoning_effort: true,
1023
+ });
1024
+
1025
+ export const openAISchema = openAIBaseSchema
1013
1026
  .transform((obj: Partial<TConversation>) => removeNullishValues(obj))
1014
1027
  .catch(() => ({}));
1015
1028
 
1016
- export const compactGoogleSchema = tConversationSchema
1017
- .pick({
1018
- model: true,
1019
- modelLabel: true,
1020
- promptPrefix: true,
1021
- examples: true,
1022
- temperature: true,
1023
- maxOutputTokens: true,
1024
- artifacts: true,
1025
- topP: true,
1026
- topK: true,
1027
- iconURL: true,
1028
- greeting: true,
1029
- spec: true,
1030
- maxContextTokens: true,
1031
- })
1029
+ export const compactGoogleSchema = googleBaseSchema
1032
1030
  .transform((obj) => {
1033
1031
  const newObj: Partial<TConversation> = { ...obj };
1034
1032
  if (newObj.temperature === google.temperature.default) {
@@ -1048,55 +1046,30 @@ export const compactGoogleSchema = tConversationSchema
1048
1046
  })
1049
1047
  .catch(() => ({}));
1050
1048
 
1051
- export const anthropicSchema = tConversationSchema
1052
- .pick({
1053
- model: true,
1054
- modelLabel: true,
1055
- promptPrefix: true,
1056
- temperature: true,
1057
- maxOutputTokens: true,
1058
- topP: true,
1059
- topK: true,
1060
- resendFiles: true,
1061
- promptCache: true,
1062
- thinking: true,
1063
- thinkingBudget: true,
1064
- artifacts: true,
1065
- iconURL: true,
1066
- greeting: true,
1067
- spec: true,
1068
- maxContextTokens: true,
1069
- })
1070
- .transform((obj) => removeNullishValues(obj))
1071
- .catch(() => ({}));
1049
+ export const anthropicBaseSchema = tConversationSchema.pick({
1050
+ model: true,
1051
+ modelLabel: true,
1052
+ promptPrefix: true,
1053
+ temperature: true,
1054
+ maxOutputTokens: true,
1055
+ topP: true,
1056
+ topK: true,
1057
+ resendFiles: true,
1058
+ promptCache: true,
1059
+ thinking: true,
1060
+ thinkingBudget: true,
1061
+ artifacts: true,
1062
+ iconURL: true,
1063
+ greeting: true,
1064
+ spec: true,
1065
+ maxContextTokens: true,
1066
+ });
1072
1067
 
1073
- export const compactChatGPTSchema = tConversationSchema
1074
- .pick({
1075
- model: true,
1076
- })
1077
- .transform((obj) => {
1078
- const newObj: Partial<TConversation> = { ...obj };
1079
- return removeNullishValues(newObj);
1080
- })
1068
+ export const anthropicSchema = anthropicBaseSchema
1069
+ .transform((obj) => removeNullishValues(obj))
1081
1070
  .catch(() => ({}));
1082
1071
 
1083
- export const compactPluginsSchema = tConversationSchema
1084
- .pick({
1085
- model: true,
1086
- modelLabel: true,
1087
- chatGptLabel: true,
1088
- promptPrefix: true,
1089
- temperature: true,
1090
- top_p: true,
1091
- presence_penalty: true,
1092
- frequency_penalty: true,
1093
- tools: true,
1094
- agentOptions: true,
1095
- iconURL: true,
1096
- greeting: true,
1097
- spec: true,
1098
- maxContextTokens: true,
1099
- })
1072
+ export const compactPluginsSchema = gptPluginsBaseSchema
1100
1073
  .transform((obj) => {
1101
1074
  const newObj: Partial<TConversation> = { ...obj };
1102
1075
  if (newObj.modelLabel === null) {
@@ -1149,15 +1122,16 @@ export const tBannerSchema = z.object({
1149
1122
  });
1150
1123
  export type TBanner = z.infer<typeof tBannerSchema>;
1151
1124
 
1152
- export const compactAgentsSchema = tConversationSchema
1153
- .pick({
1154
- spec: true,
1155
- // model: true,
1156
- iconURL: true,
1157
- greeting: true,
1158
- agent_id: true,
1159
- instructions: true,
1160
- additional_instructions: true,
1161
- })
1125
+ export const compactAgentsBaseSchema = tConversationSchema.pick({
1126
+ spec: true,
1127
+ // model: true,
1128
+ iconURL: true,
1129
+ greeting: true,
1130
+ agent_id: true,
1131
+ instructions: true,
1132
+ additional_instructions: true,
1133
+ });
1134
+
1135
+ export const compactAgentsSchema = compactAgentsBaseSchema
1162
1136
  .transform((obj) => removeNullishValues(obj))
1163
1137
  .catch(() => ({}));
@@ -27,6 +27,7 @@ export enum EToolResources {
27
27
  code_interpreter = 'code_interpreter',
28
28
  execute_code = 'execute_code',
29
29
  file_search = 'file_search',
30
+ image_edit = 'image_edit',
30
31
  ocr = 'ocr',
31
32
  }
32
33
 
@@ -163,15 +164,9 @@ export type AgentModelParameters = {
163
164
  presence_penalty: AgentParameterValue;
164
165
  };
165
166
 
166
- export interface AgentToolResources {
167
- execute_code?: ExecuteCodeResource;
168
- file_search?: AgentFileResource;
169
- ocr?: Omit<AgentFileResource, 'vector_store_ids'>;
170
- }
171
- export interface ExecuteCodeResource {
167
+ export interface AgentBaseResource {
172
168
  /**
173
- * A list of file IDs made available to the `execute_code` tool.
174
- * There can be a maximum of 20 files associated with the tool.
169
+ * A list of file IDs made available to the tool.
175
170
  */
176
171
  file_ids?: Array<string>;
177
172
  /**
@@ -180,21 +175,24 @@ export interface ExecuteCodeResource {
180
175
  files?: Array<TFile>;
181
176
  }
182
177
 
183
- export interface AgentFileResource {
178
+ export interface AgentToolResources {
179
+ [EToolResources.image_edit]?: AgentBaseResource;
180
+ [EToolResources.execute_code]?: ExecuteCodeResource;
181
+ [EToolResources.file_search]?: AgentFileResource;
182
+ [EToolResources.ocr]?: AgentBaseResource;
183
+ }
184
+ /**
185
+ * A resource for the execute_code tool.
186
+ * Contains file IDs made available to the tool (max 20 files) and already fetched files.
187
+ */
188
+ export type ExecuteCodeResource = AgentBaseResource;
189
+
190
+ export interface AgentFileResource extends AgentBaseResource {
184
191
  /**
185
192
  * The ID of the vector store attached to this agent. There
186
193
  * can be a maximum of 1 vector store attached to the agent.
187
194
  */
188
195
  vector_store_ids?: Array<string>;
189
- /**
190
- * A list of file IDs made available to the `file_search` tool.
191
- * To be used before vector stores are implemented.
192
- */
193
- file_ids?: Array<string>;
194
- /**
195
- * A list of files already fetched.
196
- */
197
- files?: Array<TFile>;
198
196
  }
199
197
 
200
198
  export type Agent = {
@@ -1,5 +1,6 @@
1
1
  import * as types from '../types';
2
2
  import * as r from '../roles';
3
+ import * as p from '../permissions';
3
4
  import {
4
5
  Tools,
5
6
  Assistant,
@@ -163,6 +164,11 @@ export type DeleteConversationOptions = MutationOptions<
163
164
  types.TDeleteConversationRequest
164
165
  >;
165
166
 
167
+ export type ArchiveConversationOptions = MutationOptions<
168
+ types.TArchiveConversationResponse,
169
+ types.TArchiveConversationRequest
170
+ >;
171
+
166
172
  export type DuplicateConvoOptions = MutationOptions<
167
173
  types.TDuplicateConvoResponse,
168
174
  types.TDuplicateConvoRequest
@@ -251,9 +257,9 @@ export type UpdatePermVars<T> = {
251
257
  updates: Partial<T>;
252
258
  };
253
259
 
254
- export type UpdatePromptPermVars = UpdatePermVars<r.TPromptPermissions>;
260
+ export type UpdatePromptPermVars = UpdatePermVars<p.TPromptPermissions>;
255
261
 
256
- export type UpdateAgentPermVars = UpdatePermVars<r.TAgentPermissions>;
262
+ export type UpdateAgentPermVars = UpdatePermVars<p.TAgentPermissions>;
257
263
 
258
264
  export type UpdatePermResponse = r.TRole;
259
265
 
@@ -11,25 +11,23 @@ export type Conversation = {
11
11
  conversations: s.TConversation[];
12
12
  };
13
13
 
14
- // Parameters for listing conversations (e.g., for pagination)
15
14
  export type ConversationListParams = {
16
- limit?: number;
17
- before?: string | null;
18
- after?: string | null;
19
- order?: 'asc' | 'desc';
20
- pageNumber: string;
21
- conversationId?: string;
15
+ cursor?: string;
22
16
  isArchived?: boolean;
17
+ sortBy?: 'title' | 'createdAt' | 'updatedAt';
18
+ sortDirection?: 'asc' | 'desc';
23
19
  tags?: string[];
20
+ search?: string;
24
21
  };
25
22
 
26
- // Type for the response from the conversation list API
23
+ export type MinimalConversation = Pick<
24
+ s.TConversation,
25
+ 'conversationId' | 'endpoint' | 'title' | 'createdAt' | 'updatedAt' | 'user'
26
+ >;
27
+
27
28
  export type ConversationListResponse = {
28
- conversations: s.TConversation[];
29
- pageNumber: string;
30
- pageSize: string | number;
31
- pages: string | number;
32
- messages: s.TMessage[];
29
+ conversations: MinimalConversation[];
30
+ nextCursor: string | null;
33
31
  };
34
32
 
35
33
  export type ConversationData = InfiniteData<ConversationListResponse>;
@@ -38,6 +36,23 @@ export type ConversationUpdater = (
38
36
  conversation: s.TConversation,
39
37
  ) => ConversationData;
40
38
 
39
+ /* Messages */
40
+ export type MessagesListParams = {
41
+ cursor?: string | null;
42
+ sortBy?: 'endpoint' | 'createdAt' | 'updatedAt';
43
+ sortDirection?: 'asc' | 'desc';
44
+ pageSize?: number;
45
+ conversationId?: string;
46
+ messageId?: string;
47
+ search?: string;
48
+ };
49
+
50
+ export type MessagesListResponse = {
51
+ messages: s.TMessage[];
52
+ nextCursor: string | null;
53
+ };
54
+
55
+ /* Shared Links */
41
56
  export type SharedMessagesResponse = Omit<s.TSharedLink, 'messages'> & {
42
57
  messages: s.TMessage[];
43
58
  };
package/src/types.ts CHANGED
@@ -18,6 +18,8 @@ export type TMessages = TMessage[];
18
18
 
19
19
  /* TODO: Cleanup EndpointOption types */
20
20
  export type TEndpointOption = {
21
+ spec?: string | null;
22
+ iconURL?: string | null;
21
23
  endpoint: EModelEndpoint;
22
24
  endpointType?: EModelEndpoint;
23
25
  modelDisplayLabel?: string;
@@ -39,12 +41,18 @@ export type TEndpointOption = {
39
41
  overrideUserMessageId?: string;
40
42
  };
41
43
 
44
+ export type TEphemeralAgent = {
45
+ mcp?: string[];
46
+ execute_code?: boolean;
47
+ };
48
+
42
49
  export type TPayload = Partial<TMessage> &
43
50
  Partial<TEndpointOption> & {
44
51
  isContinued: boolean;
45
52
  conversationId: string | null;
46
53
  messages?: TMessages;
47
54
  isTemporary: boolean;
55
+ ephemeralAgent?: TEphemeralAgent | null;
48
56
  };
49
57
 
50
58
  export type TSubmission = {
@@ -57,10 +65,12 @@ export type TSubmission = {
57
65
  isTemporary: boolean;
58
66
  messages: TMessage[];
59
67
  isRegenerate?: boolean;
68
+ isResubmission?: boolean;
60
69
  initialResponse?: TMessage;
61
70
  conversation: Partial<TConversation>;
62
71
  endpointOption: TEndpointOption;
63
72
  clientTimestamp?: string;
73
+ ephemeralAgent?: TEphemeralAgent | null;
64
74
  };
65
75
 
66
76
  export type EventSubmission = Omit<TSubmission, 'initialResponse'> & { initialResponse: TMessage };