Class: LLM::Schema::Object
- Defined in:
- lib/llm/shell/internal/llm.rb/lib/llm/schema/object.rb
Overview
The LLM::Schema::Object class represents an object value in a JSON schema. It is a subclass of LLM::Schema::Leaf and provides methods that can act as constraints.
Instance Attribute Summary collapse
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Method Summary collapse
-
#initialize(properties) ⇒ Object
constructor
A new instance of Object.
-
#merge!(other) ⇒ LLM::Schema::Object
Returns self.
- #to_h ⇒ Object
- #to_json(options = {}) ⇒ Object
Methods inherited from Leaf
#const, #default, #description, #enum, #required?
Constructor Details
#initialize(properties) ⇒ Object
Returns a new instance of Object.
12 13 14 |
# File 'lib/llm/shell/internal/llm.rb/lib/llm/schema/object.rb', line 12 def initialize(properties) @properties = properties end |
Instance Attribute Details
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
10 11 12 |
# File 'lib/llm/shell/internal/llm.rb/lib/llm/schema/object.rb', line 10 def properties @properties end |
Instance Method Details
#merge!(other) ⇒ LLM::Schema::Object
Returns self
25 26 27 28 29 |
# File 'lib/llm/shell/internal/llm.rb/lib/llm/schema/object.rb', line 25 def merge!(other) raise TypeError unless self.class === self @properties.merge!(other.properties) self end |
#to_h ⇒ Object
16 17 18 |
# File 'lib/llm/shell/internal/llm.rb/lib/llm/schema/object.rb', line 16 def to_h super.merge!({type: "object", properties:, required:}) end |
#to_json(options = {}) ⇒ Object
31 32 33 |
# File 'lib/llm/shell/internal/llm.rb/lib/llm/schema/object.rb', line 31 def to_json( = {}) to_h.to_json() end |