Bird
0
0

Given the code:

medium📝 component behavior Q13 of 15
LangChain - Chains and LCEL
Given the code:
parallel = RunnableParallel({"taskA": taskA, "taskB": taskB})
results = parallel.invoke()
print(results)

If taskA returns 'Hello' and taskB returns 'World', what will be printed?
A{'taskB': 'World', 'taskA': 'Hello'}
B['HelloWorld']
C'Hello World'
D{'taskA': 'Hello', 'taskB': 'World'}
Step-by-Step Solution
Solution:
  1. Step 1: Understand RunnableParallel output order

    RunnableParallel returns a dict with results in the order keys are defined.
  2. Step 2: Match task results to output dict

    taskA under 'taskA' returns 'Hello' first, taskB under 'taskB' returns 'World' second, so {'taskA': 'Hello', 'taskB': 'World'}.
  3. Final Answer:

    {'taskA': 'Hello', 'taskB': 'World'} -> Option D
  4. Quick Check:

    Order of results matches dict definition order [OK]
Quick Trick: Results dict order matches task definition order [OK]
Common Mistakes:
  • Reversing the order of task results
  • Thinking results are combined into one string
  • Expecting a list instead of dict output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes