test_saving_loading_round_trip() — langchain Function Reference
Architecture documentation for the test_saving_loading_round_trip() function in test_loading.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD d79c29fd_79ea_0cdb_7a5a_67643787c7b0["test_saving_loading_round_trip()"] eea05055_0cc3_c5ac_867f_b44ce74a7c7b["test_loading.py"] d79c29fd_79ea_0cdb_7a5a_67643787c7b0 -->|defined in| eea05055_0cc3_c5ac_867f_b44ce74a7c7b style d79c29fd_79ea_0cdb_7a5a_67643787c7b0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/prompts/test_loading.py lines 63–88
def test_saving_loading_round_trip(tmp_path: Path) -> None:
"""Test equality when saving and loading a prompt."""
simple_prompt = PromptTemplate(
input_variables=["adjective", "content"],
template="Tell me a {adjective} joke about {content}.",
)
simple_prompt.save(file_path=tmp_path / "prompt.yaml")
loaded_prompt = load_prompt(tmp_path / "prompt.yaml")
assert loaded_prompt == simple_prompt
few_shot_prompt = FewShotPromptTemplate(
input_variables=["adjective"],
prefix="Write antonyms for the following words.",
example_prompt=PromptTemplate(
input_variables=["input", "output"],
template="Input: {input}\nOutput: {output}",
),
examples=[
{"input": "happy", "output": "sad"},
{"input": "tall", "output": "short"},
],
suffix="Input: {adjective}\nOutput:",
)
few_shot_prompt.save(file_path=tmp_path / "few_shot.yaml")
loaded_prompt = load_prompt(tmp_path / "few_shot.yaml")
assert loaded_prompt == few_shot_prompt
Domain
Subdomains
Source
Frequently Asked Questions
What does test_saving_loading_round_trip() do?
test_saving_loading_round_trip() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/prompts/test_loading.py.
Where is test_saving_loading_round_trip() defined?
test_saving_loading_round_trip() is defined in libs/core/tests/unit_tests/prompts/test_loading.py at line 63.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free