class Riffer::Messages::Tool
rbs_inline: enabled
Attributes
Public Class Methods
Source
# File lib/riffer/messages/tool.rb, line 7 def self.from_hash(msg) return msg if msg.is_a?(Riffer::Messages::Tool) new( msg[:content], id: msg[:id], tool_call_id: msg[:tool_call_id], name: msg[:name], error: msg[:error], error_type: msg[:error_type]&.to_sym, loaded_tools: msg[:loaded_tools] || [], ) end
Source
# File lib/riffer/messages/tool.rb, line 29 def initialize(content, tool_call_id:, name:, id: nil, error: nil, error_type: nil, loaded_tools: []) super(content, id: id) @tool_call_id = tool_call_id @name = name @error = error @error_type = error_type @loaded_tools = loaded_tools end
Calls superclass method
Riffer::Messages::Base::new
Public Instance Methods
Source
# File lib/riffer/messages/tool.rb, line 52 def to_h hash = { role: role, content: content, tool_call_id: tool_call_id, name: name } #: Hash[Symbol, untyped] hash[:id] = id if id if error? hash[:error] = error hash[:error_type] = error_type end hash[:loaded_tools] = loaded_tools unless loaded_tools.empty? hash end