aplan() — langchain Function Reference
Architecture documentation for the aplan() function in agent.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 6f0df2b5_3eae_dfc5_06c2_f70cf546a695["aplan()"] 43de2fb1_2cba_0c7f_1a66_b91200c3611f["RunnableMultiActionAgent"] 6f0df2b5_3eae_dfc5_06c2_f70cf546a695 -->|defined in| 43de2fb1_2cba_0c7f_1a66_b91200c3611f 330b61d2_ee14_f0e8_72b9_0f8c88b2a488["astream()"] 6f0df2b5_3eae_dfc5_06c2_f70cf546a695 -->|calls| 330b61d2_ee14_f0e8_72b9_0f8c88b2a488 3b577de0_fb5e_78d3_db9f_6c9a46325e38["aplan()"] 6f0df2b5_3eae_dfc5_06c2_f70cf546a695 -->|calls| 3b577de0_fb5e_78d3_db9f_6c9a46325e38 style 6f0df2b5_3eae_dfc5_06c2_f70cf546a695 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/agents/agent.py lines 567–607
async def aplan(
self,
intermediate_steps: list[tuple[AgentAction, str]],
callbacks: Callbacks = None,
**kwargs: Any,
) -> list[AgentAction] | AgentFinish:
"""Async based on past history and current inputs, decide what to do.
Args:
intermediate_steps: Steps the LLM has taken to date,
along with observations.
callbacks: Callbacks to run.
**kwargs: User inputs.
Returns:
Action specifying what tool to use.
"""
inputs = {**kwargs, "intermediate_steps": intermediate_steps}
final_output: Any = None
if self.stream_runnable:
# Use streaming to make sure that the underlying LLM is invoked in a
# streaming
# fashion to make it possible to get access to the individual LLM tokens
# when using stream_log with the AgentExecutor.
# Because the response from the plan is not a generator, we need to
# accumulate the output into final output and return that.
async for chunk in self.runnable.astream(
inputs,
config={"callbacks": callbacks},
):
if final_output is None:
final_output = chunk
else:
final_output += chunk
else:
final_output = await self.runnable.ainvoke(
inputs,
config={"callbacks": callbacks},
)
return final_output
Domain
Subdomains
Source
Frequently Asked Questions
What does aplan() do?
aplan() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/agent.py.
Where is aplan() defined?
aplan() is defined in libs/langchain/langchain_classic/agents/agent.py at line 567.
What does aplan() call?
aplan() calls 2 function(s): aplan, astream.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free