diff --git a/api/app/clients/BaseClient.js b/api/app/clients/BaseClient.js index f2b3e7c59..0f2cd0346 100644 --- a/api/app/clients/BaseClient.js +++ b/api/app/clients/BaseClient.js @@ -1,5 +1,6 @@ const crypto = require('crypto'); -const fetch = require('node-fetch'); +const { fetch } = require('undici'); +const nodeFetch = require('node-fetch'); const { supportsBalanceCheck, Constants } = require('librechat-data-provider'); const { getConvo, getMessages, saveMessage, updateMessage, saveConvo } = require('~/models'); const { addSpaceIfNeeded, isEnabled } = require('~/server/utils'); @@ -69,6 +70,9 @@ class BaseClient { url = this.options.reverseProxyUrl; } logger.debug(`Making request to ${url}`); + if (typeof Bun !== 'undefined') { + return await nodeFetch(url, init); + } return await fetch(url, init); } diff --git a/api/models/schema/messageSchema.js b/api/models/schema/messageSchema.js index d9a6dfb93..3e89a5caa 100644 --- a/api/models/schema/messageSchema.js +++ b/api/models/schema/messageSchema.js @@ -11,6 +11,7 @@ const messageSchema = mongoose.Schema( }, conversationId: { type: String, + index: true, required: true, meiliIndex: true, }, diff --git a/client/src/hooks/SSE/useSSE.ts b/client/src/hooks/SSE/useSSE.ts index 02cc63020..8c9eae93c 100644 --- a/client/src/hooks/SSE/useSSE.ts +++ b/client/src/hooks/SSE/useSSE.ts @@ -604,7 +604,6 @@ export default function useSSE(submission: TSubmission | null, index = 0) { events.onerror = function (e: MessageEvent) { console.log('error in server stream.'); startupConfig?.checkBalance && balanceQuery.refetch(); - events.close(); let data: TResData | undefined = undefined; try {