Class: OmniAI::Tool::Array
- Inherits:
-
Object
- Object
- OmniAI::Tool::Array
- Defined in:
- lib/omniai/tool/array.rb
Overview
Represents a schema object.
Constant Summary collapse
- TYPE =
'array'
Instance Attribute Summary collapse
- #description ⇒ String?
- #items ⇒ OmniAI::Tool::Object, ...
- #max_items ⇒ Integer?
- #min_items ⇒ Integer?
Instance Method Summary collapse
-
#initialize(items:, max_items: nil, min_items: nil, description: nil) ⇒ Array
constructor
A new instance of Array.
- #parse(args) ⇒ Array
- #serialize ⇒ Hash
Constructor Details
#initialize(items:, max_items: nil, min_items: nil, description: nil) ⇒ Array
Returns a new instance of Array.
43 44 45 46 47 48 |
# File 'lib/omniai/tool/array.rb', line 43 def initialize(items:, max_items: nil, min_items: nil, description: nil) @items = items @description = description @max_items = max_items @min_items = min_items end |
Instance Attribute Details
#description ⇒ String?
37 38 39 |
# File 'lib/omniai/tool/array.rb', line 37 def description @description end |
#items ⇒ OmniAI::Tool::Object, ...
25 26 27 |
# File 'lib/omniai/tool/array.rb', line 25 def items @items end |
#max_items ⇒ Integer?
29 30 31 |
# File 'lib/omniai/tool/array.rb', line 29 def max_items @max_items end |
#min_items ⇒ Integer?
33 34 35 |
# File 'lib/omniai/tool/array.rb', line 33 def min_items @min_items end |
Instance Method Details
#parse(args) ⇒ Array
69 70 71 |
# File 'lib/omniai/tool/array.rb', line 69 def parse(args) args.map { |arg| @items.parse(arg) } end |
#serialize ⇒ Hash
54 55 56 57 58 59 60 61 62 |
# File 'lib/omniai/tool/array.rb', line 54 def serialize { type: TYPE, description: @description, items: @items.serialize, maxItems: @max_items, minItems: @min_items, }.compact end |