Bird
0
0

What will be the output of this code?

medium📝 component behavior Q13 of 15
LangChain - Chains and LCEL
What will be the output of this code?
passthrough = RunnablePassthrough()
lambda_runner = RunnableLambda(lambda x: x.upper())
result = lambda_runner.invoke(passthrough.invoke('hello'))
print(result)
A'HELLO'
B'hello'
CError: RunnablePassthrough cannot be invoked
D'Hello'
Step-by-Step Solution
Solution:
  1. Step 1: Trace RunnablePassthrough output

    Calling passthrough.invoke('hello') returns 'hello' unchanged.
  2. Step 2: Apply RunnableLambda function

    The lambda converts input to uppercase, so 'hello'.upper() returns 'HELLO'.
  3. Final Answer:

    'HELLO' -> Option A
  4. Quick Check:

    Passthrough returns input, lambda uppercases it = C [OK]
Quick Trick: Passthrough returns input, lambda transforms it [OK]
Common Mistakes:
  • Expecting passthrough to modify input
  • Confusing case conversion result
  • Assuming runtime error on invoke

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes