Module: LLM::Schema::Utils Private
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #fetch(properties, name) ⇒ Object private
- #resolve(schema, type) ⇒ Object private
- #resolve_array(schema, values) ⇒ Object private
Instance Method Details
#fetch(properties, name) ⇒ Object
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.
80 81 82 |
# File 'lib/llm/schema.rb', line 80 def fetch(properties, name) properties[name] || properties.fetch(name.to_s) end |
#resolve(schema, type) ⇒ Object
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.
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/llm/schema.rb', line 58 def resolve(schema, type) if LLM::Schema::Leaf === type type elsif ::Array === type resolve_array(schema, type) elsif Class === type && type.respond_to?(:object) type.object else target = type.name.split("::").last.downcase schema.public_send(target) end end |
#resolve_array(schema, values) ⇒ Object
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.
71 72 73 74 75 76 77 78 |
# File 'lib/llm/schema.rb', line 71 def resolve_array(schema, values) item = if values.size == 1 resolve(schema, values[0]) else schema.any_of(*values.map { resolve(schema, _1) }) end schema.array(item) end |