mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
🪂 refactor: OCR Fallback for "Upload as Text" File Process (#10126)
Some checks failed
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Has been cancelled
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Has been cancelled
Docker Dev Images Build / build (Dockerfile, librechat-dev, node) (push) Has been cancelled
Docker Dev Images Build / build (Dockerfile.multi, librechat-dev-api, api-build) (push) Has been cancelled
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Has been cancelled
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Has been cancelled
Some checks failed
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Has been cancelled
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Has been cancelled
Docker Dev Images Build / build (Dockerfile, librechat-dev, node) (push) Has been cancelled
Docker Dev Images Build / build (Dockerfile.multi, librechat-dev-api, api-build) (push) Has been cancelled
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Has been cancelled
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Has been cancelled
This commit is contained in:
parent
c602088178
commit
bc77bbd1ba
1 changed files with 16 additions and 5 deletions
|
|
@ -598,11 +598,22 @@ const processAgentFileUpload = async ({ req, res, metadata }) => {
|
||||||
if (shouldUseOCR && !(await checkCapability(req, AgentCapabilities.ocr))) {
|
if (shouldUseOCR && !(await checkCapability(req, AgentCapabilities.ocr))) {
|
||||||
throw new Error('OCR capability is not enabled for Agents');
|
throw new Error('OCR capability is not enabled for Agents');
|
||||||
} else if (shouldUseOCR) {
|
} else if (shouldUseOCR) {
|
||||||
|
try {
|
||||||
const { handleFileUpload: uploadOCR } = getStrategyFunctions(
|
const { handleFileUpload: uploadOCR } = getStrategyFunctions(
|
||||||
appConfig?.ocr?.strategy ?? FileSources.mistral_ocr,
|
appConfig?.ocr?.strategy ?? FileSources.mistral_ocr,
|
||||||
);
|
);
|
||||||
const { text, bytes, filepath: ocrFileURL } = await uploadOCR({ req, file, loadAuthValues });
|
const {
|
||||||
|
text,
|
||||||
|
bytes,
|
||||||
|
filepath: ocrFileURL,
|
||||||
|
} = await uploadOCR({ req, file, loadAuthValues });
|
||||||
return await createTextFile({ text, bytes, filepath: ocrFileURL });
|
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(
|
const shouldUseSTT = fileConfig.checkType(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue