test_few_shot_functionality() — langchain Function Reference
Architecture documentation for the test_few_shot_functionality() function in test_few_shot.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 84c6314f_e1ec_be6d_d884_674df546910d["test_few_shot_functionality()"] e4e12a36_798e_ddc0_ab57_e44de269c7e7["test_few_shot.py"] 84c6314f_e1ec_be6d_d884_674df546910d -->|defined in| e4e12a36_798e_ddc0_ab57_e44de269c7e7 style 84c6314f_e1ec_be6d_d884_674df546910d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/prompts/test_few_shot.py lines 119–144
async def test_few_shot_functionality() -> None:
"""Test that few shot works with examples."""
prefix = "This is a test about {content}."
suffix = "Now you try to talk about {new_content}."
examples = [
{"question": "foo", "answer": "bar"},
{"question": "baz", "answer": "foo"},
]
prompt = FewShotPromptTemplate(
suffix=suffix,
prefix=prefix,
input_variables=["content", "new_content"],
examples=examples,
example_prompt=EXAMPLE_PROMPT,
example_separator="\n",
)
expected_output = (
"This is a test about animals.\n"
"foo: bar\n"
"baz: foo\n"
"Now you try to talk about party."
)
output = prompt.format(content="animals", new_content="party")
assert output == expected_output
output = await prompt.aformat(content="animals", new_content="party")
assert output == expected_output
Domain
Subdomains
Source
Frequently Asked Questions
What does test_few_shot_functionality() do?
test_few_shot_functionality() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/prompts/test_few_shot.py.
Where is test_few_shot_functionality() defined?
test_few_shot_functionality() is defined in libs/core/tests/unit_tests/prompts/test_few_shot.py at line 119.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free