Bird
0
0

Why does this code raise an error?

medium📝 Debug Q7 of 15
LangChain - Evaluation and Testing
Why does this code raise an error?
from langchain.schema.example import Example
examples = [
  Example(input="What is AI?", output=123)
]
AExample requires three arguments
BInput cannot be a string
CNo import statement for EvaluationExample
DOutput must be a string, not an integer
Step-by-Step Solution
Solution:
  1. Step 1: Check data types for input and output

    Input and output should be strings representing questions and answers.
  2. Step 2: Identify the error cause

    Output is given as an integer (123), which causes a type error.
  3. Final Answer:

    Output must be a string, not an integer -> Option D
  4. Quick Check:

    Output type must be string [OK]
Quick Trick: Output must be string, not number [OK]
Common Mistakes:
MISTAKES
  • Passing numbers instead of strings
  • Assuming input can be non-string
  • Ignoring type requirements

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes