Class: ActiveIntelligence::LLM::Prompt

Inherits:
Object
  • Object
show all
Defined in:
lib/active_intelligence/llm/prompt.rb

Instance Method Summary collapse

Constructor Details

#initialize(template, assigns = {}) ⇒ Prompt

Returns a new instance of Prompt.



6
7
8
9
# File 'lib/active_intelligence/llm/prompt.rb', line 6

def initialize(template, assigns = {})
  @template = template
  @assigns = assigns
end

Instance Method Details

#renderObject



11
12
13
14
15
16
17
# File 'lib/active_intelligence/llm/prompt.rb', line 11

def render
  lookup_context = ActionView::LookupContext.new([Rails.root.join('app/prompts')])
  context = ActionView::Base.with_empty_template_cache.new(lookup_context, @assigns, nil)
  renderer = ActionView::Renderer.new(lookup_context)

  return renderer.render(context, { template: @template, formats: [:text], handlers: [:erb] })
end