log_to_messages.py — langchain Source File
Architecture documentation for log_to_messages.py, a python file in the langchain codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 0169badd_d2f5_5297_9322_bf41736eee6c["log_to_messages.py"] 80d582c5_7cc3_ac96_2742_3dbe1cbd4e2b["langchain_core.agents"] 0169badd_d2f5_5297_9322_bf41736eee6c --> 80d582c5_7cc3_ac96_2742_3dbe1cbd4e2b d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"] 0169badd_d2f5_5297_9322_bf41736eee6c --> d758344f_537f_649e_f467_b9d7442e86df style 0169badd_d2f5_5297_9322_bf41736eee6c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from langchain_core.agents import AgentAction
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage
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
Functions
Dependencies
- langchain_core.agents
- langchain_core.messages
Source
Frequently Asked Questions
What does log_to_messages.py do?
log_to_messages.py is a source file in the langchain codebase, written in python. It belongs to the AgentOrchestration domain, ActionLogic subdomain.
What functions are defined in log_to_messages.py?
log_to_messages.py defines 1 function(s): format_log_to_messages.
What does log_to_messages.py depend on?
log_to_messages.py imports 2 module(s): langchain_core.agents, langchain_core.messages.
Where is log_to_messages.py in the architecture?
log_to_messages.py is located at libs/langchain/langchain_classic/agents/format_scratchpad/log_to_messages.py (domain: AgentOrchestration, subdomain: ActionLogic, 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