Home / File/ log.py — langchain Source File

log.py — langchain Source File

Architecture documentation for log.py, a python file in the langchain codebase. 1 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  31f42e90_e6b7_ed1e_cbb2_36f357dd7b8c["log.py"]
  80d582c5_7cc3_ac96_2742_3dbe1cbd4e2b["langchain_core.agents"]
  31f42e90_e6b7_ed1e_cbb2_36f357dd7b8c --> 80d582c5_7cc3_ac96_2742_3dbe1cbd4e2b
  style 31f42e90_e6b7_ed1e_cbb2_36f357dd7b8c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from langchain_core.agents import AgentAction


def format_log_to_str(
    intermediate_steps: list[tuple[AgentAction, str]],
    observation_prefix: str = "Observation: ",
    llm_prefix: str = "Thought: ",
) -> str:
    """Construct the scratchpad that lets the agent continue its thought process.

    Args:
        intermediate_steps: List of tuples of AgentAction and observation strings.
        observation_prefix: Prefix to append the observation with.
        llm_prefix: Prefix to append the llm call with.

    Returns:
        The scratchpad.
    """
    thoughts = ""
    for action, observation in intermediate_steps:
        thoughts += action.log
        thoughts += f"\n{observation_prefix}{observation}\n{llm_prefix}"
    return thoughts

Subdomains

Dependencies

  • langchain_core.agents

Frequently Asked Questions

What does log.py do?
log.py is a source file in the langchain codebase, written in python. It belongs to the AgentOrchestration domain, ToolInterface subdomain.
What functions are defined in log.py?
log.py defines 1 function(s): format_log_to_str.
What does log.py depend on?
log.py imports 1 module(s): langchain_core.agents.
Where is log.py in the architecture?
log.py is located at libs/langchain/langchain_classic/agents/format_scratchpad/log.py (domain: AgentOrchestration, subdomain: ToolInterface, directory: libs/langchain/langchain_classic/agents/format_scratchpad).

Analyze Your Own Codebase

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

Try Supermodel Free