🔍 refactor: OCR Fully Optional with Defaults for "Upload as Text" (#9856)
Some checks are pending
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Waiting to run
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Waiting to run
Docker Dev Images Build / build (Dockerfile, librechat-dev, node) (push) Waiting to run
Docker Dev Images Build / build (Dockerfile.multi, librechat-dev-api, api-build) (push) Waiting to run
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Waiting to run
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Blocked by required conditions

* refactor: move `loadOCRConfig` from `packages/data-provider` to `packages/api` and return `undefined` if not explicitly configured

* fix: loadOCRConfig import from @librechat/api

* refactor: update defaultTextMimeTypes to support virtually all file types for text parsing

* fix: improve OCR capability check and error message for unsupported file types

* ci: remove unnecessary ocr expectation from AppService test
This commit is contained in:
Danny Avila 2025-09-26 11:56:11 -04:00 committed by GitHub
parent 3d7eaf0fcc
commit 4b5b46604c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 15 additions and 20 deletions

View file

@ -1,4 +1,5 @@
export * from './mistral/crud';
export * from './audio';
export * from './text';
export * from './mistral/crud';
export * from './ocr';
export * from './parse';
export * from './text';

View file

@ -303,7 +303,7 @@ async function loadAuthConfig(context: OCRContext): Promise<AuthConfig> {
/**
* Gets the model configuration
*/
function getModelConfig(ocrConfig: TCustomConfig['ocr']): string {
function getModelConfig(ocrConfig?: TCustomConfig['ocr']): string {
const modelConfig = ocrConfig?.mistralModel || '';
if (!modelConfig.trim()) {

View file

@ -0,0 +1,15 @@
import { OCRStrategy } from 'librechat-data-provider';
import type { TCustomConfig } from 'librechat-data-provider';
export function loadOCRConfig(config?: TCustomConfig['ocr']): TCustomConfig['ocr'] | undefined {
if (!config) return;
const baseURL = config?.baseURL ?? '';
const apiKey = config?.apiKey ?? '';
const mistralModel = config?.mistralModel ?? '';
return {
apiKey,
baseURL,
mistralModel,
strategy: config?.strategy ?? OCRStrategy.MISTRAL_OCR,
};
}