Class: OmniAI::Chat::ToolCallList
- Inherits:
-
Object
- Object
- OmniAI::Chat::ToolCallList
- Includes:
- Enumerable
- Defined in:
- lib/omniai/chat/tool_call_list.rb
Overview
An ‘OmniAI::Chat::ToolCallList` is a collection designed to handle the merging of multiple tool call arrays. LLMs provide a subset of tool call items when chunking, so merging requires the use of the tool call index to combine.
Class Method Summary collapse
Instance Method Summary collapse
- #each {|toolcall| ... } ⇒ Object
-
#initialize(entries: []) ⇒ ToolCallList
constructor
A new instance of ToolCallList.
- #inspect ⇒ String
-
#serialize(context: nil) ⇒ Array<Hash>
Usage:.
Constructor Details
#initialize(entries: []) ⇒ ToolCallList
Returns a new instance of ToolCallList.
11 12 13 |
# File 'lib/omniai/chat/tool_call_list.rb', line 11 def initialize(entries: []) @entries = entries end |
Class Method Details
.deserialize(data, context: nil) ⇒ ToolCallList
Usage:
ToolCallList.deserialize([]) # => #<ToolCallList ...>
23 24 25 26 27 |
# File 'lib/omniai/chat/tool_call_list.rb', line 23 def self.deserialize(data, context: nil) return unless data new(entries: data.map { |subdata| ToolCall.deserialize(subdata, context:) }) end |
Instance Method Details
#each {|toolcall| ... } ⇒ Object
47 48 49 |
# File 'lib/omniai/chat/tool_call_list.rb', line 47 def each(&) @entries.each(&) end |
#inspect ⇒ String
41 42 43 |
# File 'lib/omniai/chat/tool_call_list.rb', line 41 def inspect "#<#{self.class.name} entries=#{@entries.inspect}>" end |
#serialize(context: nil) ⇒ Array<Hash>
Usage:
tool_call_list.serialize # => [...]
36 37 38 |
# File 'lib/omniai/chat/tool_call_list.rb', line 36 def serialize(context: nil) @entries.compact.map { |tool_call| tool_call.serialize(context:) } end |