Bird
0
0

Which of the following is the correct way to run a regression test on a Langchain chain named my_chain with input {"text": "Hello"} and expected output {"result": "Hi"}?

easy📝 Syntax Q12 of 15
LangChain - Evaluation and Testing

Which of the following is the correct way to run a regression test on a Langchain chain named my_chain with input {"text": "Hello"} and expected output {"result": "Hi"}?

Aassert my_chain.invoke({"text": "Hello"}) == {"result": "Hi"}
Bmy_chain.test({"text": "Hello"}, {"result": "Hi"})
Cmy_chain.run({"text": "Hello"}) == {"result": "Hi"}
Dmy_chain.regression_test({"text": "Hello"}, {"result": "Hi"})
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct method to run chain and compare output

    Langchain chains use invoke or run to get output; to test, use assert to compare.
  2. Step 2: Check options for syntax correctness

    assert my_chain.invoke({"text": "Hello"}) == {"result": "Hi"} uses assert with invoke and compares to expected output correctly.
  3. Final Answer:

    assert my_chain.invoke({"text": "Hello"}) == {"result": "Hi"} -> Option A
  4. Quick Check:

    Use assert with invoke for regression test [OK]
Quick Trick: Use assert with invoke to compare outputs in regression tests [OK]
Common Mistakes:
MISTAKES
  • Using non-existent methods like regression_test
  • Comparing outputs without assert
  • Confusing run and test methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes