mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-30 18:33:40 +00:00
langchain[patch]: deprecate old agent classes and methods (#15558)
This commit is contained in:
parent
9b9449750c
commit
68eb3053e7
@ -21,6 +21,7 @@ from typing import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
from langchain_core._api import deprecated
|
||||||
from langchain_core.agents import AgentAction, AgentFinish, AgentStep
|
from langchain_core.agents import AgentAction, AgentFinish, AgentStep
|
||||||
from langchain_core.exceptions import OutputParserException
|
from langchain_core.exceptions import OutputParserException
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
@ -486,6 +487,14 @@ class RunnableMultiActionAgent(BaseMultiActionAgent):
|
|||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated(
|
||||||
|
"0.1.0",
|
||||||
|
alternative=(
|
||||||
|
"Use new agent constructor methods like create_react_agent, create_json_agent, "
|
||||||
|
"create_structured_chat_agent, etc."
|
||||||
|
),
|
||||||
|
removal="0.2.0",
|
||||||
|
)
|
||||||
class LLMSingleActionAgent(BaseSingleActionAgent):
|
class LLMSingleActionAgent(BaseSingleActionAgent):
|
||||||
"""Base class for single action agents."""
|
"""Base class for single action agents."""
|
||||||
|
|
||||||
@ -568,6 +577,14 @@ class LLMSingleActionAgent(BaseSingleActionAgent):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated(
|
||||||
|
"0.1.0",
|
||||||
|
alternative=(
|
||||||
|
"Use new agent constructor methods like create_react_agent, create_json_agent, "
|
||||||
|
"create_structured_chat_agent, etc."
|
||||||
|
),
|
||||||
|
removal="0.2.0",
|
||||||
|
)
|
||||||
class Agent(BaseSingleActionAgent):
|
class Agent(BaseSingleActionAgent):
|
||||||
"""Agent that calls the language model and deciding the action.
|
"""Agent that calls the language model and deciding the action.
|
||||||
|
|
||||||
|
@ -1,7 +1,17 @@
|
|||||||
"""Module definitions of agent types together with corresponding agents."""
|
"""Module definitions of agent types together with corresponding agents."""
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
|
from langchain_core._api import deprecated
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated(
|
||||||
|
"0.1.0",
|
||||||
|
alternative=(
|
||||||
|
"Use new agent constructor methods like create_react_agent, create_json_agent, "
|
||||||
|
"create_structured_chat_agent, etc."
|
||||||
|
),
|
||||||
|
removal="0.2.0",
|
||||||
|
)
|
||||||
class AgentType(str, Enum):
|
class AgentType(str, Enum):
|
||||||
"""An enum for agent types.
|
"""An enum for agent types.
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from typing import Any, List, Optional, Sequence, Tuple
|
from typing import Any, List, Optional, Sequence, Tuple
|
||||||
|
|
||||||
|
from langchain_core._api import deprecated
|
||||||
from langchain_core.agents import AgentAction
|
from langchain_core.agents import AgentAction
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
from langchain_core.prompts import BasePromptTemplate
|
from langchain_core.prompts import BasePromptTemplate
|
||||||
@ -24,6 +25,7 @@ from langchain.callbacks.base import BaseCallbackManager
|
|||||||
from langchain.chains.llm import LLMChain
|
from langchain.chains.llm import LLMChain
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("0.1.0", alternative="create_react_agent", removal="0.2.0")
|
||||||
class ChatAgent(Agent):
|
class ChatAgent(Agent):
|
||||||
"""Chat Agent."""
|
"""Chat Agent."""
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any, List, Optional, Sequence
|
from typing import Any, List, Optional, Sequence
|
||||||
|
|
||||||
|
from langchain_core._api import deprecated
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
from langchain_core.prompts import PromptTemplate
|
from langchain_core.prompts import PromptTemplate
|
||||||
from langchain_core.pydantic_v1 import Field
|
from langchain_core.pydantic_v1 import Field
|
||||||
@ -17,6 +18,7 @@ from langchain.callbacks.base import BaseCallbackManager
|
|||||||
from langchain.chains import LLMChain
|
from langchain.chains import LLMChain
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("0.1.0", alternative="create_react_agent", removal="0.2.0")
|
||||||
class ConversationalAgent(Agent):
|
class ConversationalAgent(Agent):
|
||||||
"""An agent that holds a conversation in addition to using tools."""
|
"""An agent that holds a conversation in addition to using tools."""
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any, List, Optional, Sequence, Tuple
|
from typing import Any, List, Optional, Sequence, Tuple
|
||||||
|
|
||||||
|
from langchain_core._api import deprecated
|
||||||
from langchain_core.agents import AgentAction
|
from langchain_core.agents import AgentAction
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage
|
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage
|
||||||
@ -29,6 +30,7 @@ from langchain.callbacks.base import BaseCallbackManager
|
|||||||
from langchain.chains import LLMChain
|
from langchain.chains import LLMChain
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("0.1.0", alternative="create_json_chat_agent", removal="0.2.0")
|
||||||
class ConversationalChatAgent(Agent):
|
class ConversationalChatAgent(Agent):
|
||||||
"""An agent designed to hold a conversation in addition to using tools."""
|
"""An agent designed to hold a conversation in addition to using tools."""
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"""Load agent."""
|
"""Load agent."""
|
||||||
from typing import Any, Optional, Sequence
|
from typing import Any, Optional, Sequence
|
||||||
|
|
||||||
|
from langchain_core._api import deprecated
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
from langchain_core.tools import BaseTool
|
from langchain_core.tools import BaseTool
|
||||||
|
|
||||||
@ -10,6 +11,14 @@ from langchain.agents.loading import AGENT_TO_CLASS, load_agent
|
|||||||
from langchain.callbacks.base import BaseCallbackManager
|
from langchain.callbacks.base import BaseCallbackManager
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated(
|
||||||
|
"0.1.0",
|
||||||
|
alternative=(
|
||||||
|
"Use new agent constructor methods like create_react_agent, create_json_agent, "
|
||||||
|
"create_structured_chat_agent, etc."
|
||||||
|
),
|
||||||
|
removal="0.2.0",
|
||||||
|
)
|
||||||
def initialize_agent(
|
def initialize_agent(
|
||||||
tools: Sequence[BaseTool],
|
tools: Sequence[BaseTool],
|
||||||
llm: BaseLanguageModel,
|
llm: BaseLanguageModel,
|
||||||
|
@ -5,6 +5,7 @@ from pathlib import Path
|
|||||||
from typing import Any, List, Optional, Union
|
from typing import Any, List, Optional, Union
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
from langchain_core._api import deprecated
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
from langchain_core.utils.loading import try_load_from_hub
|
from langchain_core.utils.loading import try_load_from_hub
|
||||||
|
|
||||||
@ -30,6 +31,7 @@ def _load_agent_from_tools(
|
|||||||
return agent_cls.from_llm_and_tools(llm, tools, **combined_config)
|
return agent_cls.from_llm_and_tools(llm, tools, **combined_config)
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("0.1.0", removal="0.2.0")
|
||||||
def load_agent_from_config(
|
def load_agent_from_config(
|
||||||
config: dict,
|
config: dict,
|
||||||
llm: Optional[BaseLanguageModel] = None,
|
llm: Optional[BaseLanguageModel] = None,
|
||||||
@ -85,6 +87,7 @@ def load_agent_from_config(
|
|||||||
return agent_cls(**combined_config) # type: ignore
|
return agent_cls(**combined_config) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("0.1.0", removal="0.2.0")
|
||||||
def load_agent(
|
def load_agent(
|
||||||
path: Union[str, Path], **kwargs: Any
|
path: Union[str, Path], **kwargs: Any
|
||||||
) -> Union[BaseSingleActionAgent, BaseMultiActionAgent]:
|
) -> Union[BaseSingleActionAgent, BaseMultiActionAgent]:
|
||||||
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any, Callable, List, NamedTuple, Optional, Sequence
|
from typing import Any, Callable, List, NamedTuple, Optional, Sequence
|
||||||
|
|
||||||
|
from langchain_core._api import deprecated
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
from langchain_core.prompts import PromptTemplate
|
from langchain_core.prompts import PromptTemplate
|
||||||
from langchain_core.pydantic_v1 import Field
|
from langchain_core.pydantic_v1 import Field
|
||||||
@ -32,6 +33,7 @@ class ChainConfig(NamedTuple):
|
|||||||
action_description: str
|
action_description: str
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("0.1.0", alternative="create_react_agent", removal="0.2.0")
|
||||||
class ZeroShotAgent(Agent):
|
class ZeroShotAgent(Agent):
|
||||||
"""Agent for the MRKL chain."""
|
"""Agent for the MRKL chain."""
|
||||||
|
|
||||||
@ -137,6 +139,7 @@ class ZeroShotAgent(Agent):
|
|||||||
super()._validate_tools(tools)
|
super()._validate_tools(tools)
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("0.1.0", removal="0.2.0")
|
||||||
class MRKLChain(AgentExecutor):
|
class MRKLChain(AgentExecutor):
|
||||||
"""[Deprecated] Chain that implements the MRKL system."""
|
"""[Deprecated] Chain that implements the MRKL system."""
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
from typing import Any, List, Optional, Sequence, Tuple, Union
|
from typing import Any, List, Optional, Sequence, Tuple, Union
|
||||||
|
|
||||||
from langchain_community.tools.convert_to_openai import format_tool_to_openai_function
|
from langchain_community.tools.convert_to_openai import format_tool_to_openai_function
|
||||||
|
from langchain_core._api import deprecated
|
||||||
from langchain_core.agents import AgentAction, AgentFinish
|
from langchain_core.agents import AgentAction, AgentFinish
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
from langchain_core.messages import (
|
from langchain_core.messages import (
|
||||||
@ -30,6 +31,7 @@ from langchain.callbacks.base import BaseCallbackManager
|
|||||||
from langchain.callbacks.manager import Callbacks
|
from langchain.callbacks.manager import Callbacks
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("0.1.0", alternative="create_openai_functions_agent", removal="0.2.0")
|
||||||
class OpenAIFunctionsAgent(BaseSingleActionAgent):
|
class OpenAIFunctionsAgent(BaseSingleActionAgent):
|
||||||
"""An Agent driven by OpenAIs function powered API.
|
"""An Agent driven by OpenAIs function powered API.
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import json
|
|||||||
from json import JSONDecodeError
|
from json import JSONDecodeError
|
||||||
from typing import Any, List, Optional, Sequence, Tuple, Union
|
from typing import Any, List, Optional, Sequence, Tuple, Union
|
||||||
|
|
||||||
|
from langchain_core._api import deprecated
|
||||||
from langchain_core.agents import AgentAction, AgentActionMessageLog, AgentFinish
|
from langchain_core.agents import AgentAction, AgentActionMessageLog, AgentFinish
|
||||||
from langchain_core.exceptions import OutputParserException
|
from langchain_core.exceptions import OutputParserException
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
@ -93,6 +94,7 @@ def _parse_ai_message(message: BaseMessage) -> Union[List[AgentAction], AgentFin
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("0.1.0", alternative="create_openai_tools_agent", removal="0.2.0")
|
||||||
class OpenAIMultiFunctionsAgent(BaseMultiActionAgent):
|
class OpenAIMultiFunctionsAgent(BaseMultiActionAgent):
|
||||||
"""An Agent driven by OpenAIs function powered API.
|
"""An Agent driven by OpenAIs function powered API.
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"""Chain that implements the ReAct paper from https://arxiv.org/pdf/2210.03629.pdf."""
|
"""Chain that implements the ReAct paper from https://arxiv.org/pdf/2210.03629.pdf."""
|
||||||
from typing import Any, List, Optional, Sequence
|
from typing import Any, List, Optional, Sequence
|
||||||
|
|
||||||
|
from langchain_core._api import deprecated
|
||||||
from langchain_core.documents import Document
|
from langchain_core.documents import Document
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
from langchain_core.prompts import BasePromptTemplate
|
from langchain_core.prompts import BasePromptTemplate
|
||||||
@ -17,6 +18,7 @@ from langchain.agents.utils import validate_tools_single_input
|
|||||||
from langchain.docstore.base import Docstore
|
from langchain.docstore.base import Docstore
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("0.1.0", removal="0.2.0")
|
||||||
class ReActDocstoreAgent(Agent):
|
class ReActDocstoreAgent(Agent):
|
||||||
"""Agent for the ReAct chain."""
|
"""Agent for the ReAct chain."""
|
||||||
|
|
||||||
@ -63,6 +65,7 @@ class ReActDocstoreAgent(Agent):
|
|||||||
return "Thought:"
|
return "Thought:"
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("0.1.0", removal="0.2.0")
|
||||||
class DocstoreExplorer:
|
class DocstoreExplorer:
|
||||||
"""Class to assist with exploration of a document store."""
|
"""Class to assist with exploration of a document store."""
|
||||||
|
|
||||||
@ -112,6 +115,7 @@ class DocstoreExplorer:
|
|||||||
return self.document.page_content.split("\n\n")
|
return self.document.page_content.split("\n\n")
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("0.1.0", removal="0.2.0")
|
||||||
class ReActTextWorldAgent(ReActDocstoreAgent):
|
class ReActTextWorldAgent(ReActDocstoreAgent):
|
||||||
"""Agent for the ReAct TextWorld chain."""
|
"""Agent for the ReAct TextWorld chain."""
|
||||||
|
|
||||||
@ -131,6 +135,7 @@ class ReActTextWorldAgent(ReActDocstoreAgent):
|
|||||||
raise ValueError(f"Tool name should be Play, got {tool_names}")
|
raise ValueError(f"Tool name should be Play, got {tool_names}")
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("0.1.0", removal="0.2.0")
|
||||||
class ReActChain(AgentExecutor):
|
class ReActChain(AgentExecutor):
|
||||||
"""[Deprecated] Chain that implements the ReAct paper."""
|
"""[Deprecated] Chain that implements the ReAct paper."""
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ from typing import Any, Sequence, Union
|
|||||||
from langchain_community.utilities.google_serper import GoogleSerperAPIWrapper
|
from langchain_community.utilities.google_serper import GoogleSerperAPIWrapper
|
||||||
from langchain_community.utilities.searchapi import SearchApiAPIWrapper
|
from langchain_community.utilities.searchapi import SearchApiAPIWrapper
|
||||||
from langchain_community.utilities.serpapi import SerpAPIWrapper
|
from langchain_community.utilities.serpapi import SerpAPIWrapper
|
||||||
|
from langchain_core._api import deprecated
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
from langchain_core.prompts import BasePromptTemplate
|
from langchain_core.prompts import BasePromptTemplate
|
||||||
from langchain_core.pydantic_v1 import Field
|
from langchain_core.pydantic_v1 import Field
|
||||||
@ -19,6 +20,7 @@ from langchain.agents.tools import Tool
|
|||||||
from langchain.agents.utils import validate_tools_single_input
|
from langchain.agents.utils import validate_tools_single_input
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("0.1.0", alternative="create_self_ask_with_search", removal="0.2.0")
|
||||||
class SelfAskWithSearchAgent(Agent):
|
class SelfAskWithSearchAgent(Agent):
|
||||||
"""Agent for the self-ask-with-search paper."""
|
"""Agent for the self-ask-with-search paper."""
|
||||||
|
|
||||||
@ -61,6 +63,7 @@ class SelfAskWithSearchAgent(Agent):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("0.1.0", removal="0.2.0")
|
||||||
class SelfAskWithSearchChain(AgentExecutor):
|
class SelfAskWithSearchChain(AgentExecutor):
|
||||||
"""[Deprecated] Chain that does self-ask with search."""
|
"""[Deprecated] Chain that does self-ask with search."""
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import re
|
import re
|
||||||
from typing import Any, List, Optional, Sequence, Tuple
|
from typing import Any, List, Optional, Sequence, Tuple
|
||||||
|
|
||||||
|
from langchain_core._api import deprecated
|
||||||
from langchain_core.agents import AgentAction
|
from langchain_core.agents import AgentAction
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
from langchain_core.prompts import BasePromptTemplate
|
from langchain_core.prompts import BasePromptTemplate
|
||||||
@ -27,6 +28,7 @@ from langchain.tools.render import render_text_description_and_args
|
|||||||
HUMAN_MESSAGE_TEMPLATE = "{input}\n\n{agent_scratchpad}"
|
HUMAN_MESSAGE_TEMPLATE = "{input}\n\n{agent_scratchpad}"
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("0.1.0", alternative="create_structured_chat_agent", removal="0.2.0")
|
||||||
class StructuredChatAgent(Agent):
|
class StructuredChatAgent(Agent):
|
||||||
"""Structured Chat Agent."""
|
"""Structured Chat Agent."""
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from typing import Any, List, Sequence, Tuple, Union
|
from typing import Any, List, Sequence, Tuple, Union
|
||||||
|
|
||||||
|
from langchain_core._api import deprecated
|
||||||
from langchain_core.agents import AgentAction, AgentFinish
|
from langchain_core.agents import AgentAction, AgentFinish
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
from langchain_core.prompts.base import BasePromptTemplate
|
from langchain_core.prompts.base import BasePromptTemplate
|
||||||
@ -16,6 +17,7 @@ from langchain.chains.llm import LLMChain
|
|||||||
from langchain.tools.render import render_text_description
|
from langchain.tools.render import render_text_description
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("0.1.0", alternative="create_xml_agent", removal="0.2.0")
|
||||||
class XMLAgent(BaseSingleActionAgent):
|
class XMLAgent(BaseSingleActionAgent):
|
||||||
"""Agent that uses XML tags.
|
"""Agent that uses XML tags.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user