Class: LlmOrchestrator::Prompt
- Inherits:
-
Object
- Object
- LlmOrchestrator::Prompt
- 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
-
#template ⇒ Object
readonly
Returns the value of attribute template.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Instance Method Summary collapse
- #format(values = {}) ⇒ Object
-
#initialize(template) ⇒ Prompt
constructor
A new instance of Prompt.
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
#template ⇒ Object (readonly)
Returns the value of attribute template.
7 8 9 |
# File 'lib/llm_orchestrator/prompt.rb', line 7 def template @template end |
#variables ⇒ Object (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 |