Interface: BatteryLifecycleHooks
Defined in: src/batteries/llm/chat_common/lifecycle.ts:78
The opt-in lifecycle option block mixed into each battery's options interface. Every phase transition fires onLifecycle (the firehose) AND the matching per-phase hook; subscribe to either or both. All optional — omitting them leaves behavior byte-for-byte unchanged.
Extended by
TesseractJsOcrAdapterOptionsTransformersJsCaptionAdapterOptionsTransformersJsAdapterOptionsLiteRtLmAdapterOptionsTransformersJsGenerationAdapterOptionsTransformersJsEmbeddingsAdapterOptionsWebLLMChatCompletionsAdapterOptionsTransformersJsSttAdapterOptions
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
onCompiling? | BatteryLifecycleCallback | Engine/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. | src/batteries/llm/chat_common/lifecycle.ts:89 |
onComplete? | BatteryLifecycleCallback | After the turn's output is parsed + persisted, before ack (fires per turn). | src/batteries/llm/chat_common/lifecycle.ts:95 |
onError? | BatteryLifecycleCallback | A load or generation failure (paired with nack). | src/batteries/llm/chat_common/lifecycle.ts:97 |
onGenerating? | BatteryLifecycleCallback | Immediately before the provider generate call (fires per turn). | src/batteries/llm/chat_common/lifecycle.ts:93 |
onLifecycle? | BatteryLifecycleCallback | Fires on EVERY phase transition (the firehose). | src/batteries/llm/chat_common/lifecycle.ts:80 |
onLoading? | BatteryLifecycleCallback | Weights/runtime loading — may fire repeatedly with progress as the provider reports it. | src/batteries/llm/chat_common/lifecycle.ts:82 |
onReady? | BatteryLifecycleCallback | Engine/pipeline resolved and cached, before the first generation. | src/batteries/llm/chat_common/lifecycle.ts:91 |