chunkAndEmbedAllMessages
chunkAndEmbedAllMessages(
ctx:StorageOperationsContext,options:MemoryEngineEmbeddingOptions&ChunkingOptions,filter?:object):Promise<number>
Defined in: src/lib/memoryEngine/embeddings.ts:340
Chunk and embed messages that don’t yet have embeddings/chunks in the database. Uses chunking for long messages, whole-message embedding for short ones.
Upgrade note: by default this SKIPS messages that already have a whole-message
vector. An app migrating from whole-message embeddings to chunk-based search
must pass filter.rechunkExisting: true to (re)chunk those existing messages
— otherwise they get no chunk rows and chunk search stays incomplete for the
back-catalog.
Requires embedding auth (apiKey or getToken in options; see
EmbeddingOptions) — rejects with "Either apiKey or getToken must be provided" if neither is set.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
Storage operations context | |
|
|
Embedding and chunking options (auth required — see above) | |
|
|
|
Optional filter for which messages to embed |
|
|
|
Only embed messages from this conversation |
|
|
|
Minimum content length to embed (default: 30). Shorter messages are skipped. |
|
|
|
Re-chunk messages that have whole-message embeddings but no chunks |
|
|
|
Re-index rows the ciphertext sweep marked CHUNKS_DISCARDED_ORIGIN.
Off by default: this spends the user’s own embedding credits, so it belongs
to an explicit user action, never to a background pass. Opens that marker
only —
A successful repair clears the marker. Later model migrations include the repaired row without this flag. See CHUNKS_DISCARDED_ORIGIN. |
|
|
( |
Only embed messages with these roles |
Returns
Promise<number>
Number of messages embedded