Class: OmniAI::Chat::ToolCall
- Inherits:
-
Object
- Object
- OmniAI::Chat::ToolCall
- Defined in:
- lib/omniai/chat/tool_call.rb
Overview
A tool-call that includes an ID / function.
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, function:) ⇒ ToolCall
constructor
A new instance of ToolCall.
- #inspect ⇒ String
- #serialize(context: nil) ⇒ Hash
Constructor Details
#initialize(id:, function:) ⇒ ToolCall
Returns a new instance of ToolCall.
15 16 17 18 |
# File 'lib/omniai/chat/tool_call.rb', line 15 def initialize(id:, function:) @id = id @function = function end |
Instance Attribute Details
#function ⇒ Function
11 12 13 |
# File 'lib/omniai/chat/tool_call.rb', line 11 def function @function end |
#id ⇒ String
8 9 10 |
# File 'lib/omniai/chat/tool_call.rb', line 8 def id @id end |
Class Method Details
.deserialize(data, context: nil) ⇒ Function
29 30 31 32 33 34 35 36 37 |
# File 'lib/omniai/chat/tool_call.rb', line 29 def self.deserialize(data, context: nil) deserialize = context&.deserializer(:tool_call) return deserialize.call(data, context:) if deserialize id = data['id'] function = Function.deserialize(data['function'], context:) new(id:, function:) end |
Instance Method Details
#inspect ⇒ String
21 22 23 |
# File 'lib/omniai/chat/tool_call.rb', line 21 def inspect "#<#{self.class.name} id=#{id.inspect} function=#{function.inspect}>" end |
#serialize(context: nil) ⇒ Hash
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/omniai/chat/tool_call.rb', line 42 def serialize(context: nil) serializer = context&.serializer(:tool_call) return serializer.call(self, context:) if serializer { id: @id, type: 'function', function: @function.serialize(context:), } end |