Home / File/ test_initialize.py — langchain Source File

test_initialize.py — langchain Source File

Architecture documentation for test_initialize.py, a python file in the langchain codebase. 4 imports, 0 dependents.

File python LangChainCore ApiManagement 4 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  210a85aa_3fd0_17d6_9968_adbb6498e194["test_initialize.py"]
  121262a1_0bd6_d637_bce3_307ab6b3ecd4["langchain_core.tools"]
  210a85aa_3fd0_17d6_9968_adbb6498e194 --> 121262a1_0bd6_d637_bce3_307ab6b3ecd4
  a6130799_fe22_58f5_4f6a_97737e38ea44["langchain_classic.agents.agent_types"]
  210a85aa_3fd0_17d6_9968_adbb6498e194 --> a6130799_fe22_58f5_4f6a_97737e38ea44
  819c1b89_0976_15a9_2a81_82b77b6f6cba["langchain_classic.agents.initialize"]
  210a85aa_3fd0_17d6_9968_adbb6498e194 --> 819c1b89_0976_15a9_2a81_82b77b6f6cba
  55289260_666e_fae6_ddf7_d3d78be29813["tests.unit_tests.llms.fake_llm"]
  210a85aa_3fd0_17d6_9968_adbb6498e194 --> 55289260_666e_fae6_ddf7_d3d78be29813
  style 210a85aa_3fd0_17d6_9968_adbb6498e194 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Test the initialize module."""

from langchain_core.tools import tool

from langchain_classic.agents.agent_types import AgentType
from langchain_classic.agents.initialize import initialize_agent
from tests.unit_tests.llms.fake_llm import FakeLLM


@tool
def my_tool(query: str) -> str:  # noqa: ARG001
    """A fake tool."""
    return "fake tool"


def test_initialize_agent_with_str_agent_type() -> None:
    """Test initialize_agent with a string."""
    fake_llm = FakeLLM()
    agent_executor = initialize_agent(
        [my_tool],
        fake_llm,
        "zero-shot-react-description",  # type: ignore[arg-type]
    )
    assert (
        agent_executor._action_agent._agent_type
        == AgentType.ZERO_SHOT_REACT_DESCRIPTION
    )
    assert isinstance(agent_executor.tags, list)
    assert "zero-shot-react-description" in agent_executor.tags

Domain

Subdomains

Dependencies

  • langchain_classic.agents.agent_types
  • langchain_classic.agents.initialize
  • langchain_core.tools
  • tests.unit_tests.llms.fake_llm

Frequently Asked Questions

What does test_initialize.py do?
test_initialize.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, ApiManagement subdomain.
What functions are defined in test_initialize.py?
test_initialize.py defines 2 function(s): my_tool, test_initialize_agent_with_str_agent_type.
What does test_initialize.py depend on?
test_initialize.py imports 4 module(s): langchain_classic.agents.agent_types, langchain_classic.agents.initialize, langchain_core.tools, tests.unit_tests.llms.fake_llm.
Where is test_initialize.py in the architecture?
test_initialize.py is located at libs/langchain/tests/unit_tests/agents/test_initialize.py (domain: LangChainCore, subdomain: ApiManagement, directory: libs/langchain/tests/unit_tests/agents).

Analyze Your Own Codebase

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

Try Supermodel Free