mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 01:10:14 +01:00
🐛 fix: Prevent Node Server Crash Due to Unhandled ChatCompletionMessage Error (#1278)
* refactor(addTitle): avoid generating title when a request was aborted * chore: bump openai to latest * fix: catch OpenAIError Uncaught error as last resort * fix: handle final messages excludes role=assistant * Update OpenAIClient.js * chore: fix linting errors
This commit is contained in:
parent
076a9b9b9c
commit
f1bc711cd7
7 changed files with 95 additions and 30 deletions
|
|
@ -105,7 +105,7 @@ process.on('uncaughtException', (err) => {
|
|||
return;
|
||||
}
|
||||
|
||||
if (err.message.includes('OpenAIError')) {
|
||||
if (err.message.includes('OpenAIError') || err.message.includes('ChatCompletionMessage')) {
|
||||
console.error(
|
||||
'\n\nAn Uncaught `OpenAIError` error may be due to your reverse-proxy setup or stream configuration, or a bug in the `openai` node package.',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const { isEnabled } = require('../../../utils');
|
||||
const { saveConvo } = require('../../../../models');
|
||||
const { saveConvo } = require('~/models');
|
||||
const { isEnabled } = require('~/server/utils');
|
||||
|
||||
const addTitle = async (req, { text, response, client }) => {
|
||||
const { TITLE_CONVO = 'true' } = process.env ?? {};
|
||||
|
|
@ -7,6 +7,11 @@ const addTitle = async (req, { text, response, client }) => {
|
|||
return;
|
||||
}
|
||||
|
||||
// If the request was aborted, don't generate the title.
|
||||
if (client.abortController.signal.aborted) {
|
||||
return;
|
||||
}
|
||||
|
||||
const title = await client.titleConvo({ text, responseText: response?.text });
|
||||
await saveConvo(req.user.id, {
|
||||
conversationId: response.conversationId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue