format_log_to_messages() — langchain Function Reference
Architecture documentation for the format_log_to_messages() function in log_to_messages.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 7d5ff957_1ff6_5eb9_1562_baebf436fd17["format_log_to_messages()"] 0169badd_d2f5_5297_9322_bf41736eee6c["log_to_messages.py"] 7d5ff957_1ff6_5eb9_1562_baebf436fd17 -->|defined in| 0169badd_d2f5_5297_9322_bf41736eee6c style 7d5ff957_1ff6_5eb9_1562_baebf436fd17 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/agents/format_scratchpad/log_to_messages.py lines 5–26
def format_log_to_messages(
intermediate_steps: list[tuple[AgentAction, str]],
template_tool_response: str = "{observation}",
) -> list[BaseMessage]:
"""Construct the scratchpad that lets the agent continue its thought process.
Args:
intermediate_steps: List of tuples of AgentAction and observation strings.
template_tool_response: Template to format the observation with.
Defaults to `"{observation}"`.
Returns:
The scratchpad.
"""
thoughts: list[BaseMessage] = []
for action, observation in intermediate_steps:
thoughts.append(AIMessage(content=action.log))
human_message = HumanMessage(
content=template_tool_response.format(observation=observation),
)
thoughts.append(human_message)
return thoughts
Domain
Subdomains
Source
Frequently Asked Questions
What does format_log_to_messages() do?
format_log_to_messages() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/format_scratchpad/log_to_messages.py.
Where is format_log_to_messages() defined?
format_log_to_messages() is defined in libs/langchain/langchain_classic/agents/format_scratchpad/log_to_messages.py at line 5.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free