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. Must match NAME_FORMAT (letters, digits, underscore, hyphen; max 64 chars).

  • 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:



173
174
175
176
177
178
179
180
181
# File 'lib/ruby_pi/tools/definition.rb', line 173

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