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 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 thefrom_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
decorator
using to prepend the function signature.
Before 0.2.0:
@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.
python -c "from langchain.document_loaders.markdown import UnstructuredMarkdownLoader"
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.
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 LangGraph 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.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
This migration guide has a side-by-side comparison.
LLMSingleActionAgentβ
In module: agents.agent
Deprecated: 0.1.0
Removal: 0.3.0
Alternative: Use LangGraph or 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 LangGraph or new agent constructor methods like create_react_agent, create_json_agent, create_structured_chat_agent, etc.