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
Instance Method Details
#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.
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/llm/schema.rb', line 56 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.
69 70 71 72 73 74 75 76 |
# File 'lib/llm/schema.rb', line 69 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 |