mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-23 20:00:15 +01:00
🧑💻 refactor: Display Client-facing Errors (#2476)
* fix(Google): allow presets to configure expected maxOutputTokens * refactor: standardize client-facing errors * refactor(checkUserKeyExpiry): pass endpoint instead of custom message * feat(UserService): JSDocs and getUserKeyValues * refactor: add NO_BASE_URL error type, make use of getUserKeyValues, throw user-specific errors * ci: update tests with recent changes
This commit is contained in:
parent
6db91978ca
commit
c937b8cd07
24 changed files with 343 additions and 149 deletions
|
|
@ -515,6 +515,32 @@ export enum ViolationTypes {
|
|||
BAN = 'ban',
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum for error message types that are not "violations" as above, used to identify client-facing errors.
|
||||
*/
|
||||
export enum ErrorTypes {
|
||||
/**
|
||||
* No User-provided Key.
|
||||
*/
|
||||
NO_USER_KEY = 'no_user_key',
|
||||
/**
|
||||
* Expired User-provided Key.
|
||||
*/
|
||||
EXPIRED_USER_KEY = 'expired_user_key',
|
||||
/**
|
||||
* Invalid User-provided Key.
|
||||
*/
|
||||
INVALID_USER_KEY = 'invalid_user_key',
|
||||
/**
|
||||
* No Base URL Provided.
|
||||
*/
|
||||
NO_BASE_URL = 'no_base_url',
|
||||
/**
|
||||
* Moderation error
|
||||
*/
|
||||
MODERATION = 'moderation',
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum for authentication keys.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -437,13 +437,13 @@ export const generateGoogleSchema = (customGoogle: GoogleSettings) => {
|
|||
topK: true,
|
||||
})
|
||||
.transform((obj) => {
|
||||
const isGeminiPro = obj?.model?.toLowerCase()?.includes('gemini-pro');
|
||||
const isGemini = obj?.model?.toLowerCase()?.includes('gemini');
|
||||
|
||||
const maxOutputTokensMax = isGeminiPro
|
||||
? defaults.maxOutputTokens.maxGeminiPro
|
||||
const maxOutputTokensMax = isGemini
|
||||
? defaults.maxOutputTokens.maxGemini
|
||||
: defaults.maxOutputTokens.max;
|
||||
const maxOutputTokensDefault = isGeminiPro
|
||||
? defaults.maxOutputTokens.defaultGeminiPro
|
||||
const maxOutputTokensDefault = isGemini
|
||||
? defaults.maxOutputTokens.defaultGemini
|
||||
: defaults.maxOutputTokens.default;
|
||||
|
||||
let maxOutputTokens = obj.maxOutputTokens ?? maxOutputTokensDefault;
|
||||
|
|
|
|||
|
|
@ -111,8 +111,8 @@ export const googleSettings = {
|
|||
max: 2048,
|
||||
step: 1,
|
||||
default: 1024,
|
||||
maxGeminiPro: 8192,
|
||||
defaultGeminiPro: 8192,
|
||||
maxGemini: 8192,
|
||||
defaultGemini: 8192,
|
||||
},
|
||||
temperature: {
|
||||
min: 0,
|
||||
|
|
@ -374,13 +374,13 @@ export const googleSchema = tConversationSchema
|
|||
topK: true,
|
||||
})
|
||||
.transform((obj) => {
|
||||
const isGeminiPro = obj?.model?.toLowerCase()?.includes('gemini-pro');
|
||||
const isGemini = obj?.model?.toLowerCase()?.includes('gemini');
|
||||
|
||||
const maxOutputTokensMax = isGeminiPro
|
||||
? google.maxOutputTokens.maxGeminiPro
|
||||
const maxOutputTokensMax = isGemini
|
||||
? google.maxOutputTokens.maxGemini
|
||||
: google.maxOutputTokens.max;
|
||||
const maxOutputTokensDefault = isGeminiPro
|
||||
? google.maxOutputTokens.defaultGeminiPro
|
||||
const maxOutputTokensDefault = isGemini
|
||||
? google.maxOutputTokens.defaultGemini
|
||||
: google.maxOutputTokens.default;
|
||||
|
||||
let maxOutputTokens = obj.maxOutputTokens ?? maxOutputTokensDefault;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue