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/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react-query/index.es.js +1 -1
- package/dist/react-query/index.es.js.map +1 -1
- package/package.json +1 -1
- package/src/schemas.ts +94 -27
package/package.json
CHANGED
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
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
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:
|
|
662
|
+
model: anthropicSettings.model.default,
|
|
596
663
|
modelLabel: null,
|
|
597
664
|
promptPrefix: null,
|
|
598
|
-
temperature:
|
|
599
|
-
maxOutputTokens:
|
|
600
|
-
topP:
|
|
601
|
-
topK:
|
|
602
|
-
resendFiles:
|
|
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:
|
|
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 ===
|
|
905
|
+
if (newObj.temperature === anthropicSettings.temperature.default) {
|
|
839
906
|
delete newObj.temperature;
|
|
840
907
|
}
|
|
841
|
-
if (newObj.maxOutputTokens ===
|
|
908
|
+
if (newObj.maxOutputTokens === anthropicSettings.legacy.maxOutputTokens.default) {
|
|
842
909
|
delete newObj.maxOutputTokens;
|
|
843
910
|
}
|
|
844
|
-
if (newObj.topP ===
|
|
911
|
+
if (newObj.topP === anthropicSettings.topP.default) {
|
|
845
912
|
delete newObj.topP;
|
|
846
913
|
}
|
|
847
|
-
if (newObj.topK ===
|
|
914
|
+
if (newObj.topK === anthropicSettings.topK.default) {
|
|
848
915
|
delete newObj.topK;
|
|
849
916
|
}
|
|
850
|
-
if (newObj.resendFiles ===
|
|
917
|
+
if (newObj.resendFiles === anthropicSettings.resendFiles.default) {
|
|
851
918
|
delete newObj.resendFiles;
|
|
852
919
|
}
|
|
853
920
|
|