mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-15 23:57:21 +00:00
langchain[patch]: update deprecation message for agent classes and constructors (#28369)
This commit is contained in:
parent
ec205fcee0
commit
8adc4a5bcc
@ -7,7 +7,20 @@ from langchain_core._api.deprecation import (
|
||||
warn_deprecated,
|
||||
)
|
||||
|
||||
AGENT_DEPRECATION_WARNING = (
|
||||
"LangChain agents will continue to be supported, but it is recommended for new "
|
||||
"use cases to be built with LangGraph. LangGraph offers a more flexible and "
|
||||
"full-featured framework for building agents, including support for "
|
||||
"tool-calling, persistence of state, and human-in-the-loop workflows. See "
|
||||
"LangGraph documentation for more details: "
|
||||
"https://langchain-ai.github.io/langgraph/. Refer here for its pre-built "
|
||||
"ReAct agent: "
|
||||
"https://langchain-ai.github.io/langgraph/how-tos/create-react-agent/"
|
||||
)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"AGENT_DEPRECATION_WARNING",
|
||||
"LangChainDeprecationWarning",
|
||||
"LangChainPendingDeprecationWarning",
|
||||
"deprecated",
|
||||
|
@ -47,6 +47,7 @@ from langchain_core.utils.input import get_color_mapping
|
||||
from pydantic import BaseModel, ConfigDict, model_validator
|
||||
from typing_extensions import Self
|
||||
|
||||
from langchain._api.deprecation import AGENT_DEPRECATION_WARNING
|
||||
from langchain.agents.agent_iterator import AgentExecutorIterator
|
||||
from langchain.agents.agent_types import AgentType
|
||||
from langchain.agents.tools import InvalidTool
|
||||
@ -633,10 +634,7 @@ class RunnableMultiActionAgent(BaseMultiActionAgent):
|
||||
|
||||
@deprecated(
|
||||
"0.1.0",
|
||||
message=(
|
||||
"Use new agent constructor methods like create_react_agent, create_json_agent, "
|
||||
"create_structured_chat_agent, etc."
|
||||
),
|
||||
message=AGENT_DEPRECATION_WARNING,
|
||||
removal="1.0",
|
||||
)
|
||||
class LLMSingleActionAgent(BaseSingleActionAgent):
|
||||
@ -724,10 +722,7 @@ class LLMSingleActionAgent(BaseSingleActionAgent):
|
||||
|
||||
@deprecated(
|
||||
"0.1.0",
|
||||
message=(
|
||||
"Use new agent constructor methods like create_react_agent, create_json_agent, "
|
||||
"create_structured_chat_agent, etc."
|
||||
),
|
||||
message=AGENT_DEPRECATION_WARNING,
|
||||
removal="1.0",
|
||||
)
|
||||
class Agent(BaseSingleActionAgent):
|
||||
|
@ -20,6 +20,10 @@ from langchain.chains.llm import LLMChain
|
||||
since="0.2.13",
|
||||
removal="1.0",
|
||||
message=(
|
||||
"This function will continue to be supported, but it is recommended for new "
|
||||
"use cases to be built with LangGraph. LangGraph offers a more flexible and "
|
||||
"full-featured framework for building agents, including support for "
|
||||
"tool-calling, persistence of state, and human-in-the-loop workflows. "
|
||||
"See API reference for this function for a replacement implementation: "
|
||||
"https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.vectorstore.base.create_vectorstore_agent.html " # noqa: E501
|
||||
"Read more here on how to create agents that query vector stores: "
|
||||
@ -109,6 +113,10 @@ def create_vectorstore_agent(
|
||||
since="0.2.13",
|
||||
removal="1.0",
|
||||
message=(
|
||||
"This function will continue to be supported, but it is recommended for new "
|
||||
"use cases to be built with LangGraph. LangGraph offers a more flexible and "
|
||||
"full-featured framework for building agents, including support for "
|
||||
"tool-calling, persistence of state, and human-in-the-loop workflows. "
|
||||
"See API reference for this function for a replacement implementation: "
|
||||
"https://api.python.langchain.com/en/latest/agents/langchain.agents.agent_toolkits.vectorstore.base.create_vectorstore_router_agent.html " # noqa: E501
|
||||
"Read more here on how to create agents that query vector stores: "
|
||||
|
@ -4,13 +4,12 @@ from enum import Enum
|
||||
|
||||
from langchain_core._api import deprecated
|
||||
|
||||
from langchain._api.deprecation import AGENT_DEPRECATION_WARNING
|
||||
|
||||
|
||||
@deprecated(
|
||||
"0.1.0",
|
||||
message=(
|
||||
"Use new agent constructor methods like create_react_agent, create_json_agent, "
|
||||
"create_structured_chat_agent, etc."
|
||||
),
|
||||
message=AGENT_DEPRECATION_WARNING,
|
||||
removal="1.0",
|
||||
)
|
||||
class AgentType(str, Enum):
|
||||
|
@ -13,6 +13,7 @@ from langchain_core.prompts.chat import (
|
||||
from langchain_core.tools import BaseTool
|
||||
from pydantic import Field
|
||||
|
||||
from langchain._api.deprecation import AGENT_DEPRECATION_WARNING
|
||||
from langchain.agents.agent import Agent, AgentOutputParser
|
||||
from langchain.agents.chat.output_parser import ChatOutputParser
|
||||
from langchain.agents.chat.prompt import (
|
||||
@ -25,7 +26,11 @@ from langchain.agents.utils import validate_tools_single_input
|
||||
from langchain.chains.llm import LLMChain
|
||||
|
||||
|
||||
@deprecated("0.1.0", alternative="create_react_agent", removal="1.0")
|
||||
@deprecated(
|
||||
"0.1.0",
|
||||
message=AGENT_DEPRECATION_WARNING,
|
||||
removal="1.0",
|
||||
)
|
||||
class ChatAgent(Agent):
|
||||
"""Chat Agent."""
|
||||
|
||||
|
@ -11,6 +11,7 @@ from langchain_core.prompts import PromptTemplate
|
||||
from langchain_core.tools import BaseTool
|
||||
from pydantic import Field
|
||||
|
||||
from langchain._api.deprecation import AGENT_DEPRECATION_WARNING
|
||||
from langchain.agents.agent import Agent, AgentOutputParser
|
||||
from langchain.agents.agent_types import AgentType
|
||||
from langchain.agents.conversational.output_parser import ConvoOutputParser
|
||||
@ -19,7 +20,11 @@ from langchain.agents.utils import validate_tools_single_input
|
||||
from langchain.chains import LLMChain
|
||||
|
||||
|
||||
@deprecated("0.1.0", alternative="create_react_agent", removal="1.0")
|
||||
@deprecated(
|
||||
"0.1.0",
|
||||
message=AGENT_DEPRECATION_WARNING,
|
||||
removal="1.0",
|
||||
)
|
||||
class ConversationalAgent(Agent):
|
||||
"""An agent that holds a conversation in addition to using tools."""
|
||||
|
||||
|
@ -7,6 +7,7 @@ from langchain_core.callbacks import BaseCallbackManager
|
||||
from langchain_core.language_models import BaseLanguageModel
|
||||
from langchain_core.tools import BaseTool
|
||||
|
||||
from langchain._api.deprecation import AGENT_DEPRECATION_WARNING
|
||||
from langchain.agents.agent import AgentExecutor
|
||||
from langchain.agents.agent_types import AgentType
|
||||
from langchain.agents.loading import AGENT_TO_CLASS, load_agent
|
||||
@ -14,10 +15,7 @@ from langchain.agents.loading import AGENT_TO_CLASS, load_agent
|
||||
|
||||
@deprecated(
|
||||
"0.1.0",
|
||||
alternative=(
|
||||
"Use new agent constructor methods like create_react_agent, create_json_agent, "
|
||||
"create_structured_chat_agent, etc."
|
||||
),
|
||||
message=AGENT_DEPRECATION_WARNING,
|
||||
removal="1.0",
|
||||
)
|
||||
def initialize_agent(
|
||||
|
@ -12,6 +12,7 @@ from langchain_core.tools import BaseTool, Tool
|
||||
from langchain_core.tools.render import render_text_description
|
||||
from pydantic import Field
|
||||
|
||||
from langchain._api.deprecation import AGENT_DEPRECATION_WARNING
|
||||
from langchain.agents.agent import Agent, AgentExecutor, AgentOutputParser
|
||||
from langchain.agents.agent_types import AgentType
|
||||
from langchain.agents.mrkl.output_parser import MRKLOutputParser
|
||||
@ -34,7 +35,11 @@ class ChainConfig(NamedTuple):
|
||||
action_description: str
|
||||
|
||||
|
||||
@deprecated("0.1.0", alternative="create_react_agent", removal="1.0")
|
||||
@deprecated(
|
||||
"0.1.0",
|
||||
message=AGENT_DEPRECATION_WARNING,
|
||||
removal="1.0",
|
||||
)
|
||||
class ZeroShotAgent(Agent):
|
||||
"""Agent for the MRKL chain.
|
||||
|
||||
@ -168,7 +173,11 @@ class ZeroShotAgent(Agent):
|
||||
super()._validate_tools(tools)
|
||||
|
||||
|
||||
@deprecated("0.1.0", removal="1.0")
|
||||
@deprecated(
|
||||
"0.1.0",
|
||||
message=AGENT_DEPRECATION_WARNING,
|
||||
removal="1.0",
|
||||
)
|
||||
class MRKLChain(AgentExecutor):
|
||||
"""Chain that implements the MRKL system."""
|
||||
|
||||
|
@ -11,6 +11,7 @@ from langchain_core.prompts import BasePromptTemplate
|
||||
from langchain_core.tools import BaseTool, Tool
|
||||
from pydantic import Field
|
||||
|
||||
from langchain._api.deprecation import AGENT_DEPRECATION_WARNING
|
||||
from langchain.agents.agent import Agent, AgentExecutor, AgentOutputParser
|
||||
from langchain.agents.agent_types import AgentType
|
||||
from langchain.agents.react.output_parser import ReActOutputParser
|
||||
@ -22,7 +23,11 @@ if TYPE_CHECKING:
|
||||
from langchain_community.docstore.base import Docstore
|
||||
|
||||
|
||||
@deprecated("0.1.0", removal="1.0")
|
||||
@deprecated(
|
||||
"0.1.0",
|
||||
message=AGENT_DEPRECATION_WARNING,
|
||||
removal="1.0",
|
||||
)
|
||||
class ReActDocstoreAgent(Agent):
|
||||
"""Agent for the ReAct chain."""
|
||||
|
||||
@ -69,7 +74,11 @@ class ReActDocstoreAgent(Agent):
|
||||
return "Thought:"
|
||||
|
||||
|
||||
@deprecated("0.1.0", removal="1.0")
|
||||
@deprecated(
|
||||
"0.1.0",
|
||||
message=AGENT_DEPRECATION_WARNING,
|
||||
removal="1.0",
|
||||
)
|
||||
class DocstoreExplorer:
|
||||
"""Class to assist with exploration of a document store."""
|
||||
|
||||
@ -119,7 +128,11 @@ class DocstoreExplorer:
|
||||
return self.document.page_content.split("\n\n")
|
||||
|
||||
|
||||
@deprecated("0.1.0", removal="1.0")
|
||||
@deprecated(
|
||||
"0.1.0",
|
||||
message=AGENT_DEPRECATION_WARNING,
|
||||
removal="1.0",
|
||||
)
|
||||
class ReActTextWorldAgent(ReActDocstoreAgent):
|
||||
"""Agent for the ReAct TextWorld chain."""
|
||||
|
||||
@ -139,7 +152,11 @@ class ReActTextWorldAgent(ReActDocstoreAgent):
|
||||
raise ValueError(f"Tool name should be Play, got {tool_names}")
|
||||
|
||||
|
||||
@deprecated("0.1.0", removal="1.0")
|
||||
@deprecated(
|
||||
"0.1.0",
|
||||
message=AGENT_DEPRECATION_WARNING,
|
||||
removal="1.0",
|
||||
)
|
||||
class ReActChain(AgentExecutor):
|
||||
"""[Deprecated] Chain that implements the ReAct paper."""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user