Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the LangChain RegressionTester class.
LangChain
from langchain.testing import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ChainTester instead of RegressionTester.
Trying to import from langchain.chains instead of langchain.testing.
✗ Incorrect
The RegressionTester class is imported from langchain.testing to perform regression tests on chains.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the class RegressionTester instead of the chain instance.
Using a variable name not defined like 'test_chain'.
✗ Incorrect
The RegressionTester is initialized with the chain instance to test, here 'my_chain'.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'execute' or 'test' which are not valid methods.
Using 'run_regression' which does not exist.
✗ Incorrect
The correct method to run regression tests in RegressionTester is run_tests().
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'fail_count' instead of 'num_failures'.
Using 'report()' instead of 'summary()'.
✗ Incorrect
The results object has 'num_failures' attribute for failure count and 'summary()' method for a readable report.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the dictionary as expected output.
Using a literal string instead of the variable for expected parameter.
✗ Incorrect
The input is a dictionary with text, expected output is a string, and the expected parameter uses the variable expected_output.