0
0
LangChainframework~10 mins

Regression testing for chains in LangChain - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the LangChain RegressionTester class.

LangChain
from langchain.testing import [1]
Drag options to blanks, or click blank then click option'
ARegressionTester
BChainTester
CChainRegression
DTestChain
Attempts:
3 left
💡 Hint
Common Mistakes
Using ChainTester instead of RegressionTester.
Trying to import from langchain.chains instead of langchain.testing.
2fill in blank
medium

Complete the code to create a RegressionTester instance for a chain named 'my_chain'.

LangChain
tester = RegressionTester(chain=[1])
Drag options to blanks, or click blank then click option'
Atest_chain
Bchain
CRegressionTester
Dmy_chain
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the class RegressionTester instead of the chain instance.
Using a variable name not defined like 'test_chain'.
3fill in blank
hard

Fix the error in the code to run regression tests and store results.

LangChain
results = tester.[1]()
Drag options to blanks, or click blank then click option'
Arun_tests
Bexecute
Crun_regression
Dtest
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'execute' or 'test' which are not valid methods.
Using 'run_regression' which does not exist.
4fill in blank
hard

Fill both blanks to assert the test results contain no failures and print summary.

LangChain
assert results.[1] == 0
print(results.[2]())
Drag options to blanks, or click blank then click option'
Anum_failures
Bsummary
Cfail_count
Dreport
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'fail_count' instead of 'num_failures'.
Using 'report()' instead of 'summary()'.
5fill in blank
hard

Fill all three blanks to create a regression test with input, expected output, and run the test.

LangChain
test_input = [1]
expected_output = [2]
tester.add_test(input=test_input, expected=[3])
Drag options to blanks, or click blank then click option'
A{'text': 'Hello'}
B'Hello, world!'
Cexpected_output
D{'text': 'Hi'}
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the dictionary as expected output.
Using a literal string instead of the variable for expected parameter.