pub fn chunk_batch<'a>(
texts: &[&'a str],
max_batch_size: usize,
) -> Result<Vec<Vec<&'a str>>>Expand description
Split a batch of texts into chunks of at most max_batch_size.
Returns an empty vec for empty input. Useful for respecting provider-specific batch limits (e.g., OpenAI allows 2048 texts per request).
§Errors
Returns an error if max_batch_size is 0.
§Example
use llm_kernel::embedding::chunk_batch;
let chunks = chunk_batch(&["a", "b", "c", "d", "e"], 2).unwrap();
assert_eq!(chunks, vec![vec!["a", "b"], vec!["c", "d"], vec!["e"]]);