librechat-data-provider 0.7.3 → 0.7.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "librechat-data-provider",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "description": "data services for librechat apps",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
package/src/schemas.ts CHANGED
@@ -156,9 +156,70 @@ export const googleSettings = {
156
156
  },
157
157
  };
158
158
 
159
+ const ANTHROPIC_MAX_OUTPUT = 8192;
160
+ const LEGACY_ANTHROPIC_MAX_OUTPUT = 4096;
161
+ export const anthropicSettings = {
162
+ model: {
163
+ default: 'claude-3-5-sonnet-20240620',
164
+ },
165
+ temperature: {
166
+ min: 0,
167
+ max: 1,
168
+ step: 0.01,
169
+ default: 1,
170
+ },
171
+ maxOutputTokens: {
172
+ min: 1,
173
+ max: ANTHROPIC_MAX_OUTPUT,
174
+ step: 1,
175
+ default: ANTHROPIC_MAX_OUTPUT,
176
+ reset: (modelName: string) => {
177
+ if (modelName.includes('claude-3-5-sonnet')) {
178
+ return ANTHROPIC_MAX_OUTPUT;
179
+ }
180
+
181
+ return 4096;
182
+ },
183
+ set: (value: number, modelName: string) => {
184
+ if (!modelName.includes('claude-3-5-sonnet') && value > LEGACY_ANTHROPIC_MAX_OUTPUT) {
185
+ return LEGACY_ANTHROPIC_MAX_OUTPUT;
186
+ }
187
+
188
+ return value;
189
+ },
190
+ },
191
+ topP: {
192
+ min: 0,
193
+ max: 1,
194
+ step: 0.01,
195
+ default: 0.7,
196
+ },
197
+ topK: {
198
+ min: 1,
199
+ max: 40,
200
+ step: 1,
201
+ default: 5,
202
+ },
203
+ resendFiles: {
204
+ default: true,
205
+ },
206
+ maxContextTokens: {
207
+ default: undefined,
208
+ },
209
+ legacy: {
210
+ maxOutputTokens: {
211
+ min: 1,
212
+ max: LEGACY_ANTHROPIC_MAX_OUTPUT,
213
+ step: 1,
214
+ default: LEGACY_ANTHROPIC_MAX_OUTPUT,
215
+ },
216
+ },
217
+ };
218
+
159
219
  export const endpointSettings = {
160
220
  [EModelEndpoint.openAI]: openAISettings,
161
221
  [EModelEndpoint.google]: googleSettings,
222
+ [EModelEndpoint.anthropic]: anthropicSettings,
162
223
  };
163
224
 
164
225
  const google = endpointSettings[EModelEndpoint.google];
@@ -576,34 +637,40 @@ export const anthropicSchema = tConversationSchema
576
637
  spec: true,
577
638
  maxContextTokens: true,
578
639
  })
579
- .transform((obj) => ({
580
- ...obj,
581
- model: obj.model ?? 'claude-1',
582
- modelLabel: obj.modelLabel ?? null,
583
- promptPrefix: obj.promptPrefix ?? null,
584
- temperature: obj.temperature ?? 1,
585
- maxOutputTokens: obj.maxOutputTokens ?? 4000,
586
- topP: obj.topP ?? 0.7,
587
- topK: obj.topK ?? 5,
588
- resendFiles: typeof obj.resendFiles === 'boolean' ? obj.resendFiles : true,
589
- iconURL: obj.iconURL ?? undefined,
590
- greeting: obj.greeting ?? undefined,
591
- spec: obj.spec ?? undefined,
592
- maxContextTokens: obj.maxContextTokens ?? undefined,
593
- }))
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
+ })
594
661
  .catch(() => ({
595
- model: 'claude-1',
662
+ model: anthropicSettings.model.default,
596
663
  modelLabel: null,
597
664
  promptPrefix: null,
598
- temperature: 1,
599
- maxOutputTokens: 4000,
600
- topP: 0.7,
601
- topK: 5,
602
- resendFiles: true,
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,
603
670
  iconURL: undefined,
604
671
  greeting: undefined,
605
672
  spec: undefined,
606
- maxContextTokens: undefined,
673
+ maxContextTokens: anthropicSettings.maxContextTokens.default,
607
674
  }));
608
675
 
609
676
  export const chatGPTBrowserSchema = tConversationSchema
@@ -835,19 +902,19 @@ export const compactAnthropicSchema = tConversationSchema
835
902
  })
836
903
  .transform((obj) => {
837
904
  const newObj: Partial<TConversation> = { ...obj };
838
- if (newObj.temperature === 1) {
905
+ if (newObj.temperature === anthropicSettings.temperature.default) {
839
906
  delete newObj.temperature;
840
907
  }
841
- if (newObj.maxOutputTokens === 4000) {
908
+ if (newObj.maxOutputTokens === anthropicSettings.legacy.maxOutputTokens.default) {
842
909
  delete newObj.maxOutputTokens;
843
910
  }
844
- if (newObj.topP === 0.7) {
911
+ if (newObj.topP === anthropicSettings.topP.default) {
845
912
  delete newObj.topP;
846
913
  }
847
- if (newObj.topK === 5) {
914
+ if (newObj.topK === anthropicSettings.topK.default) {
848
915
  delete newObj.topK;
849
916
  }
850
- if (newObj.resendFiles === true) {
917
+ if (newObj.resendFiles === anthropicSettings.resendFiles.default) {
851
918
  delete newObj.resendFiles;
852
919
  }
853
920