Bird
0
0

What is wrong with this LangServe class?

medium📝 Debug Q14 of 15
LangChain - Production Deployment
What is wrong with this LangServe class?
class BadAPI:
    def call(self, input):
        return input[::-1]
AThe return statement should convert input to uppercase
BThe input slicing syntax is incorrect
CThe class must inherit from a base LangServe class
DThe method should be named __call__, not call
Step-by-Step Solution
Solution:
  1. Step 1: Check method name required by LangServe

    LangServe expects a __call__ method to make the class callable.
  2. Step 2: Analyze method name in BadAPI

    BadAPI uses call instead of __call__, so it won't work as expected.
  3. Final Answer:

    The method should be named __call__, not call -> Option D
  4. Quick Check:

    __call__ method required [OK]
Quick Trick: Method must be __call__, not call [OK]
Common Mistakes:
MISTAKES
  • Using call instead of __call__
  • Assuming inheritance is mandatory
  • Thinking input slicing is invalid

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes