Class: LlmOrchestrator::Prompt

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

Overview

Prompt handles template-based prompt generation for LLM interactions Supports variable interpolation and template management

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template) ⇒ Prompt

Returns a new instance of Prompt.



9
10
11
12
# File 'lib/llm_orchestrator/prompt.rb', line 9

def initialize(template)
  @template = template
  @variables = extract_variables(template)
end

Instance Attribute Details

#templateObject (readonly)

Returns the value of attribute template.



7
8
9
# File 'lib/llm_orchestrator/prompt.rb', line 7

def template
  @template
end

#variablesObject (readonly)

Returns the value of attribute variables.



7
8
9
# File 'lib/llm_orchestrator/prompt.rb', line 7

def variables
  @variables
end

Instance Method Details

#format(values = {}) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/llm_orchestrator/prompt.rb', line 14

def format(values = {})
  result = template.dup
  values.each do |key, value|
    result.gsub!("{#{key}}", value.to_s)
  end
  result
end