test_log.py — langchain Source File
Architecture documentation for test_log.py, a python file in the langchain codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 60c70288_7962_a47f_d9f2_01467def64c3["test_log.py"] 59e0d3b0_0f8e_4b79_d442_e9b4821561c7["langchain_core.agents"] 60c70288_7962_a47f_d9f2_01467def64c3 --> 59e0d3b0_0f8e_4b79_d442_e9b4821561c7 67ceb331_75bc_297f_f874_f62744fc78b8["langchain_classic.agents.format_scratchpad.log"] 60c70288_7962_a47f_d9f2_01467def64c3 --> 67ceb331_75bc_297f_f874_f62744fc78b8 style 60c70288_7962_a47f_d9f2_01467def64c3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from langchain_core.agents import AgentAction
from langchain_classic.agents.format_scratchpad.log import format_log_to_str
def test_single_agent_action_observation() -> None:
intermediate_steps = [
(AgentAction(tool="Tool1", tool_input="input1", log="Log1"), "Observation1"),
]
expected_result = "Log1\nObservation: Observation1\nThought: "
assert format_log_to_str(intermediate_steps) == expected_result
def test_multiple_agent_actions_observations() -> None:
intermediate_steps = [
(AgentAction(tool="Tool1", tool_input="input1", log="Log1"), "Observation1"),
(AgentAction(tool="Tool2", tool_input="input2", log="Log2"), "Observation2"),
(AgentAction(tool="Tool3", tool_input="input3", log="Log3"), "Observation3"),
]
expected_result = """Log1\nObservation: Observation1\nThought: \
Log2\nObservation: Observation2\nThought: Log3\nObservation: \
Observation3\nThought: """
assert format_log_to_str(intermediate_steps) == expected_result
def test_custom_prefixes() -> None:
intermediate_steps = [
(AgentAction(tool="Tool1", tool_input="input1", log="Log1"), "Observation1"),
]
observation_prefix = "Custom Observation: "
llm_prefix = "Custom Thought: "
expected_result = "Log1\nCustom Observation: Observation1\nCustom Thought: "
assert (
format_log_to_str(intermediate_steps, observation_prefix, llm_prefix)
== expected_result
)
def test_empty_intermediate_steps() -> None:
output = format_log_to_str([])
assert output == ""
Domain
Subdomains
Functions
Dependencies
- langchain_classic.agents.format_scratchpad.log
- langchain_core.agents
Source
Frequently Asked Questions
What does test_log.py do?
test_log.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, ApiManagement subdomain.
What functions are defined in test_log.py?
test_log.py defines 4 function(s): test_custom_prefixes, test_empty_intermediate_steps, test_multiple_agent_actions_observations, test_single_agent_action_observation.
What does test_log.py depend on?
test_log.py imports 2 module(s): langchain_classic.agents.format_scratchpad.log, langchain_core.agents.
Where is test_log.py in the architecture?
test_log.py is located at libs/langchain/tests/unit_tests/agents/format_scratchpad/test_log.py (domain: LangChainCore, subdomain: ApiManagement, directory: libs/langchain/tests/unit_tests/agents/format_scratchpad).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free