Home / Function/ abatch() — langchain Function Reference

abatch() — langchain Function Reference

Architecture documentation for the abatch() function in configurable.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  a181c6e9_bc7d_4602_b682_a46a828c4706["abatch()"]
  018f968f_f1d1_6f85_05f3_0ff4abc12150["DynamicRunnable"]
  a181c6e9_bc7d_4602_b682_a46a828c4706 -->|defined in| 018f968f_f1d1_6f85_05f3_0ff4abc12150
  e71e4d88_aaa7_d3d0_06ac_43f60d5cd48a["prepare()"]
  a181c6e9_bc7d_4602_b682_a46a828c4706 -->|calls| e71e4d88_aaa7_d3d0_06ac_43f60d5cd48a
  b8fb710a_e6c9_a858_fadb_56b4feaab6e1["ainvoke()"]
  a181c6e9_bc7d_4602_b682_a46a828c4706 -->|calls| b8fb710a_e6c9_a858_fadb_56b4feaab6e1
  style a181c6e9_bc7d_4602_b682_a46a828c4706 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/runnables/configurable.py lines 199–235

    async def abatch(
        self,
        inputs: list[Input],
        config: RunnableConfig | list[RunnableConfig] | None = None,
        *,
        return_exceptions: bool = False,
        **kwargs: Any | None,
    ) -> list[Output]:
        configs = get_config_list(config, len(inputs))
        prepared = [self.prepare(c) for c in configs]

        if all(p is self.default for p, _ in prepared):
            return await self.default.abatch(
                inputs,
                [c for _, c in prepared],
                return_exceptions=return_exceptions,
                **kwargs,
            )

        if not inputs:
            return []

        async def ainvoke(
            prepared: tuple[Runnable[Input, Output], RunnableConfig],
            input_: Input,
        ) -> Output | Exception:
            bound, config = prepared
            if return_exceptions:
                try:
                    return await bound.ainvoke(input_, config, **kwargs)
                except Exception as e:
                    return e
            else:
                return await bound.ainvoke(input_, config, **kwargs)

        coros = map(ainvoke, prepared, inputs)
        return await gather_with_concurrency(configs[0].get("max_concurrency"), *coros)

Domain

Subdomains

Frequently Asked Questions

What does abatch() do?
abatch() is a function in the langchain codebase, defined in libs/core/langchain_core/runnables/configurable.py.
Where is abatch() defined?
abatch() is defined in libs/core/langchain_core/runnables/configurable.py at line 199.
What does abatch() call?
abatch() calls 2 function(s): ainvoke, prepare.

Analyze Your Own Codebase

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

Try Supermodel Free