MCPcopy
hub / github.com/langchain-ai/langchain / _batch

Function _batch

libs/core/langchain_core/indexing/api.py:124–131  ·  view source on GitHub ↗

Utility batching function.

(size: int, iterable: Iterable[T])

Source from the content-addressed store, hash-verified

122
123
124def _batch(size: int, iterable: Iterable[T]) -> Iterator[List[T]]:
125 """Utility batching function."""
126 it = iter(iterable)
127 while True:
128 chunk = list(islice(it, size))
129 if not chunk:
130 return
131 yield chunk
132
133
134async def _abatch(size: int, iterable: AsyncIterable[T]) -> AsyncIterator[List[T]]:

Callers 1

indexFunction · 0.85

Calls 1

listFunction · 0.85

Tested by

no test coverage detected