Module: LLM::Schema::Renderer Private
Overview
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.
Internal renderer for prompt-friendly schema output.
Instance Method Summary collapse
-
#render(node, indent: 0, name: nil, root: false) ⇒ String
private
Render a schema node as a human-readable string.
Instance Method Details
#render(node, indent: 0, name: nil, root: false) ⇒ 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.
Render a schema node as a human-readable string.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/llm/schema/renderer.rb', line 21 def render(node, indent: 0, name: nil, root: false) line = (" " * indent).to_s if name line << name.to_s line << "?" unless node.required? line << ": " end line << type_name(node) = (node, include_required: !root) line << " (#{.join(", ")})" unless .empty? line << " - #{node.description}" if node.respond_to?(:description) && node.description nested = nested_lines(node, indent: indent + 2) ([line] + nested).join("\n") end |