Class: Crimson::Message::ToolResult
Overview
The result of executing a tool call, sent back to the model.
Instance Attribute Summary collapse
- #content ⇒ String readonly
- #name ⇒ String readonly
- #tool_call_id ⇒ String readonly
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(tool_call_id:, name:, content:) ⇒ ToolResult
constructor
A new instance of ToolResult.
-
#to_anthropic_h ⇒ Hash
Anthropic-compatible representation.
-
#to_openai_h ⇒ Hash
OpenAI-compatible representation.
Constructor Details
#initialize(tool_call_id:, name:, content:) ⇒ ToolResult
Returns a new instance of ToolResult.
146 147 148 149 150 151 |
# File 'lib/crimson/message.rb', line 146 def initialize(tool_call_id:, name:, content:) super("tool") @tool_call_id = tool_call_id @name = name @content = content end |
Instance Attribute Details
#content ⇒ String (readonly)
141 142 143 |
# File 'lib/crimson/message.rb', line 141 def content @content end |
#name ⇒ String (readonly)
141 142 143 |
# File 'lib/crimson/message.rb', line 141 def name @name end |
#tool_call_id ⇒ String (readonly)
141 142 143 |
# File 'lib/crimson/message.rb', line 141 def tool_call_id @tool_call_id end |
Instance Method Details
#to_anthropic_h ⇒ Hash
Returns Anthropic-compatible representation.
163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/crimson/message.rb', line 163 def to_anthropic_h { role: "user", content: [ { type: "tool_result", tool_use_id: @tool_call_id, content: @content } ] } end |
#to_openai_h ⇒ Hash
Returns OpenAI-compatible representation.
154 155 156 157 158 159 160 |
# File 'lib/crimson/message.rb', line 154 def to_openai_h { role: "tool", tool_call_id: @tool_call_id, content: @content } end |