librechat-data-provider 0.3.4 → 0.3.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/parsers.ts ADDED
@@ -0,0 +1,225 @@
1
+ import type { TConversation, TPreset } from './schemas';
2
+ import type { TEndpointOption } from './types';
3
+ import {
4
+ EModelEndpoint,
5
+ openAISchema,
6
+ googleSchema,
7
+ bingAISchema,
8
+ anthropicSchema,
9
+ chatGPTBrowserSchema,
10
+ gptPluginsSchema,
11
+ assistantSchema,
12
+ compactOpenAISchema,
13
+ compactGoogleSchema,
14
+ compactAnthropicSchema,
15
+ compactChatGPTSchema,
16
+ compactPluginsSchema,
17
+ } from './schemas';
18
+ import { alternateName } from './config';
19
+
20
+ type EndpointSchema =
21
+ | typeof openAISchema
22
+ | typeof googleSchema
23
+ | typeof bingAISchema
24
+ | typeof anthropicSchema
25
+ | typeof chatGPTBrowserSchema
26
+ | typeof gptPluginsSchema
27
+ | typeof assistantSchema;
28
+
29
+ const endpointSchemas: Record<EModelEndpoint, EndpointSchema> = {
30
+ [EModelEndpoint.openAI]: openAISchema,
31
+ [EModelEndpoint.azureOpenAI]: openAISchema,
32
+ [EModelEndpoint.custom]: openAISchema,
33
+ [EModelEndpoint.google]: googleSchema,
34
+ [EModelEndpoint.bingAI]: bingAISchema,
35
+ [EModelEndpoint.anthropic]: anthropicSchema,
36
+ [EModelEndpoint.chatGPTBrowser]: chatGPTBrowserSchema,
37
+ [EModelEndpoint.gptPlugins]: gptPluginsSchema,
38
+ [EModelEndpoint.assistant]: assistantSchema,
39
+ };
40
+
41
+ // const schemaCreators: Record<EModelEndpoint, (customSchema: DefaultSchemaValues) => EndpointSchema> = {
42
+ // [EModelEndpoint.google]: createGoogleSchema,
43
+ // };
44
+
45
+ export function getFirstDefinedValue(possibleValues: string[]) {
46
+ let returnValue;
47
+ for (const value of possibleValues) {
48
+ if (value) {
49
+ returnValue = value;
50
+ break;
51
+ }
52
+ }
53
+ return returnValue;
54
+ }
55
+
56
+ export type TPossibleValues = {
57
+ models: string[];
58
+ secondaryModels?: string[];
59
+ };
60
+
61
+ export const parseConvo = ({
62
+ endpoint,
63
+ endpointType,
64
+ conversation,
65
+ possibleValues,
66
+ }: {
67
+ endpoint: EModelEndpoint;
68
+ endpointType?: EModelEndpoint;
69
+ conversation: Partial<TConversation | TPreset>;
70
+ possibleValues?: TPossibleValues;
71
+ // TODO: POC for default schema
72
+ // defaultSchema?: Partial<EndpointSchema>,
73
+ }) => {
74
+ let schema = endpointSchemas[endpoint];
75
+
76
+ if (!schema && !endpointType) {
77
+ throw new Error(`Unknown endpoint: ${endpoint}`);
78
+ } else if (!schema && endpointType) {
79
+ schema = endpointSchemas[endpointType];
80
+ }
81
+
82
+ // if (defaultSchema && schemaCreators[endpoint]) {
83
+ // schema = schemaCreators[endpoint](defaultSchema);
84
+ // }
85
+
86
+ const convo = schema.parse(conversation) as TConversation;
87
+ const { models, secondaryModels } = possibleValues ?? {};
88
+
89
+ if (models && convo) {
90
+ convo.model = getFirstDefinedValue(models) ?? convo.model;
91
+ }
92
+
93
+ if (secondaryModels && convo.agentOptions) {
94
+ convo.agentOptions.model = getFirstDefinedValue(secondaryModels) ?? convo.agentOptions.model;
95
+ }
96
+
97
+ return convo;
98
+ };
99
+
100
+ export const getResponseSender = (endpointOption: TEndpointOption): string => {
101
+ const { model, endpoint, endpointType, modelDisplayLabel, chatGptLabel, modelLabel, jailbreak } =
102
+ endpointOption;
103
+
104
+ if (
105
+ [
106
+ EModelEndpoint.openAI,
107
+ EModelEndpoint.azureOpenAI,
108
+ EModelEndpoint.gptPlugins,
109
+ EModelEndpoint.chatGPTBrowser,
110
+ ].includes(endpoint)
111
+ ) {
112
+ if (chatGptLabel) {
113
+ return chatGptLabel;
114
+ } else if (model && model.includes('gpt-3')) {
115
+ return 'GPT-3.5';
116
+ } else if (model && model.includes('gpt-4')) {
117
+ return 'GPT-4';
118
+ } else if (model && model.includes('mistral')) {
119
+ return 'Mistral';
120
+ }
121
+ return alternateName[endpoint] ?? 'ChatGPT';
122
+ }
123
+
124
+ if (endpoint === EModelEndpoint.bingAI) {
125
+ return jailbreak ? 'Sydney' : 'BingAI';
126
+ }
127
+
128
+ if (endpoint === EModelEndpoint.anthropic) {
129
+ return modelLabel ?? 'Claude';
130
+ }
131
+
132
+ if (endpoint === EModelEndpoint.google) {
133
+ if (modelLabel) {
134
+ return modelLabel;
135
+ } else if (model && model.includes('gemini')) {
136
+ return 'Gemini';
137
+ } else if (model && model.includes('code')) {
138
+ return 'Codey';
139
+ }
140
+
141
+ return 'PaLM2';
142
+ }
143
+
144
+ if (endpoint === EModelEndpoint.custom || endpointType === EModelEndpoint.custom) {
145
+ if (modelLabel) {
146
+ return modelLabel;
147
+ } else if (chatGptLabel) {
148
+ return chatGptLabel;
149
+ } else if (model && model.includes('mistral')) {
150
+ return 'Mistral';
151
+ } else if (model && model.includes('gpt-3')) {
152
+ return 'GPT-3.5';
153
+ } else if (model && model.includes('gpt-4')) {
154
+ return 'GPT-4';
155
+ } else if (modelDisplayLabel) {
156
+ return modelDisplayLabel;
157
+ }
158
+
159
+ return 'AI';
160
+ }
161
+
162
+ return '';
163
+ };
164
+
165
+ type CompactEndpointSchema =
166
+ | typeof compactOpenAISchema
167
+ | typeof assistantSchema
168
+ | typeof compactGoogleSchema
169
+ | typeof bingAISchema
170
+ | typeof compactAnthropicSchema
171
+ | typeof compactChatGPTSchema
172
+ | typeof compactPluginsSchema;
173
+
174
+ const compactEndpointSchemas: Record<string, CompactEndpointSchema> = {
175
+ openAI: compactOpenAISchema,
176
+ azureOpenAI: compactOpenAISchema,
177
+ custom: compactOpenAISchema,
178
+ assistant: assistantSchema,
179
+ google: compactGoogleSchema,
180
+ /* BingAI needs all fields */
181
+ bingAI: bingAISchema,
182
+ anthropic: compactAnthropicSchema,
183
+ chatGPTBrowser: compactChatGPTSchema,
184
+ gptPlugins: compactPluginsSchema,
185
+ };
186
+
187
+ export const parseCompactConvo = ({
188
+ endpoint,
189
+ endpointType,
190
+ conversation,
191
+ possibleValues,
192
+ }: {
193
+ endpoint?: EModelEndpoint;
194
+ endpointType?: EModelEndpoint;
195
+ conversation: Partial<TConversation | TPreset>;
196
+ possibleValues?: TPossibleValues;
197
+ // TODO: POC for default schema
198
+ // defaultSchema?: Partial<EndpointSchema>,
199
+ }) => {
200
+ if (!endpoint) {
201
+ throw new Error(`undefined endpoint: ${endpoint}`);
202
+ }
203
+
204
+ let schema = compactEndpointSchemas[endpoint];
205
+
206
+ if (!schema && !endpointType) {
207
+ throw new Error(`Unknown endpoint: ${endpoint}`);
208
+ } else if (!schema && endpointType) {
209
+ schema = compactEndpointSchemas[endpointType];
210
+ }
211
+
212
+ const convo = schema.parse(conversation) as TConversation;
213
+ // const { models, secondaryModels } = possibleValues ?? {};
214
+ const { models } = possibleValues ?? {};
215
+
216
+ if (models && convo) {
217
+ convo.model = getFirstDefinedValue(models) ?? convo.model;
218
+ }
219
+
220
+ // if (secondaryModels && convo.agentOptions) {
221
+ // convo.agentOptionmodel = getFirstDefinedValue(secondaryModels) ?? convo.agentOptionmodel;
222
+ // }
223
+
224
+ return convo;
225
+ };
package/src/schemas.ts CHANGED
@@ -9,75 +9,7 @@ export enum EModelEndpoint {
9
9
  gptPlugins = 'gptPlugins',
10
10
  anthropic = 'anthropic',
11
11
  assistant = 'assistant',
12
- }
13
-
14
- export const defaultEndpoints: EModelEndpoint[] = [
15
- EModelEndpoint.openAI,
16
- EModelEndpoint.assistant,
17
- EModelEndpoint.azureOpenAI,
18
- EModelEndpoint.bingAI,
19
- EModelEndpoint.chatGPTBrowser,
20
- EModelEndpoint.gptPlugins,
21
- EModelEndpoint.google,
22
- EModelEndpoint.anthropic,
23
- ];
24
-
25
- export const defaultModels = {
26
- [EModelEndpoint.google]: [
27
- 'gemini-pro',
28
- 'gemini-pro-vision',
29
- 'chat-bison',
30
- 'chat-bison-32k',
31
- 'codechat-bison',
32
- 'codechat-bison-32k',
33
- 'text-bison',
34
- 'text-bison-32k',
35
- 'text-unicorn',
36
- 'code-gecko',
37
- 'code-bison',
38
- 'code-bison-32k',
39
- ],
40
- [EModelEndpoint.anthropic]: [
41
- 'claude-2.1',
42
- 'claude-2',
43
- 'claude-1.2',
44
- 'claude-1',
45
- 'claude-1-100k',
46
- 'claude-instant-1',
47
- 'claude-instant-1-100k',
48
- ],
49
- [EModelEndpoint.openAI]: [
50
- 'gpt-3.5-turbo-16k-0613',
51
- 'gpt-3.5-turbo-16k',
52
- 'gpt-4-1106-preview',
53
- 'gpt-3.5-turbo',
54
- 'gpt-3.5-turbo-1106',
55
- 'gpt-4-vision-preview',
56
- 'gpt-4',
57
- 'gpt-3.5-turbo-instruct-0914',
58
- 'gpt-3.5-turbo-0613',
59
- 'gpt-3.5-turbo-0301',
60
- 'gpt-3.5-turbo-instruct',
61
- 'gpt-4-0613',
62
- 'text-davinci-003',
63
- 'gpt-4-0314',
64
- ],
65
- };
66
-
67
- export const alternateName = {
68
- [EModelEndpoint.openAI]: 'OpenAI',
69
- [EModelEndpoint.assistant]: 'Assistants',
70
- [EModelEndpoint.azureOpenAI]: 'Azure OpenAI',
71
- [EModelEndpoint.bingAI]: 'Bing',
72
- [EModelEndpoint.chatGPTBrowser]: 'ChatGPT',
73
- [EModelEndpoint.gptPlugins]: 'Plugins',
74
- [EModelEndpoint.google]: 'Google',
75
- [EModelEndpoint.anthropic]: 'Anthropic',
76
- };
77
-
78
- export enum AuthKeys {
79
- GOOGLE_SERVICE_KEY = 'GOOGLE_SERVICE_KEY',
80
- GOOGLE_API_KEY = 'GOOGLE_API_KEY',
12
+ custom = 'custom',
81
13
  }
82
14
 
83
15
  export const endpointSettings = {
@@ -116,41 +48,10 @@ export const endpointSettings = {
116
48
 
117
49
  const google = endpointSettings[EModelEndpoint.google];
118
50
 
119
- export const EndpointURLs: { [key in EModelEndpoint]: string } = {
120
- [EModelEndpoint.azureOpenAI]: '/api/ask/azureOpenAI',
121
- [EModelEndpoint.openAI]: '/api/ask/openAI',
122
- [EModelEndpoint.bingAI]: '/api/ask/bingAI',
123
- [EModelEndpoint.chatGPTBrowser]: '/api/ask/chatGPTBrowser',
124
- [EModelEndpoint.google]: '/api/ask/google',
125
- [EModelEndpoint.gptPlugins]: '/api/ask/gptPlugins',
126
- [EModelEndpoint.anthropic]: '/api/ask/anthropic',
127
- [EModelEndpoint.assistant]: '/api/assistants/chat',
128
- };
129
-
130
- export const modularEndpoints = new Set<EModelEndpoint | string>([
131
- EModelEndpoint.gptPlugins,
132
- EModelEndpoint.anthropic,
133
- EModelEndpoint.google,
134
- EModelEndpoint.openAI,
135
- ]);
136
-
137
- export const supportsFiles = {
138
- [EModelEndpoint.openAI]: true,
139
- [EModelEndpoint.google]: true,
140
- [EModelEndpoint.assistant]: true,
141
- [EModelEndpoint.azureOpenAI]: true,
142
- };
143
-
144
- export const supportsBalanceCheck = {
145
- [EModelEndpoint.openAI]: true,
146
- [EModelEndpoint.azureOpenAI]: true,
147
- [EModelEndpoint.gptPlugins]: true,
148
- };
149
-
150
- export const visionModels = ['gpt-4-vision', 'llava-13b', 'gemini-pro-vision'];
151
-
152
51
  export const eModelEndpointSchema = z.nativeEnum(EModelEndpoint);
153
52
 
53
+ export const extendedModelEndpointSchema = z.union([eModelEndpointSchema, z.string()]);
54
+
154
55
  export const tPluginAuthConfigSchema = z.object({
155
56
  authField: z.string(),
156
57
  label: z.string(),
@@ -205,6 +106,7 @@ export const tAgentOptionsSchema = z.object({
205
106
 
206
107
  export const tMessageSchema = z.object({
207
108
  messageId: z.string(),
109
+ endpoint: z.string().optional(),
208
110
  clientId: z.string().nullable().optional(),
209
111
  conversationId: z.string().nullable(),
210
112
  parentMessageId: z.string().nullable(),
@@ -229,7 +131,6 @@ export const tMessageSchema = z.object({
229
131
  .default(() => new Date().toISOString()),
230
132
  current: z.boolean().optional(),
231
133
  unfinished: z.boolean().optional(),
232
- submitting: z.boolean().optional(),
233
134
  searchResult: z.boolean().optional(),
234
135
  finish_reason: z.string().optional(),
235
136
  });
@@ -254,6 +155,7 @@ export const tConversationSchema = z.object({
254
155
  title: z.string().nullable().or(z.literal('New Chat')).default('New Chat'),
255
156
  user: z.string().optional(),
256
157
  endpoint: eModelEndpointSchema.nullable(),
158
+ endpointType: eModelEndpointSchema.optional(),
257
159
  suggestions: z.array(z.string()).optional(),
258
160
  messages: z.array(z.string()).optional(),
259
161
  tools: z.array(tPluginSchema).optional(),
@@ -298,16 +200,31 @@ export const tPresetSchema = tConversationSchema
298
200
  })
299
201
  .merge(
300
202
  z.object({
301
- conversationId: z.string().optional(),
203
+ conversationId: z.string().nullable().optional(),
302
204
  presetId: z.string().nullable().optional(),
303
205
  title: z.string().nullable().optional(),
304
206
  defaultPreset: z.boolean().optional(),
305
207
  order: z.number().optional(),
208
+ endpoint: extendedModelEndpointSchema.nullable(),
306
209
  }),
307
210
  );
308
211
 
212
+ export const tConvoUpdateSchema = tConversationSchema.merge(
213
+ z.object({
214
+ endpoint: extendedModelEndpointSchema.nullable(),
215
+ }),
216
+ );
217
+
218
+ export const tPresetUpdateSchema = tConversationSchema.merge(
219
+ z.object({
220
+ endpoint: extendedModelEndpointSchema.nullable(),
221
+ }),
222
+ );
223
+
309
224
  export type TPreset = z.infer<typeof tPresetSchema>;
310
225
 
226
+ // type DefaultSchemaValues = Partial<typeof google>;
227
+
311
228
  export const openAISchema = tConversationSchema
312
229
  .pick({
313
230
  model: true,
@@ -529,122 +446,6 @@ export const assistantSchema = tConversationSchema
529
446
  .transform(removeNullishValues)
530
447
  .catch(() => ({}));
531
448
 
532
- type EndpointSchema =
533
- | typeof openAISchema
534
- | typeof googleSchema
535
- | typeof bingAISchema
536
- | typeof anthropicSchema
537
- | typeof chatGPTBrowserSchema
538
- | typeof gptPluginsSchema
539
- | typeof assistantSchema;
540
-
541
- const endpointSchemas: Record<EModelEndpoint, EndpointSchema> = {
542
- [EModelEndpoint.openAI]: openAISchema,
543
- [EModelEndpoint.azureOpenAI]: openAISchema,
544
- [EModelEndpoint.google]: googleSchema,
545
- [EModelEndpoint.bingAI]: bingAISchema,
546
- [EModelEndpoint.anthropic]: anthropicSchema,
547
- [EModelEndpoint.chatGPTBrowser]: chatGPTBrowserSchema,
548
- [EModelEndpoint.gptPlugins]: gptPluginsSchema,
549
- [EModelEndpoint.assistant]: assistantSchema,
550
- };
551
-
552
- export function getFirstDefinedValue(possibleValues: string[]) {
553
- let returnValue;
554
- for (const value of possibleValues) {
555
- if (value) {
556
- returnValue = value;
557
- break;
558
- }
559
- }
560
- return returnValue;
561
- }
562
-
563
- export type TPossibleValues = {
564
- models: string[];
565
- secondaryModels?: string[];
566
- };
567
-
568
- export const parseConvo = (
569
- endpoint: EModelEndpoint,
570
- conversation: Partial<TConversation | TPreset>,
571
- possibleValues?: TPossibleValues,
572
- ) => {
573
- const schema = endpointSchemas[endpoint];
574
-
575
- if (!schema) {
576
- throw new Error(`Unknown endpoint: ${endpoint}`);
577
- }
578
-
579
- const convo = schema.parse(conversation) as TConversation;
580
- const { models, secondaryModels } = possibleValues ?? {};
581
-
582
- if (models && convo) {
583
- convo.model = getFirstDefinedValue(models) ?? convo.model;
584
- }
585
-
586
- if (secondaryModels && convo.agentOptions) {
587
- convo.agentOptions.model = getFirstDefinedValue(secondaryModels) ?? convo.agentOptions.model;
588
- }
589
-
590
- return convo;
591
- };
592
-
593
- export type TEndpointOption = {
594
- endpoint: EModelEndpoint;
595
- model?: string | null;
596
- promptPrefix?: string;
597
- temperature?: number;
598
- chatGptLabel?: string | null;
599
- modelLabel?: string | null;
600
- jailbreak?: boolean;
601
- key?: string | null;
602
- };
603
-
604
- export const getResponseSender = (endpointOption: TEndpointOption): string => {
605
- const { model, endpoint, chatGptLabel, modelLabel, jailbreak } = endpointOption;
606
-
607
- if (
608
- [
609
- EModelEndpoint.openAI,
610
- EModelEndpoint.azureOpenAI,
611
- EModelEndpoint.gptPlugins,
612
- EModelEndpoint.chatGPTBrowser,
613
- ].includes(endpoint)
614
- ) {
615
- if (chatGptLabel) {
616
- return chatGptLabel;
617
- } else if (model && model.includes('gpt-3')) {
618
- return 'GPT-3.5';
619
- } else if (model && model.includes('gpt-4')) {
620
- return 'GPT-4';
621
- }
622
- return alternateName[endpoint] ?? 'ChatGPT';
623
- }
624
-
625
- if (endpoint === EModelEndpoint.bingAI) {
626
- return jailbreak ? 'Sydney' : 'BingAI';
627
- }
628
-
629
- if (endpoint === EModelEndpoint.anthropic) {
630
- return modelLabel ?? 'Claude';
631
- }
632
-
633
- if (endpoint === EModelEndpoint.google) {
634
- if (modelLabel) {
635
- return modelLabel;
636
- } else if (model && model.includes('gemini')) {
637
- return 'Gemini';
638
- } else if (model && model.includes('code')) {
639
- return 'Codey';
640
- }
641
-
642
- return 'PaLM2';
643
- }
644
-
645
- return '';
646
- };
647
-
648
449
  export const compactOpenAISchema = tConversationSchema
649
450
  .pick({
650
451
  model: true,
@@ -810,53 +611,52 @@ export const compactPluginsSchema = tConversationSchema
810
611
  })
811
612
  .catch(() => ({}));
812
613
 
813
- type CompactEndpointSchema =
814
- | typeof compactOpenAISchema
815
- | typeof assistantSchema
816
- | typeof compactGoogleSchema
817
- | typeof bingAISchema
818
- | typeof compactAnthropicSchema
819
- | typeof compactChatGPTSchema
820
- | typeof compactPluginsSchema;
821
-
822
- const compactEndpointSchemas: Record<string, CompactEndpointSchema> = {
823
- openAI: compactOpenAISchema,
824
- azureOpenAI: compactOpenAISchema,
825
- assistant: assistantSchema,
826
- google: compactGoogleSchema,
827
- /* BingAI needs all fields */
828
- bingAI: bingAISchema,
829
- anthropic: compactAnthropicSchema,
830
- chatGPTBrowser: compactChatGPTSchema,
831
- gptPlugins: compactPluginsSchema,
832
- };
833
-
834
- export const parseCompactConvo = (
835
- endpoint: EModelEndpoint | undefined,
836
- conversation: Partial<TConversation | TPreset>,
837
- possibleValues?: TPossibleValues,
838
- ) => {
839
- if (!endpoint) {
840
- throw new Error(`undefined endpoint: ${endpoint}`);
841
- }
842
-
843
- const schema = compactEndpointSchemas[endpoint];
844
-
845
- if (!schema) {
846
- throw new Error(`Unknown endpoint: ${endpoint}`);
847
- }
848
-
849
- const convo = schema.parse(conversation) as TConversation;
850
- // const { models, secondaryModels } = possibleValues ?? {};
851
- const { models } = possibleValues ?? {};
852
-
853
- if (models && convo) {
854
- convo.model = getFirstDefinedValue(models) ?? convo.model;
855
- }
856
-
857
- // if (secondaryModels && convo.agentOptions) {
858
- // convo.agentOptionmodel = getFirstDefinedValue(secondaryModels) ?? convo.agentOptionmodel;
859
- // }
860
-
861
- return convo;
862
- };
614
+ // const createGoogleSchema = (customGoogle: DefaultSchemaValues) => {
615
+ // const defaults = { ...google, ...customGoogle };
616
+ // return tConversationSchema
617
+ // .pick({
618
+ // model: true,
619
+ // modelLabel: true,
620
+ // promptPrefix: true,
621
+ // examples: true,
622
+ // temperature: true,
623
+ // maxOutputTokens: true,
624
+ // topP: true,
625
+ // topK: true,
626
+ // })
627
+ // .transform((obj) => {
628
+ // const isGeminiPro = obj?.model?.toLowerCase()?.includes('gemini-pro');
629
+
630
+ // const maxOutputTokensMax = isGeminiPro
631
+ // ? defaults.maxOutputTokens.maxGeminiPro
632
+ // : defaults.maxOutputTokens.max;
633
+ // const maxOutputTokensDefault = isGeminiPro
634
+ // ? defaults.maxOutputTokens.defaultGeminiPro
635
+ // : defaults.maxOutputTokens.default;
636
+
637
+ // let maxOutputTokens = obj.maxOutputTokens ?? maxOutputTokensDefault;
638
+ // maxOutputTokens = Math.min(maxOutputTokens, maxOutputTokensMax);
639
+
640
+ // return {
641
+ // ...obj,
642
+ // model: obj.model ?? defaults.model.default,
643
+ // modelLabel: obj.modelLabel ?? null,
644
+ // promptPrefix: obj.promptPrefix ?? null,
645
+ // examples: obj.examples ?? [{ input: { content: '' }, output: { content: '' } }],
646
+ // temperature: obj.temperature ?? defaults.temperature.default,
647
+ // maxOutputTokens,
648
+ // topP: obj.topP ?? defaults.topP.default,
649
+ // topK: obj.topK ?? defaults.topK.default,
650
+ // };
651
+ // })
652
+ // .catch(() => ({
653
+ // model: defaults.model.default,
654
+ // modelLabel: null,
655
+ // promptPrefix: null,
656
+ // examples: [{ input: { content: '' }, output: { content: '' } }],
657
+ // temperature: defaults.temperature.default,
658
+ // maxOutputTokens: defaults.maxOutputTokens.default,
659
+ // topP: defaults.topP.default,
660
+ // topK: defaults.topK.default,
661
+ // }));
662
+ // };
@@ -10,6 +10,10 @@ export type FileUploadResponse = {
10
10
  width: number;
11
11
  };
12
12
 
13
+ export type AvatarUploadResponse = {
14
+ url: string;
15
+ };
16
+
13
17
  export type FileUploadBody = {
14
18
  formData: FormData;
15
19
  file_id: string;
@@ -21,6 +25,12 @@ export type UploadMutationOptions = {
21
25
  onError?: (error: unknown, variables: FileUploadBody, context?: unknown) => void;
22
26
  };
23
27
 
28
+ export type UploadAvatarOptions = {
29
+ onSuccess?: (data: AvatarUploadResponse, variables: FormData, context?: unknown) => void;
30
+ onMutate?: (variables: FormData) => void | Promise<unknown>;
31
+ onError?: (error: unknown, variables: FormData, context?: unknown) => void;
32
+ };
33
+
24
34
  export type DeleteFilesResponse = {
25
35
  message: string;
26
36
  result: Record<string, unknown>;
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import OpenAI from 'openai';
2
- import type { TResPlugin, TMessage, TConversation, TEndpointOption } from './schemas';
2
+ import type { TResPlugin, TMessage, TConversation, EModelEndpoint } from './schemas';
3
3
 
4
4
  export type TOpenAIMessage = OpenAI.Chat.ChatCompletionMessageParam;
5
5
  export type TOpenAIFunction = OpenAI.Chat.ChatCompletionCreateParams.Function;
@@ -11,6 +11,19 @@ export type TMessages = TMessage[];
11
11
 
12
12
  export type TMessagesAtom = TMessages | null;
13
13
 
14
+ export type TEndpointOption = {
15
+ endpoint: EModelEndpoint;
16
+ endpointType?: EModelEndpoint;
17
+ modelDisplayLabel?: string;
18
+ model?: string | null;
19
+ promptPrefix?: string;
20
+ temperature?: number;
21
+ chatGptLabel?: string | null;
22
+ modelLabel?: string | null;
23
+ jailbreak?: boolean;
24
+ key?: string | null;
25
+ };
26
+
14
27
  export type TSubmission = {
15
28
  plugin?: TResPlugin;
16
29
  plugins?: TResPlugin[];
@@ -114,17 +127,23 @@ export type TSearchResults = {
114
127
  };
115
128
 
116
129
  export type TConfig = {
117
- availableModels?: [];
118
- userProvide?: boolean | null;
130
+ order: number;
131
+ type?: EModelEndpoint;
132
+ azure?: boolean;
119
133
  availableTools?: [];
120
134
  plugins?: Record<string, string>;
121
- azure?: boolean;
122
- order: number;
135
+ name?: string;
136
+ iconURL?: string;
137
+ modelDisplayLabel?: string;
138
+ userProvide?: boolean | null;
139
+ userProvideURL?: boolean | null;
123
140
  };
124
141
 
125
- export type TModelsConfig = Record<string, string[]>;
142
+ export type TEndpointsConfig =
143
+ | Record<EModelEndpoint | string, TConfig | null | undefined>
144
+ | undefined;
126
145
 
127
- export type TEndpointsConfig = Record<string, TConfig | null>;
146
+ export type TModelsConfig = Record<string, string[]>;
128
147
 
129
148
  export type TUpdateTokenCountResponse = {
130
149
  count: number;