Home / Function/ _abatch() — langchain Function Reference

_abatch() — langchain Function Reference

Architecture documentation for the _abatch() function in api.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  edbcc417_69c7_d8bc_0a8b_194cd8c3dd73["_abatch()"]
  203188c0_72d6_6932_bc21_edf25c4c00ef["api.py"]
  edbcc417_69c7_d8bc_0a8b_194cd8c3dd73 -->|defined in| 203188c0_72d6_6932_bc21_edf25c4c00ef
  02b67c59_d093_f33d_633c_d77332eb191e["aindex()"]
  02b67c59_d093_f33d_633c_d77332eb191e -->|calls| edbcc417_69c7_d8bc_0a8b_194cd8c3dd73
  style edbcc417_69c7_d8bc_0a8b_194cd8c3dd73 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/indexing/api.py lines 101–113

async def _abatch(size: int, iterable: AsyncIterable[T]) -> AsyncIterator[list[T]]:
    """Utility batching function."""
    batch: list[T] = []
    async for element in iterable:
        if len(batch) < size:
            batch.append(element)

        if len(batch) >= size:
            yield batch
            batch = []

    if batch:
        yield batch

Subdomains

Called By

Frequently Asked Questions

What does _abatch() do?
_abatch() is a function in the langchain codebase, defined in libs/core/langchain_core/indexing/api.py.
Where is _abatch() defined?
_abatch() is defined in libs/core/langchain_core/indexing/api.py at line 101.
What calls _abatch()?
_abatch() is called by 1 function(s): aindex.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free