Guide

Function calling, in Ruby.

Tools are PORO classes with a typed schema and a `call` method. Rails Agent handles the JSON schema, the parsing and the retries.

Define a tool

class Orders::FindTool < RailsAgent::Tool
  description "Look up an order by ID"
  schema do
    string :order_id, required: true
  end

  def call(order_id:)
    Order.find(order_id).as_json
  end
end

Wire into an agent

class Concierge < RailsAgents::Base
  tool :find_order, using: Orders::FindTool
end