Skip to content

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

🪂 refactor: OCR Fallback for "Upload as Text" File Process (#10126)

Danny Avilabc77bbd1ba27
diff --git a/api/server/services/Files/process.js b/api/server/services/Files/process.js
index 5e945f0e36..701412523d 100644
--- a/api/server/services/Files/process.js
+++ b/api/server/services/Files/process.js
@@ -598,11 +598,22 @@ const processAgentFileUpload = async ({ req, res, metadata }) => {
if (shouldUseOCR && !(await checkCapability(req, AgentCapabilities.ocr))) {
throw new Error('OCR capability is not enabled for Agents');
} else if (shouldUseOCR) {
- const { handleFileUpload: uploadOCR } = getStrategyFunctions(
- appConfig?.ocr?.strategy ?? FileSources.mistral_ocr,
- );
- const { text, bytes, filepath: ocrFileURL } = await uploadOCR({ req, file, loadAuthValues });
- return await createTextFile({ text, bytes, filepath: ocrFileURL });
+ try {
+ const { handleFileUpload: uploadOCR } = getStrategyFunctions(
+ appConfig?.ocr?.strategy ?? FileSources.mistral_ocr,
+ );
+ const {
+ text,
+ bytes,
+ filepath: ocrFileURL,
+ } = await uploadOCR({ req, file, loadAuthValues });
+ return await createTextFile({ text, bytes, filepath: ocrFileURL });
+ } catch (ocrError) {
+ logger.error(
+ `[processAgentFileUpload] OCR processing failed for file "${file.originalname}", falling back to text extraction:`,
+ ocrError,
+ );
+ }
}
const shouldUseSTT = fileConfig.checkType(