Skip to content
2 min read · 497 words

Interface: TesseractJsOcrAdapterOptions ​

Defined in: src/batteries/specialists/ocr/tesseract_js/types.ts:78

Constructor options for the tesseract.js OCR adapter.

Remarks ​

languages is REQUIRED with no default — language packs download on first use, so a deployment must never silently fetch packs for languages it didn't plan for (mirrors @nhtio/adk/batteries/media/engines/tesseract_js!TesseractJsEngineOptions).

Extends ​

Properties ​

PropertyTypeDescriptionInherited fromDefined in
cachePath?stringLocal cache directory for downloaded language data (forwarded to createWorker).-src/batteries/specialists/ocr/tesseract_js/types.ts:84
createWorker?CreateTesseractJsWorkerOverride worker creation entirely — the full worker-injection seam for tests.-src/batteries/specialists/ocr/tesseract_js/types.ts:96
isAvailable?() => booleanOverride the availability probe. Default: true (tesseract.js is environment-neutral).-src/batteries/specialists/ocr/tesseract_js/types.ts:98
langPath?stringWhere language data is fetched from (forwarded to createWorker).-src/batteries/specialists/ocr/tesseract_js/types.ts:82
languagesreadonly string[]Languages to load, e.g. ['eng']. REQUIRED — language packs download on first use.-src/batteries/specialists/ocr/tesseract_js/types.ts:80
onCompiling?BatteryLifecycleCallbackEngine/graph/shader compilation after download, before the first token. A COARSE marker: the on-device runtimes (LiteRT Engine.create, transformers.js from_pretrained) expose the boundary — download done, opaque WebGPU/WASM graph build about to run — but NOT a progress stream, so progress is usually absent. Often the slowest part of a cold start; without this it was invisible.BatteryLifecycleHooks.onCompilingsrc/batteries/llm/chat_common/lifecycle.ts:95
onComplete?BatteryLifecycleCallbackAfter the turn's output is parsed + persisted, before ack (fires per turn).BatteryLifecycleHooks.onCompletesrc/batteries/llm/chat_common/lifecycle.ts:105
onError?BatteryLifecycleCallbackA load or generation failure (paired with nack).BatteryLifecycleHooks.onErrorsrc/batteries/llm/chat_common/lifecycle.ts:107
onGenerating?BatteryLifecycleCallbackThe generate call is in progress (fires per turn). Fires once immediately before the provider call for most engines; engines that stream per-step generation progress (e.g. a diffusion denoise loop) fire it REPEATEDLY during generation, each carrying a progress in 0..1.BatteryLifecycleHooks.onGeneratingsrc/batteries/llm/chat_common/lifecycle.ts:103
onLifecycle?BatteryLifecycleCallbackFires on EVERY phase transition (the firehose).BatteryLifecycleHooks.onLifecyclesrc/batteries/llm/chat_common/lifecycle.ts:86
onLoading?BatteryLifecycleCallbackWeights/runtime loading — may fire repeatedly with progress as the provider reports it.BatteryLifecycleHooks.onLoadingsrc/batteries/llm/chat_common/lifecycle.ts:88
onReady?BatteryLifecycleCallbackEngine/pipeline resolved and cached, before the first generation.BatteryLifecycleHooks.onReadysrc/batteries/llm/chat_common/lifecycle.ts:97
tesseract?CreateTesseractJsModuleOverride the module resolution. Default: import('tesseract.js').-src/batteries/specialists/ocr/tesseract_js/types.ts:94
workerOptions?Record<string, unknown>Escape hatch forwarded into createWorker's options object, spread in AFTER langPath / cachePath (so an explicit workerOptions.langPath/workerOptions.cachePath wins). Exists because some bundlers mis-resolve tesseract.js's default workerPath/corePath URLs — this lets a consumer supply the correct bundled asset URLs without the adapter needing bespoke options for every bundler quirk.-src/batteries/specialists/ocr/tesseract_js/types.ts:92