Cookbook
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.
📄️ Prompt + LLM
One of the most foundational Expression Language compositions is taking:
📄️ 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:
📄️ Multiple chains
Runnables can easily be used to combine multiple Chains:
📄️ 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: