Expand description
Base classes and utilities for LangChain tools.
This module provides the core tool abstractions, mirroring
langchain_core.tools.base.
Structs§
- Injected
Tool Arg - Annotation for tool arguments that are injected at runtime.
- Injected
Tool Call Id - Annotation for injecting the tool call ID.
- Schema
Annotation Error - Error raised when args_schema is missing or has incorrect type annotation.
- Tool
Definition - Represents a tool’s definition for LLM function calling.
- Tool
Exception - Exception thrown when a tool execution error occurs.
Enums§
- Args
Schema - Represents a tool’s schema, which can be a JSON schema or a type reference.
- Handle
Tool Error - How to handle tool errors.
- Handle
Validation Error - How to handle validation errors.
- Response
Format - Represents the response format for a tool.
- Tool
Input - Input type for tools - can be a string, dict, or ToolCall.
- Tool
Output - Output type for tools.
Constants§
- FILTERED_
ARGS - Arguments that are filtered out from tool schemas.
- TOOL_
MESSAGE_ BLOCK_ TYPES - Block types that are valid in tool messages.
Traits§
- Base
Tool - Base trait for all LangChain tools.
- Base
Toolkit - Base class for toolkits containing related tools.
Functions§
- format_
output - Format tool output as appropriate.
- handle_
tool_ error_ impl - Handle a tool exception based on the configured flag.
- handle_
validation_ error_ impl - Handle a validation error based on the configured flag.
- is_
message_ content_ block - Check if object is a valid message content block.
- is_
message_ content_ type - Check if content is a valid message content type.
- is_
tool_ call - Check if an input is a tool call dictionary.
- prep_
run_ args - Prepare arguments for tool execution.
- stringify_
content - Convert content to string, preferring JSON format.
Type Aliases§
- DynTool
- Type alias for dynamic tool reference.