Class: LumenLLM::Template
- Inherits:
-
Object
- Object
- LumenLLM::Template
- Defined in:
- lib/lumen_llm/template.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#output_type ⇒ Object
readonly
Returns the value of attribute output_type.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#system_prompt ⇒ Object
readonly
Returns the value of attribute system_prompt.
-
#user_prompt ⇒ Object
readonly
Returns the value of attribute user_prompt.
Instance Method Summary collapse
-
#initialize(key:, system_prompt:, user_prompt:, model:, provider: :openrouter, output_type: :json) ⇒ Template
constructor
A new instance of Template.
- #render(input) ⇒ Object
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
#key ⇒ Object (readonly)
Returns the value of attribute key.
3 4 5 |
# File 'lib/lumen_llm/template.rb', line 3 def key @key end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
3 4 5 |
# File 'lib/lumen_llm/template.rb', line 3 def model @model end |
#output_type ⇒ Object (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 |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
3 4 5 |
# File 'lib/lumen_llm/template.rb', line 3 def provider @provider end |
#system_prompt ⇒ Object (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_prompt ⇒ Object (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 |