Class: LLM::Schema::Deferred Private
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
LLM::Schema::Deferred is a placeholder for a leaf that is resolved when the schema is rendered.
A parameter type that can only be known at runtime - an enum of the keys a store holds right now, for example - is given as a proc. The proc is called when the schema is rendered rather than when the class that declares the parameter is defined, so declaring a tool does not touch whatever the type depends on:
parameter :fruit, proc { Enum[*Fruit.kinds]}, "A fruit", required: true
Whatever the proc returns is resolved in turn, so it can return a leaf, a class, or an array of either.
Instance Attribute Summary
Attributes inherited from Leaf
Instance Method Summary collapse
- #initialize(&block) ⇒ LLM::Schema::Deferred constructor private
- #to_h ⇒ Hash private
- #to_json(options = {}) ⇒ String private
- #to_s ⇒ String private
Methods inherited from Leaf
#==, #const, #default, #description, #enum, #hash, #optional, #optional?, #owner=, #required, #required?, #resolve
Constructor Details
#initialize(&block) ⇒ LLM::Schema::Deferred
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 |
# File 'lib/llm/schema/deferred.rb', line 25 def initialize(&block) super() @block = block end |
Instance Method Details
#to_h ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 |
# File 'lib/llm/schema/deferred.rb', line 32 def to_h resolved_leaf.to_h end |
#to_json(options = {}) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
39 40 41 |
# File 'lib/llm/schema/deferred.rb', line 39 def to_json( = {}) resolved_leaf.to_h.to_json() end |
#to_s ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 |
# File 'lib/llm/schema/deferred.rb', line 45 def to_s resolved_leaf.to_s end |