batch_iterate#

langchain_core.utils.iter.batch_iterate(size: int | None, iterable: Iterable[T]) Iterator[List[T]][source]#

Utility batching function.

Parameters:
  • size (int | None) – The size of the batch. If None, returns a single batch.

  • iterable (Iterable[T]) – The iterable to batch.

Yields:

The batches of the iterable.

Return type:

Iterator[List[T]]