Bird
0
0

Find the bug in this LangChain code:

medium📝 Debug Q7 of 15
LangChain - Fundamentals
Find the bug in this LangChain code:
from langchain.llms import OpenAI
llm = OpenAI(temperature="low")
print(llm("Hello"))
AOpenAI class cannot be imported from langchain.llms
BMissing API key for OpenAI
Cllm object cannot be called like a function
Dtemperature should be a number, not a string
Step-by-Step Solution
Solution:
  1. Step 1: Check parameter types

    The temperature parameter expects a number (like 0 or 0.7), not a string.
  2. Step 2: Identify error cause

    Passing "low" as a string causes a type error or unexpected behavior.
  3. Final Answer:

    temperature should be a number, not a string -> Option D
  4. Quick Check:

    temperature must be numeric, not string [OK]
Quick Trick: Use numbers for temperature, not words [OK]
Common Mistakes:
  • Assuming import is invalid
  • Thinking llm is not callable
  • Ignoring API key requirements

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes