The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
docs: Update v0.2 information (#21796)
Eugene Yurtsevfc644c0e1c41
diff --git a/docs/docs/versions/v0_2.mdx b/docs/docs/versions/v0_2.mdxdeleted file mode 100644index ef06512cf8..0000000000--- a/docs/docs/versions/v0_2.mdx+++ /dev/null@@ -1,175 +0,0 @@-----sidebar_position: 1-sidebar_label: v0.2------# LangChain v0.2--LangChain v0.2 was released in May 2024. This release includes a number of breaking changes and deprecations. This document contains a guide on upgrading to 0.2.x, as well as a list of deprecations and breaking changes.--## Migration--This documentation will help you upgrade your code to LangChain `0.2.x.`. To prepare for migration, we first recommend you take the following steps:--1. install the 0.2.x versions of langchain-core, langchain and upgrade to recent versions of other packages that you may be using (e.g. langgraph, langchain-community, langchain-openai, etc.)-2. Verify that your code runs properly with the new packages (e.g., unit tests pass)-3. Install a recent version of `langchain-cli` , and use the tool to replace old imports used by your code with the new imports. (See instructions below.)-4. Manually resolve any remaining deprecation warnings-5. Re-run unit tests--### Upgrade to new imports--We created a tool to help migrate your code. This tool is still in **beta** and may not cover all cases, but-we hope that it will help you migrate your code more quickly.--The migration script has the following limitations:--1. It’s limited to helping users move from old imports to new imports. It doesn’t help address other deprecations.-2. It can’t handle imports that involve `as` .-3. New imports are always placed in global scope, even if the old import that was replaced was located inside some local scope (e..g, function body).-4. It will likely miss some deprecated imports.--Here is an example of the import changes that the migration script can help apply automatically:---| From Package | To Package | Deprecated Import | New Import |-|---------------------|--------------------------|--------------------------------------------------------------------|---------------------------------------------------------------------|-| langchain | langchain-community | from langchain.vectorstores import InMemoryVectorStore | from langchain_community.vectorstores import InMemoryVectorStore |-| langchain-community | langchain_openai | from langchain_community.chat_models import ChatOpenAI | from langchain_openai import ChatOpenAI |-| langchain-community | langchain-core | from langchain_community.document_loaders import Blob | from langchain_core.document_loaders import Blob |-| langchain | langchain-core | from langchain.schema.document import Document | from langchain_core.documents import Document |-| langchain | langchain-text-splitters | from langchain.text_splitter import RecursiveCharacterTextSplitter | from langchain_text_splitters import RecursiveCharacterTextSplitter |---#### Deprecation timeline--We have two main types of deprecations:--1. Code that was moved from `langchain` into another package (e.g, `langchain-community`)--If you try to import it from `langchain`, the import will keep on working, but will raise a deprecation warning. The warning will provide a replacement import statement.-- ```python- python -c "from langchain.document_loaders.markdown import UnstructuredMarkdownLoader"-- ```-- ```python- LangChainDeprecationWarning: Importing UnstructuredMarkdownLoader from langchain.document_loaders is deprecated. Please replace deprecated imports:-- >> from langchain.document_loaders import UnstructuredMarkdownLoader-- with new imports of:-- >> from langchain_community.document_loaders import UnstructuredMarkdownLoader- ```--We will continue supporting the imports in `langchain` until release 0.4 as long as the relevant package where the code lives is installed. (e.g., as long as `langchain_community` is installed.)--However, we advise for users to not rely on these imports and instead migrate to the new imports. To help with this process, we’re releasing a migration script via the LangChain CLI. See further instructions in migration guide.--2. Code that has better alternatives available and will eventually be removed, so there’s only a single way to do things. (e.g., `predict_messages` method in ChatModels has been deprecated in favor of `invoke`).--Many of these were marked for removal in 0.2. We have bumped the removal to 0.3.---#### Installation--```bash-pip install langchain-cli-langchain-cli --version # <-- Make sure the version is at least 0.0.22-```--#### Usage--Given that the migration script is not perfect, you should make sure you have a backup of your code first (e.g., using version control like `git`).--You will need to run the migration script **twice** as it only applies one import replacement per run.--For example, say your code still uses `from langchain.chat_models import ChatOpenAI`:--After the first run, you’ll get: `from langchain_community.chat_models import ChatOpenAI`-After the second run, you’ll get: `from langchain_openai import ChatOpenAI`--```bash-# Run a first time-# Will replace from langchain.chat_models import ChatOpenAI-langchain-cli migrate [path to code] --diff # Preview-langchain-cli migrate [path to code] # Apply--# Run a second time to apply more import replacements-langchain-cli migrate [path to code] --diff # Preview-langchain-cli migrate [path to code] # Apply-```--#### Other options--```bash-# See help menu-langchain-cli migrate --help-# Preview Changes without applying-langchain-cli migrate --diff [path to code]-# Run on code including ipython notebooks-# Apply all import updates except for updates from langchain to langchain-core-langchain-cli migrate --disable langchain_to_core --include-ipynb [path to code]-```--## Deprecations and breaking changes--This code contains a list of deprecations and removals in the `langchain` and `langchain-core` packages.--### Breaking changes in 0.2.0--As of release 0.2.0, `langchain` is required to be integration-agnostic. This means that code in `langchain` should not by default instantiate any specific chat models, llms, embedding models, vectorstores etc; instead, the user will be required to specify those explicitly.--The following functions and classes require an explicit LLM to be passed as an argument:--- `langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreToolkit`-- `langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreRouterToolkit`-- `langchain.chains.openai_functions.get_openapi_chain`-- `langchain.chains.router.MultiRetrievalQAChain.from_retrievers`-- `langchain.indexes.VectorStoreIndexWrapper.query`-- `langchain.indexes.VectorStoreIndexWrapper.query_with_sources`-- `langchain.indexes.VectorStoreIndexWrapper.aquery_with_sources`-- `langchain.chains.flare.FlareChain`----The following classes now require passing an explicit Embedding model as an argument:--- `langchain.indexes.VectostoreIndexCreator`--The following code has been removed:--- `langchain.natbot.NatBotChain.from_default` removed in favor of the `from_llm` class method.---### Deprecations--We have two main types of deprecations:--1. Code that was moved from `langchain` into another package (e.g, `langchain-community`)-- If you try to import it from `langchain`, the import will keep on working, but will raise a deprecation warning. The warning will provide a replacement import statement.-- ```python- python -c "from langchain.document_loaders.markdown import UnstructuredMarkdownLoader"- ```-- ```python- LangChainDeprecationWarning: Importing UnstructuredMarkdownLoader from langchain.document_loaders is deprecated. Please replace deprecated imports:-- >> from langchain.document_loaders import UnstructuredMarkdownLoader-- with new imports of:-- >> from langchain_community.document_loaders import UnstructuredMarkdownLoader- ```-- We will continue supporting the imports in `langchain` until release 0.4 as long as the relevant package where the code lives is installed. (e.g., as long as `langchain_community` is installed.)-- However, we advise for users to not rely on these imports and instead migrate to the new imports. To help with this process, we’re releasing a migration script via the LangChain CLI. See further instructions in migration guide.--2. Code that has better alternatives available and will eventually be removed, so there’s only a single way to do things. (e.g., `predict_messages` method in ChatModels has been deprecated in favor of `invoke`).-- Many of these were marked for removal in 0.2. We have bumped the removal to 0.3.\ No newline at end of filediff --git a/docs/docs/versions/v_02/deprecations.mdx b/docs/docs/versions/v_02/deprecations.mdxnew file mode 100644index 0000000000..79f1af03ed--- /dev/null+++ b/docs/docs/versions/v_02/deprecations.mdx@@ -0,0 +1,894 @@+---+sidebar_position: 3+sidebar_label: Changes+---++# Deprecations and Breaking Changes++This code contains a list of deprecations and removals in the `langchain` and `langchain-core` packages.++New features and improvements are not listed here. See the [overview](/docs/versions/v_02/overview) for a summary of what's new in this release.++## Breaking changes++As of release 0.2.0, `langchain` is required to be integration-agnostic. This means that code in `langchain` should not by default instantiate any specific chat models, llms, embedding models, vectorstores etc; instead, the user will be required to specify those explicitly.++The following functions and classes require an explicit LLM to be passed as an argument:++- `langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreToolkit`+- `langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreRouterToolkit`+- `langchain.chains.openai_functions.get_openapi_chain`+- `langchain.chains.router.MultiRetrievalQAChain.from_retrievers`+- `langchain.indexes.VectorStoreIndexWrapper.query`+- `langchain.indexes.VectorStoreIndexWrapper.query_with_sources`+- `langchain.indexes.VectorStoreIndexWrapper.aquery_with_sources`+- `langchain.chains.flare.FlareChain`+++The following classes now require passing an explicit Embedding model as an argument:++- `langchain.indexes.VectostoreIndexCreator`++The following code has been removed:++- `langchain.natbot.NatBotChain.from_default` removed in favor of the `from_llm` class method.++Behavior was changed for the following code:++- `@tool` decorator now assigns the function doc-string as the tool description. Previously, the `@tool` decorator+using to prepend the function signature.++ Before 0.2.0:++ ```python+ @tool+ def my_tool(x: str) -> str:+ """Some description."""+ return "something"++ print(my_tool.description)+ ```++ Would result in: `my_tool: (x: str) -> str - Some description.`++ As of 0.2.0:++ It will result in: `Some description.`++## Code that moved to another package++Code that was moved from `langchain` into another package (e.g, `langchain-community`)++If you try to import it from `langchain`, the import will keep on working, but will raise a deprecation warning. The warning will provide a replacement import statement.++ ```shell+ python -c "from langchain.document_loaders.markdown import UnstructuredMarkdownLoader"+```++ ```shell+ LangChainDeprecationWarning: Importing UnstructuredMarkdownLoader from langchain.document_loaders is deprecated. Please replace deprecated imports:++ >> from langchain.document_loaders import UnstructuredMarkdownLoader++ with new imports of:++ >> from langchain_community.document_loaders import UnstructuredMarkdownLoader+```++We will continue supporting the imports in `langchain` until release 0.4 as long as the relevant package where the code lives is installed. (e.g., as long as `langchain_community` is installed.)++However, we advise for users to not rely on these imports and instead migrate to the new imports. To help with this process, we’re releasing a migration script via the LangChain CLI. See further instructions in migration guide.++## Code targeted for removal++Code that has better alternatives available and will eventually be removed, so there’s only a single way to do things. (e.g., `predict_messages` method in ChatModels has been deprecated in favor of `invoke`).++### astream events V1++If you are using `astream_events`, please review how to [migrate to astream events v2](/docs/versions/v_02/migrating_astream_events).++### langchain_core++#### try_load_from_hub+++In module: `utils.loading`+Deprecated: 0.1.30+Removal: 0.3.0+++Alternative: Using the hwchase17/langchain-hub repo for prompts is deprecated. Please use https://smith.langchain.com/hub instead.+++#### BaseLanguageModel.predict+++In module: `language_models.base`+Deprecated: 0.1.7+Removal: 0.3.0+++Alternative: invoke+++#### BaseLanguageModel.predict_messages+++In module: `language_models.base`+Deprecated: 0.1.7+Removal: 0.3.0+++Alternative: invoke+++#### BaseLanguageModel.apredict+++In module: `language_models.base`+Deprecated: 0.1.7+Removal: 0.3.0+++Alternative: ainvoke+++#### BaseLanguageModel.apredict_messages+++In module: `language_models.base`+Deprecated: 0.1.7+Removal: 0.3.0+++Alternative: ainvoke+++#### RunTypeEnum+++In module: `tracers.schemas`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: Use string instead.+++#### TracerSessionV1Base+++In module: `tracers.schemas`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative:+++#### TracerSessionV1Create+++In module: `tracers.schemas`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative:+++#### TracerSessionV1+++In module: `tracers.schemas`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative:+++#### TracerSessionBase+++In module: `tracers.schemas`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative:+++#### TracerSession+++In module: `tracers.schemas`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative:+++#### BaseRun+++In module: `tracers.schemas`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: Run+++#### LLMRun+++In module: `tracers.schemas`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: Run+++#### ChainRun+++In module: `tracers.schemas`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: Run+++#### ToolRun+++In module: `tracers.schemas`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: Run+++#### BaseChatModel.__call__+++In module: `language_models.chat_models`+Deprecated: 0.1.7+Removal: 0.3.0+++Alternative: invoke+++#### BaseChatModel.call_as_llm+++In module: `language_models.chat_models`+Deprecated: 0.1.7+Removal: 0.3.0+++Alternative: invoke+++#### BaseChatModel.predict+++In module: `language_models.chat_models`+Deprecated: 0.1.7+Removal: 0.3.0+++Alternative: invoke+++#### BaseChatModel.predict_messages+++In module: `language_models.chat_models`+Deprecated: 0.1.7+Removal: 0.3.0+++Alternative: invoke+++#### BaseChatModel.apredict+++In module: `language_models.chat_models`+Deprecated: 0.1.7+Removal: 0.3.0+++Alternative: ainvoke+++#### BaseChatModel.apredict_messages+++In module: `language_models.chat_models`+Deprecated: 0.1.7+Removal: 0.3.0+++Alternative: ainvoke+++#### BaseLLM.__call__+++In module: `language_models.llms`+Deprecated: 0.1.7+Removal: 0.3.0+++Alternative: invoke+++#### BaseLLM.predict+++In module: `language_models.llms`+Deprecated: 0.1.7+Removal: 0.3.0+++Alternative: invoke+++#### BaseLLM.predict_messages+++In module: `language_models.llms`+Deprecated: 0.1.7+Removal: 0.3.0+++Alternative: invoke+++#### BaseLLM.apredict+++In module: `language_models.llms`+Deprecated: 0.1.7+Removal: 0.3.0+++Alternative: ainvoke+++#### BaseLLM.apredict_messages+++In module: `language_models.llms`+Deprecated: 0.1.7+Removal: 0.3.0+++Alternative: ainvoke+++#### BaseRetriever.get_relevant_documents+++In module: `retrievers`+Deprecated: 0.1.46+Removal: 0.3.0+++Alternative: invoke+++#### BaseRetriever.aget_relevant_documents+++In module: `retrievers`+Deprecated: 0.1.46+Removal: 0.3.0+++Alternative: ainvoke+++#### ChatPromptTemplate.from_role_strings+++In module: `prompts.chat`+Deprecated: 0.0.1+Removal:+++Alternative: from_messages classmethod+++#### ChatPromptTemplate.from_strings+++In module: `prompts.chat`+Deprecated: 0.0.1+Removal:+++Alternative: from_messages classmethod+++#### BaseTool.__call__+++In module: `tools`+Deprecated: 0.1.47+Removal: 0.3.0+++Alternative: invoke+++#### convert_pydantic_to_openai_function+++In module: `utils.function_calling`+Deprecated: 0.1.16+Removal: 0.3.0+++Alternative: langchain_core.utils.function_calling.convert_to_openai_function()+++#### convert_pydantic_to_openai_tool+++In module: `utils.function_calling`+Deprecated: 0.1.16+Removal: 0.3.0+++Alternative: langchain_core.utils.function_calling.convert_to_openai_tool()+++#### convert_python_function_to_openai_function+++In module: `utils.function_calling`+Deprecated: 0.1.16+Removal: 0.3.0+++Alternative: langchain_core.utils.function_calling.convert_to_openai_function()+++#### format_tool_to_openai_function+++In module: `utils.function_calling`+Deprecated: 0.1.16+Removal: 0.3.0+++Alternative: langchain_core.utils.function_calling.convert_to_openai_function()+++#### format_tool_to_openai_tool+++In module: `utils.function_calling`+Deprecated: 0.1.16+Removal: 0.3.0+++Alternative: langchain_core.utils.function_calling.convert_to_openai_tool()+++## langchain+++#### AgentType+++In module: `agents.agent_types`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: Use new agent constructor methods like create_react_agent, create_json_agent, create_structured_chat_agent, etc.+++#### Chain.__call__+++In module: `chains.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: invoke+++#### Chain.acall+++In module: `chains.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: ainvoke+++#### Chain.run+++In module: `chains.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: invoke+++#### Chain.arun+++In module: `chains.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: ainvoke+++#### Chain.apply+++In module: `chains.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: batch+++#### LLMChain+++In module: `chains.llm`+Deprecated: 0.1.17+Removal: 0.3.0+++Alternative: RunnableSequence, e.g., `prompt | llm`+++#### LLMSingleActionAgent+++In module: `agents.agent`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: Use new agent constructor methods like create_react_agent, create_json_agent, create_structured_chat_agent, etc.+++#### Agent+++In module: `agents.agent`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: Use new agent constructor methods like create_react_agent, create_json_agent, create_structured_chat_agent, etc.+++#### OpenAIFunctionsAgent+++In module: `agents.openai_functions_agent.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: create_openai_functions_agent+++#### ZeroShotAgent+++In module: `agents.mrkl.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: create_react_agent+++#### MRKLChain+++In module: `agents.mrkl.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative:+++#### ConversationalAgent+++In module: `agents.conversational.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: create_react_agent+++#### ConversationalChatAgent+++In module: `agents.conversational_chat.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: create_json_chat_agent+++#### ChatAgent+++In module: `agents.chat.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: create_react_agent+++#### OpenAIMultiFunctionsAgent+++In module: `agents.openai_functions_multi_agent.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: create_openai_tools_agent+++#### ReActDocstoreAgent+++In module: `agents.react.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative:+++#### DocstoreExplorer+++In module: `agents.react.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative:+++#### ReActTextWorldAgent+++In module: `agents.react.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative:+++#### ReActChain+++In module: `agents.react.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative:+++#### SelfAskWithSearchAgent+++In module: `agents.self_ask_with_search.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: create_self_ask_with_search+++#### SelfAskWithSearchChain+++In module: `agents.self_ask_with_search.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative:+++#### StructuredChatAgent+++In module: `agents.structured_chat.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: create_structured_chat_agent+++#### RetrievalQA+++In module: `chains.retrieval_qa.base`+Deprecated: 0.1.17+Removal: 0.3.0+++Alternative: create_retrieval_chain+++#### load_agent_from_config+++In module: `agents.loading`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative:+++#### load_agent+++In module: `agents.loading`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative:+++#### initialize_agent+++In module: `agents.initialize`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: Use new agent constructor methods like create_react_agent, create_json_agent, create_structured_chat_agent, etc.+++#### XMLAgent+++In module: `agents.xml.base`+Deprecated: 0.1.0+Removal: 0.3.0+++Alternative: create_xml_agent+++#### CohereRerank+++In module: `retrievers.document_compressors.cohere_rerank`+Deprecated: 0.0.30+Removal: 0.3.0+++Alternative: langchain_cohere.CohereRerank+++#### ConversationalRetrievalChain+++In module: `chains.conversational_retrieval.base`+Deprecated: 0.1.17+Removal: 0.3.0+++Alternative: create_history_aware_retriever together with create_retrieval_chain (see example in docstring)+++#### create_extraction_chain_pydantic+++In module: `chains.openai_tools.extraction`+Deprecated: 0.1.14+Removal: 0.3.0+++Alternative: with_structured_output method on chat models that support tool calling.+++#### create_openai_fn_runnable+++In module: `chains.structured_output.base`+Deprecated: 0.1.14+Removal: 0.3.0+++Alternative: with_structured_output method on chat models that support tool calling.+++#### create_structured_output_runnable+++In module: `chains.structured_output.base`+Deprecated: 0.1.17+Removal: 0.3.0+++Alternative: with_structured_output method on chat models that support tool calling.+++#### create_openai_fn_chain+++In module: `chains.openai_functions.base`+Deprecated: 0.1.1+Removal: 0.3.0+++Alternative: create_openai_fn_runnable+++#### create_structured_output_chain+++In module: `chains.openai_functions.base`+Deprecated: 0.1.1+Removal: 0.3.0++Alternative: ChatOpenAI.with_structured_output+++#### create_extraction_chain+++In module: `chains.openai_functions.extraction`+Deprecated: 0.1.14+Removal: 0.3.0+++Alternative: with_structured_output method on chat models that support tool calling.+++#### create_extraction_chain_pydantic+++In module: `chains.openai_functions.extraction`+Deprecated: 0.1.14+Removal: 0.3.0+++Alternative: with_structured_output method on chat models that support tool calling.\ No newline at end of filediff --git a/docs/docs/versions/v_02/migrating_astream_events.mdx b/docs/docs/versions/v_02/migrating_astream_events.mdxnew file mode 100644index 0000000000..b14d8c5184--- /dev/null+++ b/docs/docs/versions/v_02/migrating_astream_events.mdx@@ -0,0 +1,118 @@+---+sidebar_position: 2+sidebar_label: astream_events v2+---++# Migrating to Astream Events v2++We've added a `v2` of the astream_events API with the release of `0.2.0`. You can see this [PR](https://github.com/langchain-ai/langchain/pull/21638) for more details.++The `v2` version is a re-write of the `v1` version, and should be more efficient, with more consistent output for the events. The `v1` version of the API will be deprecated in favor of the `v2` version and will be removed in `0.4.0`.++Below is a list of changes between the `v1` and `v2` versions of the API.+++### output for `on_chat_model_end`++In `v1`, the outputs associated with `on_chat_model_end` changed depending on whether the+chat model was run as a root level runnable or as part of a chain.++As a root level runnable the output was:++```python+"data": {"output": AIMessageChunk(content="hello world!", id='some id')}+```++As part of a chain the output was:++```+ "data": {+ "output": {+ "generations": [+ [+ {+ "generation_info": None,+ "message": AIMessageChunk(+ content="hello world!", id=AnyStr()+ ),+ "text": "hello world!",+ "type": "ChatGenerationChunk",+ }+ ]+ ],+ "llm_output": None,+ }+ },+```+++As of `v2`, the output will always be the simpler representation:++```python+"data": {"output": AIMessageChunk(content="hello world!", id='some id')}+```++:::note+Non chat models (i.e., regular LLMs) are will be consistently associated with the more verbose format for now.+:::++### output for `on_retriever_end`++`on_retriever_end` output will always return a list of `Documents`.++Before:+```python+{+ "data": {+ "output": [+ Document(...),+ Document(...),+ ...+ ]+ }+}+```++### Removed `on_retriever_stream`++The `on_retriever_stream` event was an artifact of the implementation and has been removed.++Full information associated with the event is already available in the `on_retriever_end` event.++Please use `on_retriever_end` instead.++### Removed `on_tool_stream`++The `on_tool_stream` event was an artifact of the implementation and has been removed.++Full information associated with the event is already available in the `on_tool_end` event.++Please use `on_tool_end` instead.++### Propagating Names++Names of runnables have been updated to be more consistent.++```python+model = GenericFakeChatModel(messages=infinite_cycle).configurable_fields(+ messages=ConfigurableField(+ id="messages",+ name="Messages",+ description="Messages return by the LLM",+ )+)+```++In `v1`, the event name was `RunnableConfigurableFields`.++In `v2`, the event name is `GenericFakeChatModel`.++If you're filtering by event names, check if you need to update your filters.++### RunnableRetry++Usage of [RunnableRetry](https://api.python.langchain.com/en/latest/runnables/langchain_core.runnables.retry.RunnableRetry.html)+within an LCEL chain being streamed generated an incorrect `on_chain_end` event in `v1` corresponding+to the failed runnable invocation that was being retried. This event has been removed in `v2`.++No action is required for this change.diff --git a/docs/docs/versions/v_02/migration.mdx b/docs/docs/versions/v_02/migration.mdxnew file mode 100644index 0000000000..ecca228ef1--- /dev/null+++ b/docs/docs/versions/v_02/migration.mdx@@ -0,0 +1,82 @@+---+sidebar_position: 1+sidebar_label: Migration+---++# Migration++LangChain v0.2 was released in May 2024. This release includes a number of [breaking changes and deprecations](/docs/versions/v_02/deprecations). This document contains a guide on upgrading to 0.2.x.++This documentation will help you upgrade your code to LangChain `0.2.x.`. To prepare for migration, we first recommend you take the following steps:++1. Install the 0.2.x versions of langchain-core, langchain and upgrade to recent versions of other packages that you may be using. (e.g. langgraph, langchain-community, langchain-openai, etc.)+2. Verify that your code runs properly with the new packages (e.g., unit tests pass).+3. Install a recent version of `langchain-cli` , and use the tool to replace old imports used by your code with the new imports. (See instructions below.)+4. Manually resolve any remaining deprecation warnings.+5. Re-run unit tests.+6. If you are using `astream_events`, please review how to [migrate to astream events v2](/docs/versions/v_02/migrating_astream_events).++## Upgrade to new imports++We created a tool to help migrate your code. This tool is still in **beta** and may not cover all cases, but+we hope that it will help you migrate your code more quickly.++The migration script has the following limitations:++1. It’s limited to helping users move from old imports to new imports. It does not help address other deprecations.+2. It can’t handle imports that involve `as` .+3. New imports are always placed in global scope, even if the old import that was replaced was located inside some local scope (e..g, function body).+4. It will likely miss some deprecated imports.++Here is an example of the import changes that the migration script can help apply automatically:+++| From Package | To Package | Deprecated Import | New Import |+|---------------------|--------------------------|--------------------------------------------------------------------|---------------------------------------------------------------------|+| langchain | langchain-community | from langchain.vectorstores import InMemoryVectorStore | from langchain_community.vectorstores import InMemoryVectorStore |+| langchain-community | langchain_openai | from langchain_community.chat_models import ChatOpenAI | from langchain_openai import ChatOpenAI |+| langchain-community | langchain-core | from langchain_community.document_loaders import Blob | from langchain_core.document_loaders import Blob |+| langchain | langchain-core | from langchain.schema.document import Document | from langchain_core.documents import Document |+| langchain | langchain-text-splitters | from langchain.text_splitter import RecursiveCharacterTextSplitter | from langchain_text_splitters import RecursiveCharacterTextSplitter |+++## Installation++```bash+pip install langchain-cli+langchain-cli --version # <-- Make sure the version is at least 0.0.22+```++## Usage++Given that the migration script is not perfect, you should make sure you have a backup of your code first (e.g., using version control like `git`).++You will need to run the migration script **twice** as it only applies one import replacement per run.++For example, say your code still uses `from langchain.chat_models import ChatOpenAI`:++After the first run, you’ll get: `from langchain_community.chat_models import ChatOpenAI`+After the second run, you’ll get: `from langchain_openai import ChatOpenAI`++```bash+# Run a first time+# Will replace from langchain.chat_models import ChatOpenAI+langchain-cli migrate [path to code] --diff # Preview+langchain-cli migrate [path to code] # Apply++# Run a second time to apply more import replacements+langchain-cli migrate [path to code] --diff # Preview+langchain-cli migrate [path to code] # Apply+```++### Other options++```bash+# See help menu+langchain-cli migrate --help+# Preview Changes without applying+langchain-cli migrate --diff [path to code]+# Run on code including ipython notebooks+# Apply all import updates except for updates from langchain to langchain-core+langchain-cli migrate --disable langchain_to_core --include-ipynb [path to code]+```diff --git a/docs/docs/versions/overview.mdx b/docs/docs/versions/v_02/overview.mdxsimilarity index 99%rename from docs/docs/versions/overview.mdxrename to docs/docs/versions/v_02/overview.mdxindex d6786e0251..188b932bbe 100644--- a/docs/docs/versions/overview.mdx+++ b/docs/docs/versions/v_02/overview.mdx@@ -9,7 +9,7 @@ sidebar_label: OverviewThe following features have been added during the development of 0.1.x:-- Better streaming support via the [Event Streaming API](https://python.langchain.com/docs/expression_language/streaming/#using-stream-events)+- Better streaming support via the [Event Streaming API](https://python.langchain.com/docs/expression_language/streaming/#using-stream-events).- [Standardized tool calling support](https://blog.langchain.dev/tool-calling-with-langchain/)- A standardized interface for [structuring output](https://github.com/langchain-ai/langchain/discussions/18154)- [@chain decorator](https://python.langchain.com/docs/expression_language/how_to/decorator/) to more easily create **RunnableLambdas**@@ -20,6 +20,7 @@ The following features have been added during the development of 0.1.x:- Interoperability of chat message histories across most providers- [Over 20+ partner packages in python](https://python.langchain.com/docs/integrations/platforms/) for popular integrations+## What’s coming to LangChain?- We’ve been working hard on [langgraph](https://python.langchain.com/docs/langgraph/). We will be building more capabilities on top of it and focusing on making it the go-to framework for agent architectures.diff --git a/docs/sidebars.js b/docs/sidebars.jsindex decc731621..003a6f4504 100644--- a/docs/sidebars.js+++ b/docs/sidebars.js@@ -69,13 +69,21 @@ module.exports = {collapsed: false,collapsible: false,items: [+ "versions/release_policy",+ "versions/packages",{- type: "autogenerated",- dirName: "versions",+ type: "category",+ label: "v0.2",+ items: [+ {+ type: "autogenerated",+ dirName: "versions/v_02",+ }+ ]}],},- "security",+ "security"],integrations: [{