Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🔧 fix: Resizable Panel Unmount Error & Code Env. File Re-Upload (#5947)
Danny Avilafdb3cf3f583c
diff --git a/api/app/clients/GoogleClient.js b/api/app/clients/GoogleClient.jsindex 03461a6796..a2ca02558b 100644--- a/api/app/clients/GoogleClient.js+++ b/api/app/clients/GoogleClient.js@@ -51,7 +51,7 @@ class GoogleClient extends BaseClient {const serviceKey = creds[AuthKeys.GOOGLE_SERVICE_KEY] ?? {};this.serviceKey =- serviceKey && typeof serviceKey === 'string' ? JSON.parse(serviceKey) : serviceKey ?? {};+ serviceKey && typeof serviceKey === 'string' ? JSON.parse(serviceKey) : (serviceKey ?? {});/** @type {string | null | undefined} */this.project_id = this.serviceKey.project_id;this.client_email = this.serviceKey.client_email;@@ -73,6 +73,8 @@ class GoogleClient extends BaseClient {* @type {string} */this.outputTokensKey = 'output_tokens';this.visionMode = VisionModes.generative;+ /** @type {string} */+ this.systemMessage;if (options.skipSetOptions) {return;}@@ -184,7 +186,7 @@ class GoogleClient extends BaseClient {if (typeof this.options.artifactsPrompt === 'string' && this.options.artifactsPrompt) {promptPrefix = `${promptPrefix ?? ''}\n${this.options.artifactsPrompt}`.trim();}- this.options.promptPrefix = promptPrefix;+ this.systemMessage = promptPrefix;this.initializeClient();return this;}@@ -314,7 +316,7 @@ class GoogleClient extends BaseClient {}this.augmentedPrompt = await this.contextHandlers.createContext();- this.options.promptPrefix = this.augmentedPrompt + this.options.promptPrefix;+ this.systemMessage = this.augmentedPrompt + this.systemMessage;}}@@ -361,8 +363,8 @@ class GoogleClient extends BaseClient {throw new Error('[GoogleClient] PaLM 2 and Codey models are no longer supported.');}- if (this.options.promptPrefix) {- const instructionsTokenCount = this.getTokenCount(this.options.promptPrefix);+ if (this.systemMessage) {+ const instructionsTokenCount = this.getTokenCount(this.systemMessage);this.maxContextTokens = this.maxContextTokens - instructionsTokenCount;if (this.maxContextTokens < 0) {@@ -417,8 +419,8 @@ class GoogleClient extends BaseClient {],};- if (this.options.promptPrefix) {- payload.instances[0].context = this.options.promptPrefix;+ if (this.systemMessage) {+ payload.instances[0].context = this.systemMessage;}logger.debug('[GoogleClient] buildMessages', payload);@@ -464,7 +466,7 @@ class GoogleClient extends BaseClient {identityPrefix = `${identityPrefix}\nYou are ${this.options.modelLabel}`;}- let promptPrefix = (this.options.promptPrefix ?? '').trim();+ let promptPrefix = (this.systemMessage ?? '').trim();if (identityPrefix) {promptPrefix = `${identityPrefix}${promptPrefix}`;@@ -648,7 +650,7 @@ class GoogleClient extends BaseClient {generationConfig: googleGenConfigSchema.parse(this.modelOptions),};- const promptPrefix = (this.options.promptPrefix ?? '').trim();+ const promptPrefix = (this.systemMessage ?? '').trim();if (promptPrefix.length) {requestOptions.systemInstruction = {parts: [diff --git a/api/server/services/Files/Code/process.js b/api/server/services/Files/Code/process.jsindex ce8acf4ad3..c92e628589 100644--- a/api/server/services/Files/Code/process.js+++ b/api/server/services/Files/Code/process.js@@ -209,7 +209,7 @@ const primeFiles = async (options, apiKey) => {const { handleFileUpload: uploadCodeEnvFile } = getStrategyFunctions(FileSources.execute_code,);- const stream = await getDownloadStream(file.filepath);+ const stream = await getDownloadStream(options.req, file.filepath);const fileIdentifier = await uploadCodeEnvFile({req: options.req,stream,diff --git a/api/server/services/Files/Firebase/crud.js b/api/server/services/Files/Firebase/crud.jsindex 76a6c1d8d4..8319f908ef 100644--- a/api/server/services/Files/Firebase/crud.js+++ b/api/server/services/Files/Firebase/crud.js@@ -224,10 +224,11 @@ async function uploadFileToFirebase({ req, file, file_id }) {/*** Retrieves a readable stream for a file from Firebase storage.*+ * @param {ServerRequest} _req* @param {string} filepath - The filepath.* @returns {Promise<ReadableStream>} A readable stream of the file.*/-async function getFirebaseFileStream(filepath) {+async function getFirebaseFileStream(_req, filepath) {try {const storage = getFirebaseStorage();if (!storage) {diff --git a/api/server/services/Files/Local/crud.js b/api/server/services/Files/Local/crud.jsindex 97a067d794..c2bb75c125 100644--- a/api/server/services/Files/Local/crud.js+++ b/api/server/services/Files/Local/crud.js@@ -286,11 +286,31 @@ async function uploadLocalFile({ req, file, file_id }) {/*** Retrieves a readable stream for a file from local storage.*+ * @param {ServerRequest} req - The request object from Express* @param {string} filepath - The filepath.* @returns {ReadableStream} A readable stream of the file.*/-function getLocalFileStream(filepath) {+function getLocalFileStream(req, filepath) {try {+ if (filepath.includes('/uploads/')) {+ const basePath = filepath.split('/uploads/')[1];++ if (!basePath) {+ logger.warn(`Invalid base path: ${filepath}`);+ throw new Error(`Invalid file path: ${filepath}`);+ }++ const fullPath = path.join(req.app.locals.paths.uploads, basePath);+ const uploadsDir = req.app.locals.paths.uploads;++ const rel = path.relative(uploadsDir, fullPath);+ if (rel.startsWith('..') || path.isAbsolute(rel) || rel.includes(`..${path.sep}`)) {+ logger.warn(`Invalid relative file path: ${filepath}`);+ throw new Error(`Invalid file path: ${filepath}`);+ }++ return fs.createReadStream(fullPath);+ }return fs.createReadStream(filepath);} catch (error) {logger.error('Error getting local file stream:', error);diff --git a/client/package.json b/client/package.jsonindex 917333ce25..df85c2521c 100644--- a/client/package.json+++ b/client/package.json@@ -66,8 +66,8 @@"html-to-image": "^1.11.11","i18next": "^24.2.2","i18next-browser-languagedetector": "^8.0.3",- "js-cookie": "^3.0.5","input-otp": "^1.4.2",+ "js-cookie": "^3.0.5","librechat-data-provider": "*","lodash": "^4.17.21","lucide-react": "^0.394.0",@@ -86,7 +86,7 @@"react-i18next": "^15.4.0","react-lazy-load-image-component": "^1.6.0","react-markdown": "^9.0.1",- "react-resizable-panels": "^2.1.1",+ "react-resizable-panels": "^2.1.7","react-router-dom": "^6.11.2","react-speech-recognition": "^3.10.0","react-textarea-autosize": "^8.4.0",@@ -144,4 +144,4 @@"vite-plugin-node-polyfills": "^0.17.0","vite-plugin-pwa": "^0.21.1"}-}\ No newline at end of file+}diff --git a/package-lock.json b/package-lock.jsonindex 802cedd19e..ef573d7010 100644--- a/package-lock.json+++ b/package-lock.json@@ -1095,7 +1095,7 @@"react-i18next": "^15.4.0","react-lazy-load-image-component": "^1.6.0","react-markdown": "^9.0.1",- "react-resizable-panels": "^2.1.1",+ "react-resizable-panels": "^2.1.7","react-router-dom": "^6.11.2","react-speech-recognition": "^3.10.0","react-textarea-autosize": "^8.4.0",@@ -1609,6 +1609,15 @@"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz","integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="},+ "client/node_modules/react-resizable-panels": {+ "version": "2.1.7",+ "resolved": "https://registry.npmjs.org/react-resizable-panels/-/react-resizable-panels-2.1.7.tgz",+ "integrity": "sha512-JtT6gI+nURzhMYQYsx8DKkx6bSoOGFp7A3CwMrOb8y5jFHFyqwo9m68UhmXRw57fRVJksFn1TSlm3ywEQ9vMgA==",+ "peerDependencies": {+ "react": "^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc",+ "react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc"+ }+ },"client/node_modules/rollup": {"version": "4.34.6","resolved": "https://registry.npmjs.org/rollup/-/rollup-4.34.6.tgz",@@ -31919,15 +31928,6 @@}}},- "node_modules/react-resizable-panels": {- "version": "2.1.1",- "resolved": "https://registry.npmjs.org/react-resizable-panels/-/react-resizable-panels-2.1.1.tgz",- "integrity": "sha512-+cUV/yZBYfiBj+WJtpWDJ3NtR4zgDZfHt3+xtaETKE+FCvp+RK/NJxacDQKxMHgRUTSkfA6AnGljQ5QZNsCQoA==",- "peerDependencies": {- "react": "^16.14.0 || ^17.0.0 || ^18.0.0",- "react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0"- }- },"node_modules/react-router": {"version": "6.22.0","resolved": "https://registry.npmjs.org/react-router/-/react-router-6.22.0.tgz",