Module: RubyPi::Tool

Defined in:
lib/ruby_pi/tools/definition.rb

Overview

Top-level convenience module for defining tools with a short syntax.

Usage:

tool = RubyPi::Tool.define(name: "my_tool", description: "Does stuff") { |args| ... }

Class Method Summary collapse

Class Method Details

.define(name:, description:, category: nil, parameters: {}, &block) ⇒ RubyPi::Tools::Definition

Creates a new tool Definition using the same arguments as Definition.new.

This is the primary public API for defining tools. It provides a cleaner entry point than instantiating Definition directly.

Parameters:

  • name (String, Symbol)

    Unique identifier for the tool.

  • description (String)

    What the tool does (shown to the LLM).

  • category (Symbol, nil) (defaults to: nil)

    Optional grouping category.

  • parameters (Hash) (defaults to: {})

    JSON Schema hash for the tool’s input parameters.

Returns:



138
139
140
141
142
143
144
145
146
# File 'lib/ruby_pi/tools/definition.rb', line 138

def define(name:, description:, category: nil, parameters: {}, &block)
  Tools::Definition.new(
    name: name,
    description: description,
    category: category,
    parameters: parameters,
    &block
  )
end