haive.core.utils.tool_list¶

Tool list implementation for Haive Core.

This module provides specialized tool collection management and utilities.

Classes¶

ToolList

A collection of tools that inherits from NamedDict.

Module Contents¶

class haive.core.utils.tool_list.ToolList(/, **data)[source]¶

Bases: haive.core.utils.haive_collections.NamedDict

A collection of tools that inherits from NamedDict.

Provides specialized handling for: - BaseTool classes and instances - BaseToolkit instances (automatically expands tools) - StructuredTool instances - Pydantic BaseModel classes (kept as classes) - Callable functions

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

add(tool, key=None)[source]¶

Add a tool with automatic or explicit key.

Parameters:
  • tool (Any) – Tool to add

  • key (str | None) – Optional explicit key

Returns:

Key used for the tool

Return type:

str

get_by_tool_type(tool_type)[source]¶

Get all tools of a specified type.

Parameters:

tool_type (str) – Type to filter by

Returns:

List of tools matching the type

Return type:

list[Any]

get_model_classes()[source]¶

Get all model classes in the tool list.

Returns:

Dictionary mapping name to model class

Return type:

dict[str, type[pydantic.BaseModel]]

get_model_instances()[source]¶

Get all model instances in the tool list.

Returns:

Dictionary mapping name to model instance

Return type:

dict[str, pydantic.BaseModel]

get_tool(name)[source]¶

Get a tool by name.

Parameters:

name (str) – Tool name

Returns:

Tool if found, None otherwise

Return type:

Any | None

get_tool_info(name)[source]¶

Get comprehensive information about a tool.

Parameters:

name (str) – Tool name

Returns:

Dictionary with tool information

Return type:

dict[str, Any]

get_tool_type(name)[source]¶

Get type of a specific tool.

Parameters:

name (str) – Tool name

Returns:

Tool type string or None if not found

Return type:

str | None

get_tool_type_mapping()[source]¶

Get mapping of tool types to tool names.

Returns:

Dictionary mapping tool types to lists of tool names

Return type:

dict[str, list[str]]

get_tools_by_category()[source]¶

Get tools organized by category.

Returns:

Dictionary with tools grouped by type

Return type:

dict[str, dict[str, Any]]

model_post_init(__context)[source]¶

Build tool type information after initialization.

Return type:

None

classmethod process_tools(data)[source]¶

Process tools input and expand toolkits.

Parameters:

data (Any)

Return type:

Any

to_list()[source]¶

Convert to a simple list of tools.

Returns:

List of all tools

Return type:

list[Any]

update(items)[source]¶

Update with new tools.

Parameters:

items (Any) – Dictionary or sequence of tools

Return type:

None

model_config¶

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].