Example code for accomplishing common tasks with the LangChain Expression Language (LCEL). These examples show how to compose different Runnable (the core LCEL interface) components to achieve various tasks. If you're just getting acquainted with LCEL, the Prompt + LLM page is a good place to start.
Several pages in this section include embedded interactive screencasts from Scrimba. They're a great resource for getting started - you can edit the included code whenever you want, just as if you were pair programming with a teacher!
📄️ Prompt + LLM
One of the most foundational Expression Language compositions is taking:
📄️ Multiple chains
Runnables can be used to combine multiple Chains together:
📄️ Retrieval augmented generation (RAG)
Let's now look at adding in a retrieval step to a prompt and an LLM, which adds up to a "retrieval-augmented generation" chain:
📄️ Querying a SQL DB
We can replicate our SQLDatabaseChain with Runnables.
📄️ Adding memory
This shows how to add memory to an arbitrary chain. Right now, you can use the memory classes but need to hook them up manually.
📄️ Using tools
Tools are also runnables, and can therefore be used within a chain:
You can pass a Runnable into an agent.