librechat-data-provider 0.7.5 → 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.
Files changed (45) hide show
  1. package/check_updates.sh +1 -0
  2. package/dist/index.es.js +1 -1
  3. package/dist/index.es.js.map +1 -1
  4. package/dist/index.js +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/react-query/index.es.js +1 -1
  7. package/dist/react-query/index.es.js.map +1 -1
  8. package/package.json +4 -4
  9. package/server-rollup.config.js +3 -3
  10. package/specs/actions.spec.ts +424 -35
  11. package/specs/azure.spec.ts +8 -5
  12. package/specs/filetypes.spec.ts +1 -7
  13. package/specs/mcp.spec.ts +52 -0
  14. package/specs/utils.spec.ts +129 -0
  15. package/src/actions.ts +209 -82
  16. package/src/api-endpoints.ts +39 -16
  17. package/src/azure.ts +40 -33
  18. package/src/bedrock.ts +84 -4
  19. package/src/config.ts +199 -95
  20. package/src/createPayload.ts +3 -1
  21. package/src/data-service.ts +114 -20
  22. package/src/file-config.ts +10 -2
  23. package/src/generate.ts +1 -1
  24. package/src/index.ts +7 -4
  25. package/src/keys.ts +6 -0
  26. package/src/mcp.ts +87 -0
  27. package/src/models.ts +1 -1
  28. package/src/parsers.ts +43 -43
  29. package/src/react-query/react-query-service.ts +40 -126
  30. package/src/request.ts +28 -7
  31. package/src/roles.ts +33 -1
  32. package/src/schemas.ts +250 -198
  33. package/src/types/agents.ts +57 -1
  34. package/src/types/assistants.ts +33 -2
  35. package/src/types/files.ts +1 -0
  36. package/src/types/mutations.ts +96 -8
  37. package/src/types/queries.ts +39 -21
  38. package/src/types/runs.ts +1 -0
  39. package/src/types.ts +90 -81
  40. package/src/utils.ts +44 -0
  41. package/src/zod.spec.ts +526 -0
  42. package/src/zod.ts +86 -0
  43. package/tsconfig.json +1 -2
  44. package/specs/parsers.spec.ts +0 -48
  45. package/src/sse.js +0 -242
@@ -41,27 +41,29 @@ export function getSharedMessages(shareId: string): Promise<t.TSharedMessagesRes
41
41
  return request.get(endpoints.shareMessages(shareId));
42
42
  }
43
43
 
44
- export const listSharedLinks = (
45
- params?: q.SharedLinkListParams,
44
+ export const listSharedLinks = async (
45
+ params: q.SharedLinksListParams,
46
46
  ): Promise<q.SharedLinksResponse> => {
47
- const pageNumber = (params?.pageNumber ?? '1') || '1'; // Default to page 1 if not provided
48
- const isPublic = params?.isPublic ?? true; // Default to true if not provided
49
- return request.get(endpoints.getSharedLinks(pageNumber, isPublic));
47
+ const { pageSize, isPublic, sortBy, sortDirection, search, cursor } = params;
48
+
49
+ return request.get(
50
+ endpoints.getSharedLinks(pageSize, isPublic, sortBy, sortDirection, search, cursor),
51
+ );
50
52
  };
51
53
 
52
- export function getSharedLink(shareId: string): Promise<t.TSharedLinkResponse> {
53
- return request.get(endpoints.shareMessages(shareId));
54
+ export function getSharedLink(conversationId: string): Promise<t.TSharedLinkGetResponse> {
55
+ return request.get(endpoints.getSharedLink(conversationId));
54
56
  }
55
57
 
56
- export function createSharedLink(payload: t.TSharedLinkRequest): Promise<t.TSharedLinkResponse> {
57
- return request.post(endpoints.createSharedLink, payload);
58
+ export function createSharedLink(conversationId: string): Promise<t.TSharedLinkResponse> {
59
+ return request.post(endpoints.createSharedLink(conversationId));
58
60
  }
59
61
 
60
- export function updateSharedLink(payload: t.TSharedLinkRequest): Promise<t.TSharedLinkResponse> {
61
- return request.patch(endpoints.updateSharedLink, payload);
62
+ export function updateSharedLink(shareId: string): Promise<t.TSharedLinkResponse> {
63
+ return request.patch(endpoints.updateSharedLink(shareId));
62
64
  }
63
65
 
64
- export function deleteSharedLink(shareId: string): Promise<t.TDeleteSharedLinkResponse> {
66
+ export function deleteSharedLink(shareId: string): Promise<m.TDeleteSharedLinkResponse> {
65
67
  return request.delete(endpoints.shareMessages(shareId));
66
68
  }
67
69
 
@@ -74,6 +76,13 @@ export function updateMessage(payload: t.TUpdateMessageRequest): Promise<unknown
74
76
  return request.put(endpoints.messages(conversationId, messageId), { text });
75
77
  }
76
78
 
79
+ export const editArtifact = async ({
80
+ messageId,
81
+ ...params
82
+ }: m.TEditArtifactRequest): Promise<m.TEditArtifactResponse> => {
83
+ return request.post(`/api/messages/artifact/${messageId}`, params);
84
+ };
85
+
77
86
  export function updateMessageContent(payload: t.TUpdateMessageContent): Promise<unknown> {
78
87
  const { conversationId, messageId, index, text } = payload;
79
88
  if (!conversationId) {
@@ -124,11 +133,11 @@ export const updateTokenCount = (text: string) => {
124
133
  return request.post(endpoints.tokenizer(), { arg: text });
125
134
  };
126
135
 
127
- export const login = (payload: t.TLoginUser) => {
136
+ export const login = (payload: t.TLoginUser): Promise<t.TLoginResponse> => {
128
137
  return request.post(endpoints.login(), payload);
129
138
  };
130
139
 
131
- export const logout = () => {
140
+ export const logout = (): Promise<m.TLogoutResponse> => {
132
141
  return request.post(endpoints.logout());
133
142
  };
134
143
 
@@ -173,7 +182,7 @@ export const updateUserPlugins = (payload: t.TUpdateUserPlugins) => {
173
182
 
174
183
  /* Config */
175
184
 
176
- export const getStartupConfig = (): Promise<t.TStartupConfig> => {
185
+ export const getStartupConfig = (): Promise<config.TStartupConfig> => {
177
186
  return request.get(endpoints.config());
178
187
  };
179
188
 
@@ -304,6 +313,40 @@ export const getAvailableTools = (
304
313
  return request.get(path);
305
314
  };
306
315
 
316
+ export const getVerifyAgentToolAuth = (
317
+ params: q.VerifyToolAuthParams,
318
+ ): Promise<q.VerifyToolAuthResponse> => {
319
+ return request.get(
320
+ endpoints.agents({
321
+ path: `tools/${params.toolId}/auth`,
322
+ }),
323
+ );
324
+ };
325
+
326
+ export const callTool = <T extends m.ToolId>({
327
+ toolId,
328
+ toolParams,
329
+ }: {
330
+ toolId: T;
331
+ toolParams: m.ToolParams<T>;
332
+ }): Promise<m.ToolCallResponse> => {
333
+ return request.post(
334
+ endpoints.agents({
335
+ path: `tools/${toolId}/call`,
336
+ }),
337
+ toolParams,
338
+ );
339
+ };
340
+
341
+ export const getToolCalls = (params: q.GetToolCallParams): Promise<q.ToolCallResults> => {
342
+ return request.get(
343
+ endpoints.agents({
344
+ path: 'tools/calls',
345
+ options: params,
346
+ }),
347
+ );
348
+ };
349
+
307
350
  /* Files */
308
351
 
309
352
  export const getFiles = (): Promise<f.TFile[]> => {
@@ -394,6 +437,16 @@ export const updateAgent = ({
394
437
  );
395
438
  };
396
439
 
440
+ export const duplicateAgent = ({
441
+ agent_id,
442
+ }: m.DuplicateAgentBody): Promise<{ agent: a.Agent; actions: a.Action[] }> => {
443
+ return request.post(
444
+ endpoints.agents({
445
+ path: `${agent_id}/duplicate`,
446
+ }),
447
+ );
448
+ };
449
+
397
450
  export const deleteAgent = ({ agent_id }: m.DeleteAgentBody): Promise<void> => {
398
451
  return request.delete(
399
452
  endpoints.agents({
@@ -461,7 +514,8 @@ export const uploadAvatar = (data: FormData): Promise<f.AvatarUploadResponse> =>
461
514
  export const uploadAssistantAvatar = (data: m.AssistantAvatarVariables): Promise<a.Assistant> => {
462
515
  return request.postMultiPart(
463
516
  endpoints.assistants({
464
- path: `avatar/${data.assistant_id}`,
517
+ isAvatar: true,
518
+ path: `${data.assistant_id}/avatar`,
465
519
  options: { model: data.model, endpoint: data.endpoint },
466
520
  version: data.version,
467
521
  }),
@@ -471,9 +525,7 @@ export const uploadAssistantAvatar = (data: m.AssistantAvatarVariables): Promise
471
525
 
472
526
  export const uploadAgentAvatar = (data: m.AgentAvatarVariables): Promise<a.Agent> => {
473
527
  return request.postMultiPart(
474
- endpoints.agents({
475
- path: `avatar/${data.agent_id}`,
476
- }),
528
+ `${endpoints.images()}/agents/${data.agent_id}/avatar`,
477
529
  data.formData,
478
530
  );
479
531
  };
@@ -526,6 +578,12 @@ export const getCustomConfigSpeech = (): Promise<t.TCustomConfigSpeechResponse>
526
578
 
527
579
  /* conversations */
528
580
 
581
+ export function duplicateConversation(
582
+ payload: t.TDuplicateConvoRequest,
583
+ ): Promise<t.TDuplicateConvoResponse> {
584
+ return request.post(endpoints.duplicateConversation(), payload);
585
+ }
586
+
529
587
  export function forkConversation(payload: t.TForkConvoRequest): Promise<t.TForkConvoResponse> {
530
588
  return request.post(endpoints.forkConversation(), payload);
531
589
  }
@@ -660,10 +718,16 @@ export function getRole(roleName: string): Promise<r.TRole> {
660
718
 
661
719
  export function updatePromptPermissions(
662
720
  variables: m.UpdatePromptPermVars,
663
- ): Promise<m.UpdatePromptPermResponse> {
721
+ ): Promise<m.UpdatePermResponse> {
664
722
  return request.put(endpoints.updatePromptPermissions(variables.roleName), variables.updates);
665
723
  }
666
724
 
725
+ export function updateAgentPermissions(
726
+ variables: m.UpdateAgentPermVars,
727
+ ): Promise<m.UpdatePermResponse> {
728
+ return request.put(endpoints.updateAgentPermissions(variables.roleName), variables.updates);
729
+ }
730
+
667
731
  /* Tags */
668
732
  export function getConversationTags(): Promise<t.TConversationTagsResponse> {
669
733
  return request.get(endpoints.conversationTags());
@@ -710,3 +774,33 @@ export function acceptTerms(): Promise<t.TAcceptTermsResponse> {
710
774
  export function getBanner(): Promise<t.TBannerResponse> {
711
775
  return request.get(endpoints.banner());
712
776
  }
777
+
778
+ export function enableTwoFactor(): Promise<t.TEnable2FAResponse> {
779
+ return request.get(endpoints.enableTwoFactor());
780
+ }
781
+
782
+ export function verifyTwoFactor(
783
+ payload: t.TVerify2FARequest,
784
+ ): Promise<t.TVerify2FAResponse> {
785
+ return request.post(endpoints.verifyTwoFactor(), payload);
786
+ }
787
+
788
+ export function confirmTwoFactor(
789
+ payload: t.TVerify2FARequest,
790
+ ): Promise<t.TVerify2FAResponse> {
791
+ return request.post(endpoints.confirmTwoFactor(), payload);
792
+ }
793
+
794
+ export function disableTwoFactor(): Promise<t.TDisable2FAResponse> {
795
+ return request.post(endpoints.disableTwoFactor());
796
+ }
797
+
798
+ export function regenerateBackupCodes(): Promise<t.TRegenerateBackupCodesResponse> {
799
+ return request.post(endpoints.regenerateBackupCodes());
800
+ }
801
+
802
+ export function verifyTwoFactorTemp(
803
+ payload: t.TVerify2FATempRequest,
804
+ ): Promise<t.TVerify2FATempResponse> {
805
+ return request.post(endpoints.verifyTwoFactorTemp(), payload);
806
+ }
@@ -45,6 +45,7 @@ export const fullMimeTypesList = [
45
45
  'text/x-tex',
46
46
  'text/plain',
47
47
  'text/css',
48
+ 'text/vtt',
48
49
  'image/jpeg',
49
50
  'text/javascript',
50
51
  'image/gif',
@@ -53,6 +54,8 @@ export const fullMimeTypesList = [
53
54
  'application/typescript',
54
55
  'application/xml',
55
56
  'application/zip',
57
+ 'image/svg',
58
+ 'image/svg+xml',
56
59
  ...excelFileTypes,
57
60
  ];
58
61
 
@@ -109,7 +112,7 @@ export const excelMimeTypes =
109
112
  /^application\/(vnd\.ms-excel|msexcel|x-msexcel|x-ms-excel|x-excel|x-dos_ms_excel|xls|x-xls|vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet)$/;
110
113
 
111
114
  export const textMimeTypes =
112
- /^(text\/(x-c|x-csharp|x-c\+\+|x-java|html|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain|css|javascript|csv))$/;
115
+ /^(text\/(x-c|x-csharp|x-c\+\+|x-java|html|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain|css|vtt|javascript|csv))$/;
113
116
 
114
117
  export const applicationMimeTypes =
115
118
  /^(application\/(epub\+zip|csv|json|pdf|x-tar|typescript|vnd\.openxmlformats-officedocument\.(wordprocessingml\.document|presentationml\.presentation|spreadsheetml\.sheet)|xml|zip))$/;
@@ -121,6 +124,8 @@ export const supportedMimeTypes = [
121
124
  excelMimeTypes,
122
125
  applicationMimeTypes,
123
126
  imageMimeTypes,
127
+ /** Supported by LC Code Interpreter PAI */
128
+ /^image\/(svg|svg\+xml)$/,
124
129
  ];
125
130
 
126
131
  export const codeInterpreterMimeTypes = [
@@ -144,10 +149,13 @@ export const codeTypeMapping: { [key: string]: string } = {
144
149
  ts: 'application/typescript',
145
150
  tar: 'application/x-tar',
146
151
  zip: 'application/zip',
152
+ yml: 'application/x-yaml',
153
+ yaml: 'application/x-yaml',
154
+ log: 'text/plain',
147
155
  };
148
156
 
149
157
  export const retrievalMimeTypes = [
150
- /^(text\/(x-c|x-c\+\+|html|x-java|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain|xml))$/,
158
+ /^(text\/(x-c|x-c\+\+|html|x-java|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain|vtt|xml))$/,
151
159
  /^(application\/(json|pdf|vnd\.openxmlformats-officedocument\.(wordprocessingml\.document|presentationml\.presentation)))$/,
152
160
  ];
153
161
 
package/src/generate.ts CHANGED
@@ -414,7 +414,7 @@ export function validateSettingDefinitions(settings: SettingsConfiguration): voi
414
414
 
415
415
  // Default columnSpan
416
416
  if (!setting.columnSpan) {
417
- setting.columnSpan = Math.floor(columns / 2);
417
+ setting.columnSpan = Math.floor((columns ?? 0) / 2);
418
418
  }
419
419
 
420
420
  // Default label to key
package/src/index.ts CHANGED
@@ -7,27 +7,30 @@ export * from './file-config';
7
7
  export * from './artifacts';
8
8
  /* schema helpers */
9
9
  export * from './parsers';
10
+ export * from './zod';
10
11
  /* custom/dynamic configurations */
11
- export * from './models';
12
12
  export * from './generate';
13
+ export * from './models';
14
+ /* mcp */
15
+ export * from './mcp';
13
16
  /* RBAC */
14
17
  export * from './roles';
15
18
  /* types (exports schemas from `./types` as they contain needed in other defs) */
16
19
  export * from './types';
17
20
  export * from './types/agents';
18
21
  export * from './types/assistants';
19
- export * from './types/queries';
20
22
  export * from './types/files';
21
23
  export * from './types/mutations';
24
+ export * from './types/queries';
22
25
  export * from './types/runs';
23
26
  /* query/mutation keys */
24
27
  export * from './keys';
25
28
  /* api call helpers */
26
29
  export * from './headers-helpers';
27
30
  export { default as request } from './request';
28
- import * as dataService from './data-service';
29
31
  export { dataService };
32
+ import * as dataService from './data-service';
30
33
  /* general helpers */
31
- export * from './sse';
34
+ export * from './utils';
32
35
  export * from './actions';
33
36
  export { default as createPayload } from './createPayload';
package/src/keys.ts CHANGED
@@ -25,6 +25,8 @@ export enum QueryKeys {
25
25
  files = 'files',
26
26
  fileConfig = 'fileConfig',
27
27
  tools = 'tools',
28
+ toolAuth = 'toolAuth',
29
+ toolCalls = 'toolCalls',
28
30
  agentTools = 'agentTools',
29
31
  actions = 'actions',
30
32
  assistantDocs = 'assistantDocs',
@@ -51,7 +53,9 @@ export enum MutationKeys {
51
53
  fileDelete = 'fileDelete',
52
54
  updatePreset = 'updatePreset',
53
55
  deletePreset = 'deletePreset',
56
+ loginUser = 'loginUser',
54
57
  logoutUser = 'logoutUser',
58
+ refreshToken = 'refreshToken',
55
59
  avatarUpload = 'avatarUpload',
56
60
  speechToText = 'speechToText',
57
61
  textToSpeech = 'textToSpeech',
@@ -63,4 +67,6 @@ export enum MutationKeys {
63
67
  deleteAgentAction = 'deleteAgentAction',
64
68
  deleteUser = 'deleteUser',
65
69
  updateRole = 'updateRole',
70
+ enableTwoFactor = 'enableTwoFactor',
71
+ verifyTwoFactor = 'verifyTwoFactor',
66
72
  }
package/src/mcp.ts ADDED
@@ -0,0 +1,87 @@
1
+ import { z } from 'zod';
2
+ import { extractEnvVariable } from './utils';
3
+
4
+ const BaseOptionsSchema = z.object({
5
+ iconPath: z.string().optional(),
6
+ timeout: z.number().optional(),
7
+ });
8
+
9
+ export const StdioOptionsSchema = BaseOptionsSchema.extend({
10
+ type: z.literal('stdio').optional(),
11
+ /**
12
+ * The executable to run to start the server.
13
+ */
14
+ command: z.string(),
15
+ /**
16
+ * Command line arguments to pass to the executable.
17
+ */
18
+ args: z.array(z.string()),
19
+ /**
20
+ * The environment to use when spawning the process.
21
+ *
22
+ * If not specified, the result of getDefaultEnvironment() will be used.
23
+ * Environment variables can be referenced using ${VAR_NAME} syntax.
24
+ */
25
+ env: z
26
+ .record(z.string(), z.string())
27
+ .optional()
28
+ .transform((env) => {
29
+ if (!env) {
30
+ return env;
31
+ }
32
+
33
+ const processedEnv: Record<string, string> = {};
34
+ for (const [key, value] of Object.entries(env)) {
35
+ processedEnv[key] = extractEnvVariable(value);
36
+ }
37
+ return processedEnv;
38
+ }),
39
+ /**
40
+ * How to handle stderr of the child process. This matches the semantics of Node's `child_process.spawn`.
41
+ *
42
+ * @type {import('node:child_process').IOType | import('node:stream').Stream | number}
43
+ *
44
+ * The default is "inherit", meaning messages to stderr will be printed to the parent process's stderr.
45
+ */
46
+ stderr: z.any().optional(),
47
+ });
48
+
49
+ export const WebSocketOptionsSchema = BaseOptionsSchema.extend({
50
+ type: z.literal('websocket').optional(),
51
+ url: z
52
+ .string()
53
+ .url()
54
+ .refine(
55
+ (val) => {
56
+ const protocol = new URL(val).protocol;
57
+ return protocol === 'ws:' || protocol === 'wss:';
58
+ },
59
+ {
60
+ message: 'WebSocket URL must start with ws:// or wss://',
61
+ },
62
+ ),
63
+ });
64
+
65
+ export const SSEOptionsSchema = BaseOptionsSchema.extend({
66
+ type: z.literal('sse').optional(),
67
+ url: z
68
+ .string()
69
+ .url()
70
+ .refine(
71
+ (val) => {
72
+ const protocol = new URL(val).protocol;
73
+ return protocol !== 'ws:' && protocol !== 'wss:';
74
+ },
75
+ {
76
+ message: 'SSE URL must not start with ws:// or wss://',
77
+ },
78
+ ),
79
+ });
80
+
81
+ export const MCPOptionsSchema = z.union([
82
+ StdioOptionsSchema,
83
+ WebSocketOptionsSchema,
84
+ SSEOptionsSchema,
85
+ ]);
86
+
87
+ export const MCPServersSchema = z.record(z.string(), MCPOptionsSchema);
package/src/models.ts CHANGED
@@ -37,7 +37,7 @@ export const tModelSpecSchema = z.object({
37
37
  export const specsConfigSchema = z.object({
38
38
  enforce: z.boolean().default(false),
39
39
  prioritize: z.boolean().default(true),
40
- list: z.array(tModelSpecSchema).optional(),
40
+ list: z.array(tModelSpecSchema).min(1),
41
41
  });
42
42
 
43
43
  export type TSpecsConfig = z.infer<typeof specsConfigSchema>;
package/src/parsers.ts CHANGED
@@ -6,7 +6,6 @@ import { ContentTypes } from './types/runs';
6
6
  import {
7
7
  openAISchema,
8
8
  googleSchema,
9
- bingAISchema,
10
9
  EModelEndpoint,
11
10
  anthropicSchema,
12
11
  assistantSchema,
@@ -20,12 +19,12 @@ import {
20
19
  compactAssistantSchema,
21
20
  } from './schemas';
22
21
  import { bedrockInputSchema } from './bedrock';
22
+ import { extractEnvVariable } from './utils';
23
23
  import { alternateName } from './config';
24
24
 
25
25
  type EndpointSchema =
26
26
  | typeof openAISchema
27
27
  | typeof googleSchema
28
- | typeof bingAISchema
29
28
  | typeof anthropicSchema
30
29
  | typeof chatGPTBrowserSchema
31
30
  | typeof gptPluginsSchema
@@ -38,7 +37,6 @@ const endpointSchemas: Record<EModelEndpoint, EndpointSchema> = {
38
37
  [EModelEndpoint.azureOpenAI]: openAISchema,
39
38
  [EModelEndpoint.custom]: openAISchema,
40
39
  [EModelEndpoint.google]: googleSchema,
41
- [EModelEndpoint.bingAI]: bingAISchema,
42
40
  [EModelEndpoint.anthropic]: anthropicSchema,
43
41
  [EModelEndpoint.chatGPTBrowser]: chatGPTBrowserSchema,
44
42
  [EModelEndpoint.gptPlugins]: gptPluginsSchema,
@@ -61,7 +59,6 @@ export function getEnabledEndpoints() {
61
59
  EModelEndpoint.azureAssistants,
62
60
  EModelEndpoint.azureOpenAI,
63
61
  EModelEndpoint.google,
64
- EModelEndpoint.bingAI,
65
62
  EModelEndpoint.chatGPTBrowser,
66
63
  EModelEndpoint.gptPlugins,
67
64
  EModelEndpoint.anthropic,
@@ -126,18 +123,6 @@ export function errorsToString(errors: ZodIssue[]) {
126
123
  .join(' ');
127
124
  }
128
125
 
129
- export const envVarRegex = /^\${(.+)}$/;
130
-
131
- /** Extracts the value of an environment variable from a string. */
132
- export function extractEnvVariable(value: string) {
133
- const envVarMatch = value.match(envVarRegex);
134
- if (envVarMatch) {
135
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
136
- return process.env[envVarMatch[1]] || value;
137
- }
138
- return value;
139
- }
140
-
141
126
  /** Resolves header values to env variables if detected */
142
127
  export function resolveHeaders(headers: Record<string, string> | undefined) {
143
128
  const resolvedHeaders = { ...(headers ?? {}) };
@@ -183,7 +168,7 @@ export const parseConvo = ({
183
168
  possibleValues,
184
169
  }: {
185
170
  endpoint: EModelEndpoint;
186
- endpointType?: EModelEndpoint;
171
+ endpointType?: EModelEndpoint | null;
187
172
  conversation: Partial<s.TConversation | s.TPreset> | null;
188
173
  possibleValues?: TPossibleValues;
189
174
  // TODO: POC for default schema
@@ -215,6 +200,29 @@ export const parseConvo = ({
215
200
  return convo;
216
201
  };
217
202
 
203
+ /** Match GPT followed by digit, optional decimal, and optional suffix
204
+ *
205
+ * Examples: gpt-4, gpt-4o, gpt-4.5, gpt-5a, etc. */
206
+ const extractGPTVersion = (modelStr: string): string => {
207
+ const gptMatch = modelStr.match(/gpt-(\d+(?:\.\d+)?)([a-z])?/i);
208
+ if (gptMatch) {
209
+ const version = gptMatch[1];
210
+ const suffix = gptMatch[2] || '';
211
+ return `GPT-${version}${suffix}`;
212
+ }
213
+ return '';
214
+ };
215
+
216
+ /** Match omni models (o1, o3, etc.), "o" followed by a digit, possibly with decimal */
217
+ const extractOmniVersion = (modelStr: string): string => {
218
+ const omniMatch = modelStr.match(/\bo(\d+(?:\.\d+)?)\b/i);
219
+ if (omniMatch) {
220
+ const version = omniMatch[1];
221
+ return `o${version}`;
222
+ }
223
+ return '';
224
+ };
225
+
218
226
  export const getResponseSender = (endpointOption: t.TEndpointOption): string => {
219
227
  const {
220
228
  model: _m,
@@ -223,7 +231,6 @@ export const getResponseSender = (endpointOption: t.TEndpointOption): string =>
223
231
  modelDisplayLabel: _mdl,
224
232
  chatGptLabel: _cgl,
225
233
  modelLabel: _ml,
226
- jailbreak,
227
234
  } = endpointOption;
228
235
 
229
236
  const model = _m ?? '';
@@ -243,24 +250,17 @@ export const getResponseSender = (endpointOption: t.TEndpointOption): string =>
243
250
  return chatGptLabel;
244
251
  } else if (modelLabel) {
245
252
  return modelLabel;
246
- } else if (model && /\bo1\b/i.test(model)) {
247
- return 'o1';
248
- } else if (model && model.includes('gpt-3')) {
249
- return 'GPT-3.5';
250
- } else if (model && model.includes('gpt-4o')) {
251
- return 'GPT-4o';
252
- } else if (model && model.includes('gpt-4')) {
253
- return 'GPT-4';
253
+ } else if (model && extractOmniVersion(model)) {
254
+ return extractOmniVersion(model);
254
255
  } else if (model && model.includes('mistral')) {
255
256
  return 'Mistral';
257
+ } else if (model && model.includes('gpt-')) {
258
+ const gptVersion = extractGPTVersion(model);
259
+ return gptVersion || 'GPT';
256
260
  }
257
261
  return (alternateName[endpoint] as string | undefined) ?? 'ChatGPT';
258
262
  }
259
263
 
260
- if (endpoint === EModelEndpoint.bingAI) {
261
- return jailbreak === true ? 'Sydney' : 'BingAI';
262
- }
263
-
264
264
  if (endpoint === EModelEndpoint.anthropic) {
265
265
  return modelLabel || 'Claude';
266
266
  }
@@ -272,7 +272,7 @@ export const getResponseSender = (endpointOption: t.TEndpointOption): string =>
272
272
  if (endpoint === EModelEndpoint.google) {
273
273
  if (modelLabel) {
274
274
  return modelLabel;
275
- } else if (model && model.includes('gemini')) {
275
+ } else if (model && (model.includes('gemini') || model.includes('learnlm'))) {
276
276
  return 'Gemini';
277
277
  } else if (model && model.includes('code')) {
278
278
  return 'Codey';
@@ -286,14 +286,13 @@ export const getResponseSender = (endpointOption: t.TEndpointOption): string =>
286
286
  return modelLabel;
287
287
  } else if (chatGptLabel) {
288
288
  return chatGptLabel;
289
+ } else if (model && extractOmniVersion(model)) {
290
+ return extractOmniVersion(model);
289
291
  } else if (model && model.includes('mistral')) {
290
292
  return 'Mistral';
291
- } else if (model && model.includes('gpt-3')) {
292
- return 'GPT-3.5';
293
- } else if (model && model.includes('gpt-4o')) {
294
- return 'GPT-4o';
295
- } else if (model && model.includes('gpt-4')) {
296
- return 'GPT-4';
293
+ } else if (model && model.includes('gpt-')) {
294
+ const gptVersion = extractGPTVersion(model);
295
+ return gptVersion || 'GPT';
297
296
  } else if (modelDisplayLabel) {
298
297
  return modelDisplayLabel;
299
298
  }
@@ -309,7 +308,6 @@ type CompactEndpointSchema =
309
308
  | typeof compactAssistantSchema
310
309
  | typeof compactAgentsSchema
311
310
  | typeof compactGoogleSchema
312
- | typeof bingAISchema
313
311
  | typeof anthropicSchema
314
312
  | typeof compactChatGPTSchema
315
313
  | typeof bedrockInputSchema
@@ -324,8 +322,6 @@ const compactEndpointSchemas: Record<string, CompactEndpointSchema> = {
324
322
  [EModelEndpoint.agents]: compactAgentsSchema,
325
323
  [EModelEndpoint.google]: compactGoogleSchema,
326
324
  [EModelEndpoint.bedrock]: bedrockInputSchema,
327
- /* BingAI needs all fields */
328
- [EModelEndpoint.bingAI]: bingAISchema,
329
325
  [EModelEndpoint.anthropic]: anthropicSchema,
330
326
  [EModelEndpoint.chatGPTBrowser]: compactChatGPTSchema,
331
327
  [EModelEndpoint.gptPlugins]: compactPluginsSchema,
@@ -338,7 +334,7 @@ export const parseCompactConvo = ({
338
334
  possibleValues,
339
335
  }: {
340
336
  endpoint?: EModelEndpoint;
341
- endpointType?: EModelEndpoint;
337
+ endpointType?: EModelEndpoint | null;
342
338
  conversation: Partial<s.TConversation | s.TPreset>;
343
339
  possibleValues?: TPossibleValues;
344
340
  // TODO: POC for default schema
@@ -348,7 +344,7 @@ export const parseCompactConvo = ({
348
344
  throw new Error(`undefined endpoint: ${endpoint}`);
349
345
  }
350
346
 
351
- let schema = compactEndpointSchemas[endpoint];
347
+ let schema = compactEndpointSchemas[endpoint] as CompactEndpointSchema | undefined;
352
348
 
353
349
  if (!schema && !endpointType) {
354
350
  throw new Error(`Unknown endpoint: ${endpoint}`);
@@ -356,7 +352,11 @@ export const parseCompactConvo = ({
356
352
  schema = compactEndpointSchemas[endpointType];
357
353
  }
358
354
 
359
- const convo = schema.parse(conversation) as s.TConversation;
355
+ if (!schema) {
356
+ throw new Error(`Unknown endpointType: ${endpointType}`);
357
+ }
358
+
359
+ const convo = schema.parse(conversation) as s.TConversation | null;
360
360
  // const { models, secondaryModels } = possibleValues ?? {};
361
361
  const { models } = possibleValues ?? {};
362
362