-
Notifications
You must be signed in to change notification settings - Fork 15.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
175 additions
and
177 deletions.
There are no files selected for viewing
12 changes: 2 additions & 10 deletions
12
docs/docs/versions/migrating_chains/constitutional_chain.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 3 additions & 11 deletions
14
docs/docs/versions/migrating_chains/conversation_chain.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 11 additions & 12 deletions
23
docs/docs/versions/migrating_chains/conversation_retrieval_chain.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "raw", | ||
"metadata": { | ||
"vscode": { | ||
"languageId": "raw" | ||
} | ||
}, | ||
"source": [ | ||
"---\n", | ||
"sidebar_position: 1\n", | ||
"---" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# How to migrate from v0.0 chains\n", | ||
"\n", | ||
"LangChain has evolved since its initial release, and many of the original \"Chain\" classes \n", | ||
"have been deprecated in favor of the more flexible and powerful frameworks of LCEL and LangGraph. \n", | ||
"\n", | ||
"This guide will help you migrate your existing v0.0 chains to the new abstractions.\n", | ||
"\n", | ||
":::info How deprecated implementations work\n", | ||
"Even though many of these implementations are deprecated, they are **still supported** in the codebase. \n", | ||
"However, they are not recommended for new development, and we recommend re-implementing them using the following guides!\n", | ||
"\n", | ||
"To see the planned removal version for each deprecated implementation, check their API reference.\n", | ||
":::\n", | ||
"\n", | ||
":::info Prerequisites\n", | ||
"\n", | ||
"These guides assume some familiarity with the following concepts:\n", | ||
"- [LangChain Expression Language](/docs/concepts#langchain-expression-language-lcel)\n", | ||
"- [LangGraph](https://langchain-ai.github.io/langgraph/)\n", | ||
":::\n", | ||
"\n", | ||
"LangChain maintains a number of legacy abstractions. Many of these can be reimplemented via short combinations of LCEL and LangGraph primitives.\n", | ||
"\n", | ||
"### LCEL\n", | ||
"[LCEL](/docs/concepts/#langchain-expression-language-lcel) is designed to streamline the process of building useful apps with LLMs and combining related components. It does this by providing:\n", | ||
"\n", | ||
"1. **A unified interface**: Every LCEL object implements the `Runnable` interface, which defines a common set of invocation methods (`invoke`, `batch`, `stream`, `ainvoke`, ...). This makes it possible to also automatically and consistently support useful operations like streaming of intermediate steps and batching, since every chain composed of LCEL objects is itself an LCEL object.\n", | ||
"2. **Composition primitives**: LCEL provides a number of primitives that make it easy to compose chains, parallelize components, add fallbacks, dynamically configure chain internals, and more.\n", | ||
"\n", | ||
"### LangGraph\n", | ||
"[LangGraph](https://langchain-ai.github.io/langgraph/), built on top of LCEL, allows for performant orchestrations of application components while maintaining concise and readable code. It includes built-in persistence, support for cycles, and prioritizes controllability.\n", | ||
"If LCEL grows unwieldy for larger or more complex chains, they may benefit from a LangGraph implementation.\n", | ||
"\n", | ||
"### Advantages\n", | ||
"Using these frameworks for existing v0.0 chains confers some advantages:\n", | ||
"\n", | ||
"- The resulting chains typically implement the full `Runnable` interface, including streaming and asynchronous support where appropriate;\n", | ||
"- The chains may be more easily extended or modified;\n", | ||
"- The parameters of the chain are typically surfaced for easier customization (e.g., prompts) over previous versions, which tended to be subclasses and had opaque parameters and internals.\n", | ||
"- If using LangGraph, the chain supports built-in persistence, allowing for conversational experiences via a \"memory\" of the chat history.\n", | ||
"- If using LangGraph, the steps of the chain can be streamed, allowing for greater control and customizability.\n", | ||
"\n", | ||
"\n", | ||
"The below pages assist with migration from various specific chains to LCEL and LangGraph:\n", | ||
"\n", | ||
"- [LLMChain](./llm_chain.ipynb)\n", | ||
"- [ConversationChain](./conversation_chain.ipynb)\n", | ||
"- [RetrievalQA](./retrieval_qa.ipynb)\n", | ||
"- [ConversationalRetrievalChain](./conversation_retrieval_chain.ipynb)\n", | ||
"- [StuffDocumentsChain](./stuff_docs_chain.ipynb)\n", | ||
"- [MapReduceDocumentsChain](./map_reduce_chain.ipynb)\n", | ||
"- [MapRerankDocumentsChain](./map_rerank_docs_chain.ipynb)\n", | ||
"- [RefineDocumentsChain](./refine_docs_chain.ipynb)\n", | ||
"- [LLMRouterChain](./llm_router_chain.ipynb)\n", | ||
"- [MultiPromptChain](./multi_prompt_chain.ipynb)\n", | ||
"- [LLMMathChain](./llm_math_chain.ipynb)\n", | ||
"- [ConstitutionalChain](./constitutional_chain.ipynb)\n", | ||
"\n", | ||
"Check out the [LCEL conceptual docs](/docs/concepts/#langchain-expression-language-lcel) and [LangGraph docs](https://langchain-ai.github.io/langgraph/) for more background information." | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 2 additions & 10 deletions
12
docs/docs/versions/migrating_chains/llm_router_chain.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.