mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
🔧 fix: Error Handling Improvements (#1518)
* style(Icon): remove error bubble from message icon * fix(custom): `initializeClient` now throws error if apiKey or baseURL are admin provided but no env var was found * refactor(tPresetSchema): match `conversationId` type to `tConversationSchema` but optional, use `extendedModelEndpointSchema` for `endpoint` * fix(useSSE): minor improvements - use `completed` set to avoid submitting unecessary abort request - set preset with `newConversation` calls using initial conversation settings to prevent default Preset override as well as default settings - return if there is a parsing error within `onerror` as expected errors from server are properly formatted
This commit is contained in:
parent
c9aaf502af
commit
ead1c3c797
5 changed files with 57 additions and 14 deletions
|
|
@ -4,6 +4,8 @@ const { isUserProvided, extractEnvVariable } = require('~/server/utils');
|
|||
const getCustomConfig = require('~/cache/getCustomConfig');
|
||||
const { OpenAIClient } = require('~/app');
|
||||
|
||||
const envVarRegex = /^\${(.+)}$/;
|
||||
|
||||
const { PROXY } = process.env;
|
||||
|
||||
const initializeClient = async ({ req, res, endpointOption }) => {
|
||||
|
|
@ -20,6 +22,14 @@ const initializeClient = async ({ req, res, endpointOption }) => {
|
|||
const CUSTOM_API_KEY = extractEnvVariable(endpointConfig.apiKey);
|
||||
const CUSTOM_BASE_URL = extractEnvVariable(endpointConfig.baseURL);
|
||||
|
||||
if (CUSTOM_API_KEY.match(envVarRegex)) {
|
||||
throw new Error(`Missing API Key for ${endpoint}.`);
|
||||
}
|
||||
|
||||
if (CUSTOM_BASE_URL.match(envVarRegex)) {
|
||||
throw new Error(`Missing Base URL for ${endpoint}.`);
|
||||
}
|
||||
|
||||
const customOptions = {
|
||||
addParams: endpointConfig.addParams,
|
||||
dropParams: endpointConfig.dropParams,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue