class

Fm::Tool

Inherits Reference < Object

A tool that can be invoked by the model.

Implement this abstract class to define custom tools that the model can call during generation.

class WeatherTool < Fm::Tool
  def name : String
    "checkWeather"
  end

  def description : String
    "Check current weather conditions"
  end

  def arguments_schema : JSON::Any
    JSON.parse(%({"type":"object","properties":{"location":{"type":"string"}},"required":["location"]}))
  end

  def call(arguments : JSON::Any) : Fm::ToolOutput
    location = arguments["location"]?.try(&.as_s) || "Unknown"
    Fm::ToolOutput.new("Weather in #{location}: Sunny, 72°F")
  end
end

Instance methods

arguments_schema

Returns the JSON schema for the tool's arguments.

Source
call(arguments : JSON::Any) : ToolOutput

Invokes the tool with the given arguments.

Source
description

Returns a description of what the tool does.

Source
name

Returns the name of the tool.

Source