Home / Function/ astream() — langchain Function Reference

astream() — langchain Function Reference

Architecture documentation for the astream() function in agent.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  330b61d2_ee14_f0e8_72b9_0f8c88b2a488["astream()"]
  493d4ce4_2303_08e0_2337_2bee34fe2662["AgentExecutor"]
  330b61d2_ee14_f0e8_72b9_0f8c88b2a488 -->|defined in| 493d4ce4_2303_08e0_2337_2bee34fe2662
  2930f93d_205d_ca04_bcf2_65e6c3a766a2["aplan()"]
  2930f93d_205d_ca04_bcf2_65e6c3a766a2 -->|calls| 330b61d2_ee14_f0e8_72b9_0f8c88b2a488
  6f0df2b5_3eae_dfc5_06c2_f70cf546a695["aplan()"]
  6f0df2b5_3eae_dfc5_06c2_f70cf546a695 -->|calls| 330b61d2_ee14_f0e8_72b9_0f8c88b2a488
  style 330b61d2_ee14_f0e8_72b9_0f8c88b2a488 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/agents/agent.py lines 1763–1792

    async def astream(
        self,
        input: dict[str, Any] | Any,
        config: RunnableConfig | None = None,
        **kwargs: Any,
    ) -> AsyncIterator[AddableDict]:
        """Async enables streaming over steps taken to reach final output.

        Args:
            input: Input to the agent.
            config: Config to use.
            kwargs: Additional arguments.

        Yields:
            Addable dictionary.
        """
        config = ensure_config(config)
        iterator = AgentExecutorIterator(
            self,
            input,
            config.get("callbacks"),
            tags=config.get("tags"),
            metadata=config.get("metadata"),
            run_name=config.get("run_name"),
            run_id=config.get("run_id"),
            yield_actions=True,
            **kwargs,
        )
        async for step in iterator:
            yield step

Subdomains

Called By

Frequently Asked Questions

What does astream() do?
astream() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/agent.py.
Where is astream() defined?
astream() is defined in libs/langchain/langchain_classic/agents/agent.py at line 1763.
What calls astream()?
astream() is called by 2 function(s): aplan, aplan.

Analyze Your Own Codebase

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

Try Supermodel Free