tools.py — langchain Source File
Architecture documentation for tools.py, a python file in the langchain codebase. 8 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 1309cdfa_5ae7_0c40_108d_2e1dc971e263["tools.py"] 0029f612_c503_ebcf_a452_a0fae8c9f2c3["os"] 1309cdfa_5ae7_0c40_108d_2e1dc971e263 --> 0029f612_c503_ebcf_a452_a0fae8c9f2c3 50e20440_a135_6be3_a5a5_67791be5a2a6["abc"] 1309cdfa_5ae7_0c40_108d_2e1dc971e263 --> 50e20440_a135_6be3_a5a5_67791be5a2a6 feec1ec4_6917_867b_d228_b134d0ff8099["typing"] 1309cdfa_5ae7_0c40_108d_2e1dc971e263 --> feec1ec4_6917_867b_d228_b134d0ff8099 0b0de9e1_5259_4f11_33ed_8e5834038690["unittest"] 1309cdfa_5ae7_0c40_108d_2e1dc971e263 --> 0b0de9e1_5259_4f11_33ed_8e5834038690 f69d6389_263d_68a4_7fbf_f14c0602a9ba["pytest"] 1309cdfa_5ae7_0c40_108d_2e1dc971e263 --> f69d6389_263d_68a4_7fbf_f14c0602a9ba 121262a1_0bd6_d637_bce3_307ab6b3ecd4["langchain_core.tools"] 1309cdfa_5ae7_0c40_108d_2e1dc971e263 --> 121262a1_0bd6_d637_bce3_307ab6b3ecd4 dd5e7909_a646_84f1_497b_cae69735550e["pydantic"] 1309cdfa_5ae7_0c40_108d_2e1dc971e263 --> dd5e7909_a646_84f1_497b_cae69735550e 6acb5c26_ca82_2e59_7635_f6897caf5d55["langchain_tests.base"] 1309cdfa_5ae7_0c40_108d_2e1dc971e263 --> 6acb5c26_ca82_2e59_7635_f6897caf5d55 style 1309cdfa_5ae7_0c40_108d_2e1dc971e263 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Tools unit tests."""
from __future__ import annotations
import os
from abc import abstractmethod
from typing import Any
from unittest import mock
import pytest
from langchain_core.tools import BaseTool
from pydantic import SecretStr
from langchain_tests.base import BaseStandardTests
class ToolsTests(BaseStandardTests):
"""Base class for testing tools.
This won't show in the documentation, but the docstrings will be inherited by
subclasses.
"""
@property
@abstractmethod
def tool_constructor(self) -> type[BaseTool] | BaseTool:
"""Returns a class or instance of a tool to be tested."""
...
@property
def tool_constructor_params(self) -> dict[str, Any]:
"""Returns a dictionary of parameters to pass to the tool constructor."""
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 - it should not have
`{"name", "id", "args"}` keys.
"""
return {}
@pytest.fixture
def tool(self) -> BaseTool:
"""Tool fixture."""
if isinstance(self.tool_constructor, BaseTool):
if self.tool_constructor_params != {}:
msg = (
"If tool_constructor is an instance of BaseTool, "
"tool_constructor_params must be empty"
)
raise ValueError(msg)
return self.tool_constructor
return self.tool_constructor(**self.tool_constructor_params)
class ToolsUnitTests(ToolsTests):
"""Base class for tools unit tests."""
// ... (66 more lines)
Domain
Subdomains
Classes
Dependencies
- abc
- langchain_core.tools
- langchain_tests.base
- os
- pydantic
- pytest
- typing
- unittest
Source
Frequently Asked Questions
What does tools.py do?
tools.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, Runnables subdomain.
What does tools.py depend on?
tools.py imports 8 module(s): abc, langchain_core.tools, langchain_tests.base, os, pydantic, pytest, typing, unittest.
Where is tools.py in the architecture?
tools.py is located at libs/standard-tests/langchain_tests/unit_tests/tools.py (domain: LangChainCore, subdomain: Runnables, directory: libs/standard-tests/langchain_tests/unit_tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free