Sha256: 64d892ce32eda3d36b845c0672cfd822e5f440bb062fa901e9e980b82e2164d2

Contents?: true

Size: 493 Bytes

Versions: 1

Compression:

Stored size: 493 Bytes

Contents

module LlmOrchestrator
  class Prompt
    attr_reader :template, :variables
    
    def initialize(template)
      @template = template
      @variables = extract_variables(template)
    end
    
    def format(values = {})
      result = template.dup
      values.each do |key, value|
        result.gsub!("{#{key}}", value.to_s)
      end
      result
    end
    
    private
    
    def extract_variables(template)
      template.scan(/\{(\w+)\}/).flatten.map(&:to_sym)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
llm_orchestrator-0.1.0 lib/llm_orchestrator/prompt.rb