test_self_ask.py — langchain Source File
Architecture documentation for test_self_ask.py, a python file in the langchain codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR e26f489d_c07e_3464_f097_d639972e317c["test_self_ask.py"] 80d582c5_7cc3_ac96_2742_3dbe1cbd4e2b["langchain_core.agents"] e26f489d_c07e_3464_f097_d639972e317c --> 80d582c5_7cc3_ac96_2742_3dbe1cbd4e2b f6de3d82_bf0d_075f_be8c_4044fd9e6ec8["langchain_classic.agents.output_parsers.self_ask"] e26f489d_c07e_3464_f097_d639972e317c --> f6de3d82_bf0d_075f_be8c_4044fd9e6ec8 style e26f489d_c07e_3464_f097_d639972e317c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from langchain_core.agents import AgentAction, AgentFinish
from langchain_classic.agents.output_parsers.self_ask import SelfAskOutputParser
def test_follow_up() -> None:
"""Test follow up parsing."""
parser = SelfAskOutputParser()
_input = "Follow up: what is two + 2"
output = parser.invoke(_input)
expected_output = AgentAction(
tool="Intermediate Answer",
tool_input="what is two + 2",
log=_input,
)
assert output == expected_output
# Test that also handles one word by default
_input = "Followup: what is two + 2"
output = parser.invoke(_input)
expected_output = AgentAction(
tool="Intermediate Answer",
tool_input="what is two + 2",
log=_input,
)
assert output == expected_output
def test_follow_up_custom() -> None:
"""Test follow up parsing for custom followups."""
parser = SelfAskOutputParser(followups=("Now:",))
_input = "Now: what is two + 2"
output = parser.invoke(_input)
expected_output = AgentAction(
tool="Intermediate Answer",
tool_input="what is two + 2",
log=_input,
)
assert output == expected_output
def test_finish() -> None:
"""Test standard finish."""
parser = SelfAskOutputParser()
_input = "So the final answer is: 4"
output = parser.invoke(_input)
expected_output = AgentFinish(return_values={"output": "4"}, log=_input)
assert output == expected_output
def test_finish_custom() -> None:
"""Test custom finish."""
parser = SelfAskOutputParser(finish_string="Finally: ")
_input = "Finally: 4"
output = parser.invoke(_input)
expected_output = AgentFinish(return_values={"output": "4"}, log=_input)
assert output == expected_output
Domain
Subdomains
Dependencies
- langchain_classic.agents.output_parsers.self_ask
- langchain_core.agents
Source
Frequently Asked Questions
What does test_self_ask.py do?
test_self_ask.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What functions are defined in test_self_ask.py?
test_self_ask.py defines 4 function(s): test_finish, test_finish_custom, test_follow_up, test_follow_up_custom.
What does test_self_ask.py depend on?
test_self_ask.py imports 2 module(s): langchain_classic.agents.output_parsers.self_ask, langchain_core.agents.
Where is test_self_ask.py in the architecture?
test_self_ask.py is located at libs/langchain/tests/unit_tests/agents/output_parsers/test_self_ask.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/langchain/tests/unit_tests/agents/output_parsers).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free