Module base

Module base 

Source
Expand description

Base classes and utilities for LangChain tools.

This module provides the core tool abstractions, mirroring langchain_core.tools.base.

Structs§

InjectedToolArg
Annotation for tool arguments that are injected at runtime.
InjectedToolCallId
Annotation for injecting the tool call ID.
SchemaAnnotationError
Error raised when args_schema is missing or has incorrect type annotation.
ToolDefinition
Represents a tool’s definition for LLM function calling.
ToolException
Exception thrown when a tool execution error occurs.

Enums§

ArgsSchema
Represents a tool’s schema, which can be a JSON schema or a type reference.
HandleToolError
How to handle tool errors.
HandleValidationError
How to handle validation errors.
ResponseFormat
Represents the response format for a tool.
ToolInput
Input type for tools - can be a string, dict, or ToolCall.
ToolOutput
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§

BaseTool
Base trait for all LangChain tools.
BaseToolkit
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.