Exercise#4 LCEL Cheatsheet & Howtos

Objective

Learn to use the various Runnable APIs for building chains.

Use the LangChain Runnable resources below to answer the questions.

Link to LCEL cheatsheet

Link to LCEL How-tos

Useful patterns that you MUST learn:

1. Which Runnable function would you use to setup chain with fallbacks?

solution

2. How can you add retry logic to invoke?

solution

3. How can you set the maximum number of parallel calls?

solution

4. How would you add fields (keys/values) in chain that can be set during invoke/batch/stream?

solution

5. You need to have if-then-logic to select a Runnable at runtime based on input?

solution

6. There are 10 fields in the output for a chain, you only want to return 2. How would you accompalish it?

solution

7. How can you create a visual representation of a chain?

solution

8. You would like to see all prompts handled in a chain?

solution

9. Variables are not passed to the next chain automatically. How would you pass data through?

solution

10. You would like to use one of the chains out of N based on the input

solution

Checkout LCEL cheatsheet

  • Open the link below or use the PDF to try out the various Runnable capabilities.
  • Bookmark link for future reference

Checkout LCEL How-tos

Read through and try out few of these how-tos.

How to: chain runnables

How to: stream runnables

How to: invoke runnables in parallel

How to: add default invocation args to runnables

How to: turn any function into a runnable

How to: pass through inputs from one chain step to the next

How to: configure runnable behavior at runtime

How to: add message history (memory) to a chain

How to: route between sub-chains

How to: create a dynamic (self-constructing) chain

How to: inspect runnables

How to: add fallbacks to a runnable

How to: pass runtime secrets to a runnable