tools.py — langchain Source File
Architecture documentation for tools.py, a python file in the langchain codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 20a07e07_26ee_ded7_a31f_ef7d03a44e8b["tools.py"] 17a62cb3_fefd_6320_b757_b53bb4a1c661["langchain_core.callbacks"] 20a07e07_26ee_ded7_a31f_ef7d03a44e8b --> 17a62cb3_fefd_6320_b757_b53bb4a1c661 121262a1_0bd6_d637_bce3_307ab6b3ecd4["langchain_core.tools"] 20a07e07_26ee_ded7_a31f_ef7d03a44e8b --> 121262a1_0bd6_d637_bce3_307ab6b3ecd4 f85fae70_1011_eaec_151c_4083140ae9e5["typing_extensions"] 20a07e07_26ee_ded7_a31f_ef7d03a44e8b --> f85fae70_1011_eaec_151c_4083140ae9e5 style 20a07e07_26ee_ded7_a31f_ef7d03a44e8b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Interface for tools."""
from langchain_core.callbacks import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain_core.tools import BaseTool, tool
from typing_extensions import override
class InvalidTool(BaseTool):
"""Tool that is run when invalid tool name is encountered by agent."""
name: str = "invalid_tool"
"""Name of the tool."""
description: str = "Called when tool name is invalid. Suggests valid tool names."
"""Description of the tool."""
@override
def _run(
self,
requested_tool_name: str,
available_tool_names: list[str],
run_manager: CallbackManagerForToolRun | None = None,
) -> str:
"""Use the tool."""
available_tool_names_str = ", ".join(list(available_tool_names))
return (
f"{requested_tool_name} is not a valid tool, "
f"try one of [{available_tool_names_str}]."
)
@override
async def _arun(
self,
requested_tool_name: str,
available_tool_names: list[str],
run_manager: AsyncCallbackManagerForToolRun | None = None,
) -> str:
"""Use the tool asynchronously."""
available_tool_names_str = ", ".join(list(available_tool_names))
return (
f"{requested_tool_name} is not a valid tool, "
f"try one of [{available_tool_names_str}]."
)
__all__ = ["InvalidTool", "tool"]
Domain
Subdomains
Classes
Dependencies
- langchain_core.callbacks
- langchain_core.tools
- typing_extensions
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 AgentOrchestration domain, ClassicChains subdomain.
What does tools.py depend on?
tools.py imports 3 module(s): langchain_core.callbacks, langchain_core.tools, typing_extensions.
Where is tools.py in the architecture?
tools.py is located at libs/langchain/langchain_classic/agents/tools.py (domain: AgentOrchestration, subdomain: ClassicChains, directory: libs/langchain/langchain_classic/agents).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free