mirror of
https://github.com/hwchase17/langchain
synced 2024-11-08 07:10:35 +00:00
d3ec00b566
Co-authored-by: Nuno Campos <nuno@boringbits.io> Co-authored-by: Davis Chase <130488702+dev2049@users.noreply.github.com> Co-authored-by: Zander Chase <130414180+vowelparrot@users.noreply.github.com> Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
"""Test PAL chain."""
|
|
|
|
from langchain import OpenAI
|
|
from langchain.chains.pal.base import PALChain
|
|
|
|
|
|
def test_math_prompt() -> None:
|
|
"""Test math prompt."""
|
|
llm = OpenAI(temperature=0, max_tokens=512)
|
|
pal_chain = PALChain.from_math_prompt(llm)
|
|
question = (
|
|
"Jan has three times the number of pets as Marcia. "
|
|
"Marcia has two more pets than Cindy. "
|
|
"If Cindy has four pets, how many total pets do the three have?"
|
|
)
|
|
output = pal_chain.run(question)
|
|
assert output == "28"
|
|
|
|
|
|
def test_colored_object_prompt() -> None:
|
|
"""Test colored object prompt."""
|
|
llm = OpenAI(temperature=0, max_tokens=512)
|
|
pal_chain = PALChain.from_colored_object_prompt(llm)
|
|
question = (
|
|
"On the desk, you see two blue booklets, "
|
|
"two purple booklets, and two yellow pairs of sunglasses. "
|
|
"If I remove all the pairs of sunglasses from the desk, "
|
|
"how many purple items remain on it?"
|
|
)
|
|
output = pal_chain.run(question)
|
|
assert output == "2"
|