Class: Riffer::Messages::Tool
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#error_type ⇒ Object
readonly
Returns the value of attribute error_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tool_call_id ⇒ Object
readonly
Returns the value of attribute tool_call_id.
Attributes inherited from Base
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(content, tool_call_id:, name:, error: nil, error_type: nil) ⇒ Tool
constructor
A new instance of Tool.
- #role ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(content, tool_call_id:, name:, error: nil, error_type: nil) ⇒ Tool
Returns a new instance of Tool.
6 7 8 9 10 11 12 |
# File 'lib/riffer/messages/tool.rb', line 6 def initialize(content, tool_call_id:, name:, error: nil, error_type: nil) super(content) @tool_call_id = tool_call_id @name = name @error = error @error_type = error_type end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
4 5 6 |
# File 'lib/riffer/messages/tool.rb', line 4 def error @error end |
#error_type ⇒ Object (readonly)
Returns the value of attribute error_type.
4 5 6 |
# File 'lib/riffer/messages/tool.rb', line 4 def error_type @error_type end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/riffer/messages/tool.rb', line 4 def name @name end |
#tool_call_id ⇒ Object (readonly)
Returns the value of attribute tool_call_id.
4 5 6 |
# File 'lib/riffer/messages/tool.rb', line 4 def tool_call_id @tool_call_id end |
Instance Method Details
#error? ⇒ Boolean
14 15 16 |
# File 'lib/riffer/messages/tool.rb', line 14 def error? !@error.nil? end |
#role ⇒ Object
18 19 20 |
# File 'lib/riffer/messages/tool.rb', line 18 def role "tool" end |
#to_h ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/riffer/messages/tool.rb', line 22 def to_h hash = {role: role, content: content, tool_call_id: tool_call_id, name: name} if error? hash[:error] = error hash[:error_type] = error_type end hash end |