ReActDocstoreAgent Class — langchain Architecture
Architecture documentation for the ReActDocstoreAgent class in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD d5d43d15_73de_819f_ef9d_0df3b0f5c681["ReActDocstoreAgent"] 37fcc3f3_2798_3648_915c_2bffdd19bff7["Agent"] d5d43d15_73de_819f_ef9d_0df3b0f5c681 -->|extends| 37fcc3f3_2798_3648_915c_2bffdd19bff7 9ccefa56_209b_c990_304c_d902563c789e["base.py"] d5d43d15_73de_819f_ef9d_0df3b0f5c681 -->|defined in| 9ccefa56_209b_c990_304c_d902563c789e 76a53ac5_8e7b_5311_c897_6551bbf7b7d7["_get_default_output_parser()"] d5d43d15_73de_819f_ef9d_0df3b0f5c681 -->|method| 76a53ac5_8e7b_5311_c897_6551bbf7b7d7 f2f35f90_85c2_6aa3_a5d5_1b83cf982518["_agent_type()"] d5d43d15_73de_819f_ef9d_0df3b0f5c681 -->|method| f2f35f90_85c2_6aa3_a5d5_1b83cf982518 33fe9ce0_badd_939d_8d17_5c349b8ab475["create_prompt()"] d5d43d15_73de_819f_ef9d_0df3b0f5c681 -->|method| 33fe9ce0_badd_939d_8d17_5c349b8ab475 aa43b201_85d4_3e68_b77d_271aa3784786["_validate_tools()"] d5d43d15_73de_819f_ef9d_0df3b0f5c681 -->|method| aa43b201_85d4_3e68_b77d_271aa3784786 f5ae6c6b_e117_5e79_6e8d_8324edfe23cd["observation_prefix()"] d5d43d15_73de_819f_ef9d_0df3b0f5c681 -->|method| f5ae6c6b_e117_5e79_6e8d_8324edfe23cd bd116a34_9f35_4b26_7674_80231427e778["_stop()"] d5d43d15_73de_819f_ef9d_0df3b0f5c681 -->|method| bd116a34_9f35_4b26_7674_80231427e778 9a838d98_e7ad_862c_674b_b579b051aabe["llm_prefix()"] d5d43d15_73de_819f_ef9d_0df3b0f5c681 -->|method| 9a838d98_e7ad_862c_674b_b579b051aabe
Relationship Graph
Source Code
libs/langchain/langchain_classic/agents/react/base.py lines 36–81
class ReActDocstoreAgent(Agent):
"""Agent for the ReAct chain."""
output_parser: AgentOutputParser = Field(default_factory=ReActOutputParser)
@classmethod
@override
def _get_default_output_parser(cls, **kwargs: Any) -> AgentOutputParser:
return ReActOutputParser()
@property
def _agent_type(self) -> str:
"""Return Identifier of an agent type."""
return AgentType.REACT_DOCSTORE
@classmethod
@override
def create_prompt(cls, tools: Sequence[BaseTool]) -> BasePromptTemplate:
"""Return default prompt."""
return WIKI_PROMPT
@classmethod
def _validate_tools(cls, tools: Sequence[BaseTool]) -> None:
validate_tools_single_input(cls.__name__, tools)
super()._validate_tools(tools)
if len(tools) != len(_LOOKUP_AND_SEARCH_TOOLS):
msg = f"Exactly two tools must be specified, but got {tools}"
raise ValueError(msg)
tool_names = {tool.name for tool in tools}
if tool_names != _LOOKUP_AND_SEARCH_TOOLS:
msg = f"Tool names should be Lookup and Search, got {tool_names}"
raise ValueError(msg)
@property
def observation_prefix(self) -> str:
"""Prefix to append the observation with."""
return "Observation: "
@property
def _stop(self) -> list[str]:
return ["\nObservation:"]
@property
def llm_prefix(self) -> str:
"""Prefix to append the LLM call with."""
return "Thought:"
Extends
Source
Frequently Asked Questions
What is the ReActDocstoreAgent class?
ReActDocstoreAgent is a class in the langchain codebase, defined in libs/langchain/langchain_classic/agents/react/base.py.
Where is ReActDocstoreAgent defined?
ReActDocstoreAgent is defined in libs/langchain/langchain_classic/agents/react/base.py at line 36.
What does ReActDocstoreAgent extend?
ReActDocstoreAgent extends Agent.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free