test_basic_tool.py — langchain Source File
Architecture documentation for test_basic_tool.py, a python file in the langchain codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR bbe2cb79_700d_8403_c0bc_b4483611554a["test_basic_tool.py"] 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] bbe2cb79_700d_8403_c0bc_b4483611554a --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 43d88577_548b_2248_b01b_7987bae85dcc["langchain_core.tools"] bbe2cb79_700d_8403_c0bc_b4483611554a --> 43d88577_548b_2248_b01b_7987bae85dcc 91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"] bbe2cb79_700d_8403_c0bc_b4483611554a --> 91721f45_4909_e489_8c1f_084f8bd87145 8f882798_3f47_fa1f_5253_3b7193f357a9["langchain_tests.integration_tests"] bbe2cb79_700d_8403_c0bc_b4483611554a --> 8f882798_3f47_fa1f_5253_3b7193f357a9 bab3058f_1ec6_5a8a_2b11_86f46e62adb4["langchain_tests.unit_tests"] bbe2cb79_700d_8403_c0bc_b4483611554a --> bab3058f_1ec6_5a8a_2b11_86f46e62adb4 style bbe2cb79_700d_8403_c0bc_b4483611554a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from typing import Any, Literal
from langchain_core.tools import BaseTool
from typing_extensions import override
from langchain_tests.integration_tests import ToolsIntegrationTests
from langchain_tests.unit_tests import ToolsUnitTests
class ParrotMultiplyTool(BaseTool):
name: str = "ParrotMultiplyTool"
description: str = (
"Multiply two numbers like a parrot. Parrots always add eighty for their matey."
)
@override
def _run(self, a: int, b: int) -> int:
return a * b + 80
class ParrotMultiplyArtifactTool(BaseTool):
name: str = "ParrotMultiplyArtifactTool"
description: str = (
"Multiply two numbers like a parrot. Parrots always add eighty for their matey."
)
response_format: Literal["content_and_artifact"] = "content_and_artifact"
@override
def _run(self, a: int, b: int) -> tuple[int, str]:
return a * b + 80, "parrot artifact"
class TestParrotMultiplyToolUnit(ToolsUnitTests):
@property
def tool_constructor(self) -> type[ParrotMultiplyTool]:
return ParrotMultiplyTool
@property
def tool_constructor_params(self) -> dict[str, Any]:
# if your tool constructor instead required initialization arguments like
# `def __init__(self, some_arg: int):`, you would return those here
# as a dictionary, e.g.: `return {'some_arg': 42}`
return {}
@property
def tool_invoke_params_example(self) -> dict[str, Any]:
"""Returns a dictionary representing the "args" of an example tool call.
This should NOT be a ToolCall dict - i.e. it should not
have {"name", "id", "args"} keys.
"""
return {"a": 2, "b": 3}
class TestParrotMultiplyToolIntegration(ToolsIntegrationTests):
@property
def tool_constructor(self) -> type[ParrotMultiplyTool]:
return ParrotMultiplyTool
@property
def tool_constructor_params(self) -> dict[str, Any]:
# if your tool constructor instead required initialization arguments like
# `def __init__(self, some_arg: int):`, you would return those here
# as a dictionary, e.g.: `return {'some_arg': 42}`
return {}
@property
def tool_invoke_params_example(self) -> dict[str, Any]:
"""Returns a dictionary representing the "args" of an example tool call.
This should NOT be a ToolCall dict - i.e. it should not
have {"name", "id", "args"} keys.
"""
return {"a": 2, "b": 3}
class TestParrotMultiplyArtifactToolIntegration(ToolsIntegrationTests):
@property
def tool_constructor(self) -> type[ParrotMultiplyArtifactTool]:
return ParrotMultiplyArtifactTool
@property
def tool_constructor_params(self) -> dict[str, Any]:
# if your tool constructor instead required initialization arguments like
# `def __init__(self, some_arg: int):`, you would return those here
# as a dictionary, e.g.: `return {'some_arg': 42}`
return {}
@property
def tool_invoke_params_example(self) -> dict[str, Any]:
"""Returns a dictionary representing the "args" of an example tool call.
This should NOT be a ToolCall dict - i.e. it should not
have {"name", "id", "args"} keys.
"""
return {"a": 2, "b": 3}
Domain
Subdomains
Classes
Dependencies
- langchain_core.tools
- langchain_tests.integration_tests
- langchain_tests.unit_tests
- typing
- typing_extensions
Source
Frequently Asked Questions
What does test_basic_tool.py do?
test_basic_tool.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, Serialization subdomain.
What does test_basic_tool.py depend on?
test_basic_tool.py imports 5 module(s): langchain_core.tools, langchain_tests.integration_tests, langchain_tests.unit_tests, typing, typing_extensions.
Where is test_basic_tool.py in the architecture?
test_basic_tool.py is located at libs/standard-tests/tests/unit_tests/test_basic_tool.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/standard-tests/tests/unit_tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free