Home / Class/ ReActTextWorldAgent Class — langchain Architecture

ReActTextWorldAgent Class — langchain Architecture

Architecture documentation for the ReActTextWorldAgent class in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  2d166c20_d149_321c_980b_160d189505a7["ReActTextWorldAgent"]
  1cf99388_e912_1afe_4370_b5eb6aef0535["ReActDocstoreAgent"]
  2d166c20_d149_321c_980b_160d189505a7 -->|extends| 1cf99388_e912_1afe_4370_b5eb6aef0535
  ad80ef00_f3ce_f433_8c88_7c6f97a4bc56["base.py"]
  2d166c20_d149_321c_980b_160d189505a7 -->|defined in| ad80ef00_f3ce_f433_8c88_7c6f97a4bc56
  2c5336da_81b4_d5b0_c102_4ada7c14fe08["create_prompt()"]
  2d166c20_d149_321c_980b_160d189505a7 -->|method| 2c5336da_81b4_d5b0_c102_4ada7c14fe08
  db3bfef1_e457_395a_3bef_a1f5fcfce110["_validate_tools()"]
  2d166c20_d149_321c_980b_160d189505a7 -->|method| db3bfef1_e457_395a_3bef_a1f5fcfce110

Relationship Graph

Source Code

libs/langchain/langchain_classic/agents/react/base.py lines 143–162

class ReActTextWorldAgent(ReActDocstoreAgent):
    """Agent for the ReAct TextWorld chain."""

    @classmethod
    @override
    def create_prompt(cls, tools: Sequence[BaseTool]) -> BasePromptTemplate:
        """Return default prompt."""
        return TEXTWORLD_PROMPT

    @classmethod
    def _validate_tools(cls, tools: Sequence[BaseTool]) -> None:
        validate_tools_single_input(cls.__name__, tools)
        super()._validate_tools(tools)
        if len(tools) != 1:
            msg = f"Exactly one tool must be specified, but got {tools}"
            raise ValueError(msg)
        tool_names = {tool.name for tool in tools}
        if tool_names != {"Play"}:
            msg = f"Tool name should be Play, got {tool_names}"
            raise ValueError(msg)

Frequently Asked Questions

What is the ReActTextWorldAgent class?
ReActTextWorldAgent is a class in the langchain codebase, defined in libs/langchain/langchain_classic/agents/react/base.py.
Where is ReActTextWorldAgent defined?
ReActTextWorldAgent is defined in libs/langchain/langchain_classic/agents/react/base.py at line 143.
What does ReActTextWorldAgent extend?
ReActTextWorldAgent extends ReActDocstoreAgent.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free