Home / Function/ plan() — langchain Function Reference

plan() — langchain Function Reference

Architecture documentation for the plan() function in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  6cb59e5d_1cfb_c4ce_368c_4757582bc20c["plan()"]
  282deafd_7db7_2eb5_f124_f5c450b624d7["XMLAgent"]
  6cb59e5d_1cfb_c4ce_368c_4757582bc20c -->|defined in| 282deafd_7db7_2eb5_f124_f5c450b624d7
  style 6cb59e5d_1cfb_c4ce_368c_4757582bc20c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/agents/xml/base.py lines 65–87

    def plan(
        self,
        intermediate_steps: list[tuple[AgentAction, str]],
        callbacks: Callbacks = None,
        **kwargs: Any,
    ) -> AgentAction | AgentFinish:
        log = ""
        for action, observation in intermediate_steps:
            log += (
                f"<tool>{action.tool}</tool><tool_input>{action.tool_input}"
                f"</tool_input><observation>{observation}</observation>"
            )
        tools = ""
        for tool in self.tools:
            tools += f"{tool.name}: {tool.description}\n"
        inputs = {
            "intermediate_steps": log,
            "tools": tools,
            "question": kwargs["input"],
            "stop": ["</tool_input>", "</final_answer>"],
        }
        response = self.llm_chain(inputs, callbacks=callbacks)
        return response[self.llm_chain.output_key]

Subdomains

Frequently Asked Questions

What does plan() do?
plan() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/xml/base.py.
Where is plan() defined?
plan() is defined in libs/langchain/langchain_classic/agents/xml/base.py at line 65.

Analyze Your Own Codebase

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

Try Supermodel Free