Class: OmniAI::Tool::Property
- Inherits:
-
Object
- Object
- OmniAI::Tool::Property
- Defined in:
- lib/omniai/tool/property.rb
Overview
Usage:
property = OmniAI::Tool::Property.new(type: ‘string’, description: ‘The nth number to calculate.’)
Defined Under Namespace
Modules: Type
Instance Attribute Summary collapse
- #description ⇒ String? readonly
- #enum ⇒ Array<String>? readonly
- #type ⇒ String readonly
Class Method Summary collapse
- .boolean(description: nil, enum: nil) ⇒ OmniAI::Tool::Property
- .integer(description: nil, enum: nil) ⇒ OmniAI::Tool::Property
- .number(description: nil, enum: nil) ⇒ OmniAI::Tool::Property
- .string(description: nil, enum: nil) ⇒ OmniAI::Tool::Property
Instance Method Summary collapse
- #initialize(type:, description: nil, enum: nil) ⇒ OmniAI::Tool::Property constructor
- #parse(value) ⇒ String, ...
- #prepare ⇒ Hash
Constructor Details
#initialize(type:, description: nil, enum: nil) ⇒ OmniAI::Tool::Property
56 57 58 59 60 |
# File 'lib/omniai/tool/property.rb', line 56 def initialize(type:, description: nil, enum: nil) @type = type @description = description @enum = enum end |
Instance Attribute Details
#description ⇒ String? (readonly)
20 21 22 |
# File 'lib/omniai/tool/property.rb', line 20 def description @description end |
#enum ⇒ Array<String>? (readonly)
23 24 25 |
# File 'lib/omniai/tool/property.rb', line 23 def enum @enum end |
#type ⇒ String (readonly)
17 18 19 |
# File 'lib/omniai/tool/property.rb', line 17 def type @type end |
Class Method Details
.boolean(description: nil, enum: nil) ⇒ OmniAI::Tool::Property
28 29 30 |
# File 'lib/omniai/tool/property.rb', line 28 def self.boolean(description: nil, enum: nil) new(type: Type::BOOLEAN, description:, enum:) end |
.integer(description: nil, enum: nil) ⇒ OmniAI::Tool::Property
35 36 37 |
# File 'lib/omniai/tool/property.rb', line 35 def self.integer(description: nil, enum: nil) new(type: Type::INTEGER, description:, enum:) end |
.number(description: nil, enum: nil) ⇒ OmniAI::Tool::Property
49 50 51 |
# File 'lib/omniai/tool/property.rb', line 49 def self.number(description: nil, enum: nil) new(type: Type::NUMBER, description:, enum:) end |
.string(description: nil, enum: nil) ⇒ OmniAI::Tool::Property
42 43 44 |
# File 'lib/omniai/tool/property.rb', line 42 def self.string(description: nil, enum: nil) new(type: Type::STRING, description:, enum:) end |
Instance Method Details
#parse(value) ⇒ String, ...
80 81 82 83 84 85 86 87 |
# File 'lib/omniai/tool/property.rb', line 80 def parse(value) case @type when Type::INTEGER then Integer(value) when Type::STRING then String(value) when Type::NUMBER then Float(value) else value end end |
#prepare ⇒ Hash
71 72 73 74 75 76 77 |
# File 'lib/omniai/tool/property.rb', line 71 def prepare { type: @type, description: @description, enum: @enum, }.compact end |