Anthropic::ToolUseContent
Inherits JSON::Serializable < Struct < Value < Object
Tool use content block (from assistant)
When Claude calls a tool, the input is returned as dynamic JSON.
Use input_as to parse it into a typed struct:
struct GetWeatherInput
include JSON::Serializable
getter location : String
getter unit : String?
end
tool_use = message.tool_use_blocks.first
if tool_use.name == "get_weather"
input = tool_use.input_as(GetWeatherInput)
puts input.location # Typed access!
end
Constructors
new(pull : JSON::PullParser)
Sourcenew(*, __pull_for_json_serializable pull : JSON::PullParser)
SourceInstance methods
id
Sourceinput
Sourceinput_as(type : T.class) : T forall T
Parse input into a typed struct
Use this when you know which tool was called and want typed access to the input parameters.
input = tool_use.input_as(MyToolInput)
puts input.some_field # Type-safe!
name
Sourcetype
Source