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
- #function ⇒ Function
- #id ⇒ String
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, function:, **options) ⇒ ToolCall
constructor
A new instance of ToolCall.
- #inspect ⇒ String
- #serialize(context: nil) ⇒ Hash
Constructor Details
#initialize(id:, function:, **options) ⇒ ToolCall
Returns a new instance of ToolCall.
22 23 24 25 26 |
# File 'lib/omniai/chat/tool_call.rb', line 22 def initialize(id:, function:, **) @id = id @function = function @options = end |
Instance Attribute Details
#function ⇒ Function
13 14 15 |
# File 'lib/omniai/chat/tool_call.rb', line 13 def function @function end |
#id ⇒ String
9 10 11 |
# File 'lib/omniai/chat/tool_call.rb', line 9 def id @id end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
17 18 19 |
# File 'lib/omniai/chat/tool_call.rb', line 17 def @options end |
Class Method Details
.deserialize(data, context: nil) ⇒ ToolCall
37 38 39 40 41 42 43 44 45 |
# File 'lib/omniai/chat/tool_call.rb', line 37 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
29 30 31 |
# File 'lib/omniai/chat/tool_call.rb', line 29 def inspect "#<#{self.class.name} id=#{id.inspect} function=#{function.inspect}>" end |
#serialize(context: nil) ⇒ Hash
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/omniai/chat/tool_call.rb', line 50 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 |