LemonChannels.Outbox.Chunker (lemon_channels v0.1.0)

View Source

Chunker for splitting long messages into channel-sized pieces.

Different channels have different message size limits. The chunker splits messages intelligently at word/sentence boundaries.

Summary

Functions

Split text into chunks that fit within the size limit.

Get the recommended chunk size for a channel.

Functions

chunk(text, opts \\ [])

@spec chunk(text :: binary(), opts :: keyword()) :: [binary()]

Split text into chunks that fit within the size limit.

Options

  • :chunk_size - Maximum characters per chunk (default: 4096)
  • :preserve_words - Try to break at word boundaries (default: true)
  • :preserve_sentences - Try to break at sentence boundaries (default: true)

chunk_size_for(channel_id)

@spec chunk_size_for(channel_id :: binary()) :: non_neg_integer()

Get the recommended chunk size for a channel.