Fm::Tool
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