Deprecations and Breaking Changes
Source: langchain

---sidebar_position: 3sidebar_label: Changeskeywords: [retrievalqa, llmchain, conversationalretrievalchain]---# Deprecations and Breaking ChangesThis 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/overview/) for a summary of what's new in this release.## Breaking changesAs 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`@tool` decorator now assigns the function doc-string as the tool description. Previously, the `@tool` decoratorusing to prepend the function signature.Before 0.2.0:```python@tooldef 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 packageCode 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 removalCode 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 V1If you are using `astream_events`, please review how to [migrate to astream events v2](/docs/versions/v0_2/migrating_astream_events).### langchain_core#### try_load_from_hubIn module: `utils.loading`Deprecated: 0.1.30Removal: 0.3.0Alternative: Using the hwchase17/langchain-hub repo for prompts is deprecated. Please use https://smith.langchain.com/hub instead.#### BaseLanguageModel.predictIn module: `language_models.base`Deprecated: 0.1.7Removal: 0.3.0Alternative: invoke#### BaseLanguageModel.predict_messagesIn module: `language_models.base`Deprecated: 0.1.7Removal: 0.3.0Alternative: invoke#### BaseLanguageModel.apredictIn module: `language_models.base`Deprecated: 0.1.7Removal: 0.3.0Alternative: ainvoke#### BaseLanguageModel.apredict_messagesIn module: `language_models.base`Deprecated: 0.1.7Removal: 0.3.0Alternative: ainvoke#### RunTypeEnumIn module: `tracers.schemas`Deprecated: 0.1.0Removal: 0.3.0Alternative: Use string instead.#### TracerSessionV1BaseIn module: `tracers.schemas`Deprecated: 0.1.0Removal: 0.3.0Alternative:#### TracerSessionV1CreateIn module: `tracers.schemas`Deprecated: 0.1.0Removal: 0.3.0Alternative:#### TracerSessionV1In module: `tracers.schemas`Deprecated: 0.1.0Removal: 0.3.0Alternative:#### TracerSessionBaseIn module: `tracers.schemas`Deprecated: 0.1.0Removal: 0.3.0Alternative:#### TracerSessionIn module: `tracers.schemas`Deprecated: 0.1.0Removal: 0.3.0Alternative:#### BaseRunIn module: `tracers.schemas`Deprecated: 0.1.0Removal: 0.3.0Alternative: Run#### LLMRunIn module: `tracers.schemas`Deprecated: 0.1.0Removal: 0.3.0Alternative: Run#### ChainRunIn module: `tracers.schemas`Deprecated: 0.1.0Removal: 0.3.0Alternative: Run#### ToolRunIn module: `tracers.schemas`Deprecated: 0.1.0Removal: 0.3.0Alternative: Run#### BaseChatModel.__call__In module: `language_models.chat_models`Deprecated: 0.1.7Removal: 0.3.0Alternative: invoke#### BaseChatModel.call_as_llmIn module: `language_models.chat_models`Deprecated: 0.1.7Removal: 0.3.0Alternative: invoke#### BaseChatModel.predictIn module: `language_models.chat_models`Deprecated: 0.1.7Removal: 0.3.0Alternative: invoke#### BaseChatModel.predict_messagesIn module: `language_models.chat_models`Deprecated: 0.1.7Removal: 0.3.0Alternative: invoke#### BaseChatModel.apredictIn module: `language_models.chat_models`Deprecated: 0.1.7Removal: 0.3.0Alternative: ainvoke#### BaseChatModel.apredict_messagesIn module: `language_models.chat_models`Deprecated: 0.1.7Removal: 0.3.0Alternative: ainvoke#### BaseLLM.__call__In module: `language_models.llms`Deprecated: 0.1.7Removal: 0.3.0Alternative: invoke#### BaseLLM.predictIn module: `language_models.llms`Deprecated: 0.1.7Removal: 0.3.0Alternative: invoke#### BaseLLM.predict_messagesIn module: `language_models.llms`Deprecated: 0.1.7Removal: 0.3.0Alternative: invoke#### BaseLLM.apredictIn module: `language_models.llms`Deprecated: 0.1.7Removal: 0.3.0Alternative: ainvoke#### BaseLLM.apredict_messagesIn module: `language_models.llms`Deprecated: 0.1.7Removal: 0.3.0Alternative: ainvoke#### BaseRetriever.get_relevant_documentsIn module: `retrievers`Deprecated: 0.1.46Removal: 0.3.0Alternative: invoke#### BaseRetriever.aget_relevant_documentsIn module: `retrievers`Deprecated: 0.1.46Removal: 0.3.0Alternative: ainvoke#### ChatPromptTemplate.from_role_stringsIn module: `prompts.chat`Deprecated: 0.0.1Removal:Alternative: from_messages classmethod#### ChatPromptTemplate.from_stringsIn module: `prompts.chat`Deprecated: 0.0.1Removal:Alternative: from_messages classmethod#### BaseTool.__call__In module: `tools`Deprecated: 0.1.47Removal: 0.3.0Alternative: invoke#### convert_pydantic_to_openai_functionIn module: `utils.function_calling`Deprecated: 0.1.16Removal: 0.3.0Alternative: langchain_core.utils.function_calling.convert_to_openai_function()#### convert_pydantic_to_openai_toolIn module: `utils.function_calling`Deprecated: 0.1.16Removal: 0.3.0Alternative: langchain_core.utils.function_calling.convert_to_openai_tool()#### convert_python_function_to_openai_functionIn module: `utils.function_calling`Deprecated: 0.1.16Removal: 0.3.0Alternative: langchain_core.utils.function_calling.convert_to_openai_function()#### format_tool_to_openai_functionIn module: `utils.function_calling`Deprecated: 0.1.16Removal: 0.3.0Alternative: langchain_core.utils.function_calling.convert_to_openai_function()#### format_tool_to_openai_toolIn module: `utils.function_calling`Deprecated: 0.1.16Removal: 0.3.0Alternative: langchain_core.utils.function_calling.convert_to_openai_tool()### langchain#### AgentTypeIn module: `agents.agent_types`Deprecated: 0.1.0Removal: 0.3.0Alternative: Use [LangGraph](/docs/how_to/migrate_agent/) or 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.0Removal: 0.3.0Alternative: invoke#### Chain.acallIn module: `chains.base`Deprecated: 0.1.0Removal: 0.3.0Alternative: ainvoke#### Chain.runIn module: `chains.base`Deprecated: 0.1.0Removal: 0.3.0Alternative: invoke#### Chain.arunIn module: `chains.base`Deprecated: 0.1.0Removal: 0.3.0Alternative: ainvoke#### Chain.applyIn module: `chains.base`Deprecated: 0.1.0Removal: 0.3.0Alternative: batch#### LLMChainIn module: `chains.llm`Deprecated: 0.1.17Removal: 0.3.0Alternative: [RunnableSequence](/docs/how_to/sequence/), e.g., `prompt | llm`This [migration guide](/docs/versions/migrating_chains/llm_chain) has a side-by-side comparison.#### LLMSingleActionAgentIn module: `agents.agent`Deprecated: 0.1.0Removal: 0.3.0Alternative: Use [LangGraph](/docs/how_to/migrate_agent/) or new agent constructor methods like create_react_agent, create_json_agent, create_structured_chat_agent, etc.#### AgentIn module: `agents.agent`Deprecated: 0.1.0Removal: 0.3.0Alternative: Use [LangGraph](/docs/how_to/migrate_agent/) or new agent constructor methods like create_react_agent, create_json_agent, create_structured_chat_agent, etc.#### OpenAIFunctionsAgentIn module: `agents.openai_functions_agent.base`Deprecated: 0.1.0Removal: 0.3.0Alternative: create_openai_functions_agent#### ZeroShotAgentIn module: `agents.mrkl.base`Deprecated: 0.1.0Removal: 0.3.0Alternative: create_react_agent#### MRKLChainIn module: `agents.mrkl.base`Deprecated: 0.1.0Removal: 0.3.0Alternative:#### ConversationalAgentIn module: `agents.conversational.base`Deprecated: 0.1.0Removal: 0.3.0Alternative: create_react_agent#### ConversationalChatAgentIn module: `agents.conversational_chat.base`Deprecated: 0.1.0Removal: 0.3.0Alternative: create_json_chat_agent#### ChatAgentIn module: `agents.chat.base`Deprecated: 0.1.0Removal: 0.3.0Alternative: create_react_agent#### OpenAIMultiFunctionsAgentIn module: `agents.openai_functions_multi_agent.base`Deprecated: 0.1.0Removal: 0.3.0Alternative: create_openai_tools_agent#### ReActDocstoreAgentIn module: `agents.react.base`Deprecated: 0.1.0Removal: 0.3.0Alternative:#### DocstoreExplorerIn module: `agents.react.base`Deprecated: 0.1.0Removal: 0.3.0Alternative:#### ReActTextWorldAgentIn module: `agents.react.base`Deprecated: 0.1.0Removal: 0.3.0Alternative:#### ReActChainIn module: `agents.react.base`Deprecated: 0.1.0Removal: 0.3.0Alternative:#### SelfAskWithSearchAgentIn module: `agents.self_ask_with_search.base`Deprecated: 0.1.0Removal: 0.3.0Alternative: create_self_ask_with_search#### SelfAskWithSearchChainIn module: `agents.self_ask_with_search.base`Deprecated: 0.1.0Removal: 0.3.0Alternative:#### StructuredChatAgentIn module: `agents.structured_chat.base`Deprecated: 0.1.0Removal: 0.3.0Alternative: create_structured_chat_agent#### RetrievalQAIn module: `chains.retrieval_qa.base`Deprecated: 0.1.17Removal: 0.3.0Alternative: [create_retrieval_chain](https://python.langchain.com/v0.2/api_reference/langchain/chains/langchain.chains.retrieval.create_retrieval_chain.html#langchain-chains-retrieval-create-retrieval-chain)This [migration guide](/docs/versions/migrating_chains/retrieval_qa) has a side-by-side comparison.#### load_agent_from_configIn module: `agents.loading`Deprecated: 0.1.0Removal: 0.3.0Alternative:#### load_agentIn module: `agents.loading`Deprecated: 0.1.0Removal: 0.3.0Alternative:#### initialize_agentIn module: `agents.initialize`Deprecated: 0.1.0Removal: 0.3.0Alternative: Use [LangGraph](/docs/how_to/migrate_agent/) or new agent constructor methods like create_react_agent, create_json_agent, create_structured_chat_agent, etc.#### XMLAgentIn module: `agents.xml.base`Deprecated: 0.1.0Removal: 0.3.0Alternative: create_xml_agent#### CohereRerankIn module: `retrievers.document_compressors.cohere_rerank`Deprecated: 0.0.30Removal: 0.3.0Alternative: langchain_cohere.CohereRerank#### ConversationalRetrievalChainIn module: `chains.conversational_retrieval.base`Deprecated: 0.1.17Removal: 0.3.0Alternative: [create_history_aware_retriever](https://python.langchain.com/v0.2/api_reference/langchain/chains/langchain.chains.history_aware_retriever.create_history_aware_retriever.html) together with [create_retrieval_chain](https://python.langchain.com/v0.2/api_reference/langchain/chains/langchain.chains.retrieval.create_retrieval_chain.html#langchain-chains-retrieval-create-retrieval-chain) (see example in docstring)This [migration guide](/docs/versions/migrating_chains/conversation_retrieval_chain) has a side-by-side comparison.#### create_extraction_chain_pydanticIn module: `chains.openai_tools.extraction`Deprecated: 0.1.14Removal: 0.3.0Alternative: [with_structured_output](/docs/how_to/structured_output/#the-with_structured_output-method) method on chat models that support tool calling.#### create_openai_fn_runnableIn module: `chains.structured_output.base`Deprecated: 0.1.14Removal: 0.3.0Alternative: [with_structured_output](/docs/how_to/structured_output/#the-with_structured_output-method) method on chat models that support tool calling.#### create_structured_output_runnableIn module: `chains.structured_output.base`Deprecated: 0.1.17Removal: 0.3.0Alternative: [with_structured_output](/docs/how_to/structured_output/#the-with_structured_output-method) method on chat models that support tool calling.#### create_openai_fn_chainIn module: `chains.openai_functions.base`Deprecated: 0.1.1Removal: 0.3.0Alternative: create_openai_fn_runnable#### create_structured_output_chainIn module: `chains.openai_functions.base`Deprecated: 0.1.1Removal: 0.3.0Alternative: ChatOpenAI.with_structured_output#### create_extraction_chainIn module: `chains.openai_functions.extraction`Deprecated: 0.1.14Removal: 0.3.0Alternative: [with_structured_output](/docs/how_to/structured_output/#the-with_structured_output-method) method on chat models that support tool calling.#### create_extraction_chain_pydanticIn module: `chains.openai_functions.extraction`Deprecated: 0.1.14Removal: 0.3.0Alternative: [with_structured_output](/docs/how_to/structured_output/#the-with_structured_output-method) method on chat models that support tool calling.