class RubyLLM::Prompt::Context
The object a prompt template is evaluated in. Locals become local variables of the template, and render inserts a partial.
The class is declared with its full name so the template binding has no RubyLLM lexical scope: Chat in a template is the application’s model, not RubyLLM::Chat.
Attributes
Returns the locals passed to the current prompt or partial. Use it to read an optional local, or a local whose name is not a valid Ruby variable name:
<% if local_assigns[:product_name] %>
Public Instance Methods
# File lib/ruby_llm/prompt/context.rb, line 33 def render(options = {}, locals = {}) return partial(options).render(**locals) unless options.is_a?(Hash) partial(options.fetch(:partial)).render(**(options[:locals] || {})) end
Renders a partial with locals. A bare name is looked up next to the current prompt only. A name with a path is looked up in the prompt roots.
<%= render "tone" %>
<%= render "shared/safety", product_name: product_name %>
<%= render partial: "shared/safety", locals: { product_name: product_name } %>