🛠️ fix: Completion Edge Cases & Improve Error Handling UX (#3968)

* fix: edge cases concerning completion response as an array

* refactor: improve invalid request error UX
This commit is contained in:
Danny Avila 2024-09-09 20:58:15 -04:00 committed by GitHub
parent 0148b9b097
commit 341e086d70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 21 additions and 7 deletions

View file

@ -1,4 +1,4 @@
const { isAssistantsEndpoint } = require('librechat-data-provider');
const { isAssistantsEndpoint, ErrorTypes } = require('librechat-data-provider');
const { sendMessage, sendError, countTokens, isEnabled } = require('~/server/utils');
const { truncateText, smartTruncateText } = require('~/app/clients/prompts');
const clearPendingReq = require('~/cache/clearPendingReq');
@ -165,10 +165,14 @@ const handleAbortError = async (res, req, error, data) => {
);
}
const errorText = error?.message?.includes('"type"')
let errorText = error?.message?.includes('"type"')
? error.message
: 'An error occurred while processing your request. Please contact the Admin.';
if (error?.type === ErrorTypes.INVALID_REQUEST) {
errorText = `{"type":"${ErrorTypes.INVALID_REQUEST}"}`;
}
const respondWithError = async (partialText) => {
let options = {
sender,