Skip to Content

chunkAndEmbedMessage

chunkAndEmbedMessage(ctx: StorageOperationsContext, messageId: string, options: MemoryEngineEmbeddingOptions & ChunkingOptions): Promise<StoredMessage | null>

Defined in: src/lib/memoryEngine/embeddings.ts:232 

Chunk and embed a single message, storing chunk embeddings in the database. For messages shorter than chunkSize, falls back to whole-message embedding.

Requires embedding auth: options must carry apiKey or getToken (see EmbeddingOptions). EmbeddingOptions keeps both optional for the dual-auth pattern, so this is enforced at runtime — with neither, the embedding call rejects with "Either apiKey or getToken must be provided".

Parameters

ParameterTypeDescription

ctx

StorageOperationsContext

Storage operations context

messageId

string

Unique ID of the message to chunk and embed

options

MemoryEngineEmbeddingOptions & ChunkingOptions

Embedding and chunking options (auth required — see above)

Returns

Promise<StoredMessage | null>

The updated message, or null if message not found

Last updated on