Class: Manceps::ToolResult
- Inherits:
-
Object
- Object
- Manceps::ToolResult
- Defined in:
- lib/manceps/tool_result.rb
Overview
Result of a tool invocation.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#is_error ⇒ Object
readonly
Returns the value of attribute is_error.
-
#structured_content ⇒ Object
readonly
Returns the value of attribute structured_content.
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(data) ⇒ ToolResult
constructor
A new instance of ToolResult.
- #structured? ⇒ Boolean
- #text ⇒ Object
Constructor Details
#initialize(data) ⇒ ToolResult
Returns a new instance of ToolResult.
8 9 10 11 12 |
# File 'lib/manceps/tool_result.rb', line 8 def initialize(data) @content = (data['content'] || []).map { |c| Content.new(c) } @is_error = data['isError'] || false @structured_content = data['structuredContent'] end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
6 7 8 |
# File 'lib/manceps/tool_result.rb', line 6 def content @content end |
#is_error ⇒ Object (readonly)
Returns the value of attribute is_error.
6 7 8 |
# File 'lib/manceps/tool_result.rb', line 6 def is_error @is_error end |
#structured_content ⇒ Object (readonly)
Returns the value of attribute structured_content.
6 7 8 |
# File 'lib/manceps/tool_result.rb', line 6 def structured_content @structured_content end |
Instance Method Details
#error? ⇒ Boolean
14 15 16 |
# File 'lib/manceps/tool_result.rb', line 14 def error? is_error end |
#structured? ⇒ Boolean
22 23 24 |
# File 'lib/manceps/tool_result.rb', line 22 def structured? !structured_content.nil? end |
#text ⇒ Object
18 19 20 |
# File 'lib/manceps/tool_result.rb', line 18 def text content.select(&:text?).map(&:text).join("\n") end |