Tool

class Tool()

A class representing a Tool that can be used by an agent for various tasks.

This class encapsulates a tool with a name, description, and an executable function. The tool can be registered with a ConversableAgent for use either with an LLM or for direct execution.

Attributes:

  • name str - The name of the tool.
  • description str - A brief description of the tool’s purpose or function.
  • func Callable[…, Any] - The function to be executed when the tool is called.

__init__

def __init__(name: str, description: str, func: Callable[..., Any]) -> None

Create a new Tool object.

Arguments:

  • name str - The name of the tool.
  • description str - The description of the tool.
  • func Callable[…, Any] - The function that will be executed when the tool is called.

register_for_llm

def register_for_llm(agent: ConversableAgent) -> None

Registers the tool for use with a ConversableAgent’s language model (LLM).

This method registers the tool so that it can be invoked by the agent during interactions with the language model.

Arguments:

  • agent ConversableAgent - The agent to which the tool will be registered.

register_for_execution

def register_for_execution(agent: ConversableAgent) -> None

Registers the tool for direct execution by a ConversableAgent.

This method registers the tool so that it can be executed by the agent, typically outside of the context of an LLM interaction.

Arguments:

  • agent ConversableAgent - The agent to which the tool will be registered.