Class: LumenLLM::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/lumen_llm/template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key:, system_prompt:, user_prompt:, model:, provider: :openrouter, output_type: :json) ⇒ Template

Returns a new instance of Template.



5
6
7
8
9
10
11
12
# File 'lib/lumen_llm/template.rb', line 5

def initialize(key:, system_prompt:, user_prompt:, model:, provider: :openrouter, output_type: :json)
  @key = key.to_s
  @system_prompt = system_prompt.to_s
  @user_prompt = user_prompt.to_s
  @model = model.to_s
  @provider = provider.to_s
  @output_type = output_type.to_s
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



3
4
5
# File 'lib/lumen_llm/template.rb', line 3

def key
  @key
end

#modelObject (readonly)

Returns the value of attribute model.



3
4
5
# File 'lib/lumen_llm/template.rb', line 3

def model
  @model
end

#output_typeObject (readonly)

Returns the value of attribute output_type.



3
4
5
# File 'lib/lumen_llm/template.rb', line 3

def output_type
  @output_type
end

#providerObject (readonly)

Returns the value of attribute provider.



3
4
5
# File 'lib/lumen_llm/template.rb', line 3

def provider
  @provider
end

#system_promptObject (readonly)

Returns the value of attribute system_prompt.



3
4
5
# File 'lib/lumen_llm/template.rb', line 3

def system_prompt
  @system_prompt
end

#user_promptObject (readonly)

Returns the value of attribute user_prompt.



3
4
5
# File 'lib/lumen_llm/template.rb', line 3

def user_prompt
  @user_prompt
end

Instance Method Details

#render(input) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/lumen_llm/template.rb', line 14

def render(input)
  {
    :provider => provider,
    :model => model,
    :messages => [
      { :role => "system", :content => interpolate(system_prompt, input) },
      { :role => "user", :content => interpolate(user_prompt, input) }
    ]
  }
end