Class: Raif::Messages::ToolCall
- Inherits:
-
Object
- Object
- Raif::Messages::ToolCall
- Defined in:
- lib/raif/messages.rb
Overview
Tool invocation request from the assistant
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#assistant_message ⇒ Object
readonly
Returns the value of attribute assistant_message.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#provider_metadata ⇒ Object
readonly
Returns the value of attribute provider_metadata.
-
#provider_tool_call_id ⇒ Object
readonly
Returns the value of attribute provider_tool_call_id.
Class Method Summary collapse
-
.from_h(hash) ⇒ ToolCall
Deserialize from a hash.
Instance Method Summary collapse
-
#initialize(name:, arguments:, provider_tool_call_id: nil, assistant_message: nil, provider_metadata: nil) ⇒ ToolCall
constructor
A new instance of ToolCall.
-
#to_h ⇒ Hash
Hash representation for JSONB storage and LLM APIs.
Constructor Details
#initialize(name:, arguments:, provider_tool_call_id: nil, assistant_message: nil, provider_metadata: nil) ⇒ ToolCall
Returns a new instance of ToolCall.
84 85 86 87 88 89 90 |
# File 'lib/raif/messages.rb', line 84 def initialize(name:, arguments:, provider_tool_call_id: nil, assistant_message: nil, provider_metadata: nil) @provider_tool_call_id = provider_tool_call_id @name = name @arguments = arguments @assistant_message = @provider_metadata = end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
77 78 79 |
# File 'lib/raif/messages.rb', line 77 def arguments @arguments end |
#assistant_message ⇒ Object (readonly)
Returns the value of attribute assistant_message.
77 78 79 |
# File 'lib/raif/messages.rb', line 77 def @assistant_message end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
77 78 79 |
# File 'lib/raif/messages.rb', line 77 def name @name end |
#provider_metadata ⇒ Object (readonly)
Returns the value of attribute provider_metadata.
77 78 79 |
# File 'lib/raif/messages.rb', line 77 def @provider_metadata end |
#provider_tool_call_id ⇒ Object (readonly)
Returns the value of attribute provider_tool_call_id.
77 78 79 |
# File 'lib/raif/messages.rb', line 77 def provider_tool_call_id @provider_tool_call_id end |
Class Method Details
.from_h(hash) ⇒ ToolCall
Deserialize from a hash
107 108 109 110 111 112 113 114 115 |
# File 'lib/raif/messages.rb', line 107 def self.from_h(hash) new( name: hash["name"], arguments: hash["arguments"], provider_tool_call_id: hash["provider_tool_call_id"], assistant_message: hash["assistant_message"], provider_metadata: hash["provider_metadata"] ) end |
Instance Method Details
#to_h ⇒ Hash
Returns Hash representation for JSONB storage and LLM APIs.
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/raif/messages.rb', line 93 def to_h { "type" => "tool_call", "provider_tool_call_id" => provider_tool_call_id, "name" => name, "arguments" => arguments, "assistant_message" => , "provider_metadata" => }.compact end |