Home / Function/ format_log_to_str() — langchain Function Reference

format_log_to_str() — langchain Function Reference

Architecture documentation for the format_log_to_str() function in log.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  76e7ea91_fa62_a6fa_2457_46257fd235a5["format_log_to_str()"]
  d46dedff_4c34_4e0b_aff7_f825fdcb6353["log.py"]
  76e7ea91_fa62_a6fa_2457_46257fd235a5 -->|defined in| d46dedff_4c34_4e0b_aff7_f825fdcb6353
  style 76e7ea91_fa62_a6fa_2457_46257fd235a5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/agents/format_scratchpad/log.py lines 4–23

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

Frequently Asked Questions

What does format_log_to_str() do?
format_log_to_str() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/format_scratchpad/log.py.
Where is format_log_to_str() defined?
format_log_to_str() is defined in libs/langchain/langchain_classic/agents/format_scratchpad/log.py at line 4.

Analyze Your Own Codebase

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

Try Supermodel Free