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
🧹 chore: Cleanup base64 Handling for Azure Mistral OCR (#7892)
Danny Avila0103b4b08a6e
diff --git a/api/server/controllers/agents/client.js b/api/server/controllers/agents/client.jsindex be64d5a0e3..41e457e5b8 100644--- a/api/server/controllers/agents/client.js+++ b/api/server/controllers/agents/client.js@@ -330,7 +330,7 @@ class AgentClient extends BaseClient {if (mcpServers.length > 0) {try {- const mcpInstructions = await getMCPManager().formatInstructionsForContext(mcpServers);+ const mcpInstructions = getMCPManager().formatInstructionsForContext(mcpServers);if (mcpInstructions) {systemContent = [systemContent, mcpInstructions].filter(Boolean).join('\n\n');logger.debug('[AgentClient] Injected MCP instructions for servers:', mcpServers);diff --git a/packages/api/src/files/mistral/crud.spec.ts b/packages/api/src/files/mistral/crud.spec.tsindex 173c60edf2..309e5565b6 100644--- a/packages/api/src/files/mistral/crud.spec.ts+++ b/packages/api/src/files/mistral/crud.spec.ts@@ -1421,7 +1421,7 @@ describe('MistralOCR Service', () => {expect.objectContaining({document: expect.objectContaining({type: 'document_url',- document_url: expect.stringMatching(/^data:image\/jpeg;base64,/),+ document_url: expect.stringMatching(/^data:application\/pdf;base64,/),}),}),expect.any(Object),diff --git a/packages/api/src/files/mistral/crud.ts b/packages/api/src/files/mistral/crud.tsindex 200cc85196..1d36459886 100644--- a/packages/api/src/files/mistral/crud.ts+++ b/packages/api/src/files/mistral/crud.ts@@ -208,7 +208,6 @@ async function loadAuthConfig(context: OCRContext): Promise<AuthConfig> {const apiKeyConfig = ocrConfig?.apiKey || '';const baseURLConfig = ocrConfig?.baseURL || '';- // If both are hardcoded, return them directlyif (!needsEnvLoad(apiKeyConfig) && !needsEnvLoad(baseURLConfig)) {return {apiKey: apiKeyConfig,@@ -216,7 +215,6 @@ async function loadAuthConfig(context: OCRContext): Promise<AuthConfig> {};}- // Build auth fields arrayconst authFields: string[] = [];if (needsEnvLoad(baseURLConfig)) {@@ -227,14 +225,12 @@ async function loadAuthConfig(context: OCRContext): Promise<AuthConfig> {authFields.push(getEnvVarName(apiKeyConfig, 'OCR_API_KEY'));}- // Load auth valuesconst authValues = await context.loadAuthValues({userId: context.req.user?.id || '',authFields,optional: new Set(['OCR_BASEURL']),});- // Resolve each valueconst apiKey = await resolveConfigValue(apiKeyConfig, 'OCR_API_KEY', authValues);const baseURL = await resolveConfigValue(baseURLConfig,@@ -335,7 +331,6 @@ export const uploadMistralOCR = async (context: OCRContext): Promise<MistralOCRUconst { apiKey, baseURL } = await loadAuthConfig(context);const model = getModelConfig(context.req.app.locals?.ocr);- // Upload fileconst mistralFile = await uploadDocumentToMistral({filePath: context.file.path,fileName: context.file.originalname,@@ -343,14 +338,12 @@ export const uploadMistralOCR = async (context: OCRContext): Promise<MistralOCRUbaseURL,});- // Get signed URLconst signedUrlResponse = await getSignedUrl({apiKey,baseURL,fileId: mistralFile.id,});- // Perform OCRconst documentType = getDocumentType(context.file);const ocrResult = await performOCR({apiKey,@@ -394,21 +387,20 @@ export const uploadAzureMistralOCR = async (const { apiKey, baseURL } = await loadAuthConfig(context);const model = getModelConfig(context.req.app.locals?.ocr);- // Read file as base64const buffer = fs.readFileSync(context.file.path);const base64 = buffer.toString('base64');+ /** Uses actual mimetype of the file, 'image/jpeg' as fallback since it seems to be accepted regardless of mismatch */+ const base64Prefix = `data:${context.file.mimetype || 'image/jpeg'};base64,`;- // Perform OCR directly with base64const documentType = getDocumentType(context.file);const ocrResult = await performOCR({apiKey,baseURL,model,- url: `data:image/jpeg;base64,${base64}`,+ url: `${base64Prefix}${base64}`,documentType,});- // Process resultconst { text, images } = processOCRResult(ocrResult);return {