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
The most common and valuable composition is taking:
ποΈ RAG
Letβs look at adding in a retrieval step to a prompt and LLM, which adds
ποΈ Multiple chains
Runnables can easily be used to string together multiple Chains
ποΈ Querying a SQL DB
We can replicate our SQLDatabaseChain with Runnables.
ποΈ Agents
You can pass a Runnable into an agent.
ποΈ Code writing
Example of how to use LCEL to write Python code.
ποΈ Routing by semantic similarity
With LCEL you can easily add [custom routing
ποΈ Adding memory
This shows how to add memory to an arbitrary chain. Right now, you can
ποΈ Adding moderation
This shows how to add in moderation (or other safeguards) around your
ποΈ Managing prompt size
Agents dynamically call tools. The results of those tool calls are added
ποΈ Using tools
You can use any Tools with Runnables easily.