Class: ActiveIntelligence::LLM::Prompt
- Inherits:
-
Object
- Object
- ActiveIntelligence::LLM::Prompt
- Defined in:
- lib/active_intelligence/llm/prompt.rb
Instance Method Summary collapse
-
#initialize(template, assigns = {}) ⇒ Prompt
constructor
A new instance of Prompt.
- #render ⇒ Object
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
#render ⇒ Object
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 |