Class: Ollama::Prompt
- Inherits:
-
Object
- Object
- Ollama::Prompt
- Defined in:
- lib/ollama/prompt.rb
Overview
Reusable prompt templates that produce Ollama::Messages.
Example DSL:
class ExplainCode < Ollama::Prompt
input(:code, :language)
system "You are a senior Ruby engineer."
user { [code, "Please review the #{language} implementation."].compact.join("\n") }
end
ExplainCode.new("def foo; end", "ruby").to_h
Class Attribute Summary collapse
-
.inputs ⇒ Object
readonly
Returns the value of attribute inputs.
-
.system_content ⇒ Object
readonly
Returns the value of attribute system_content.
-
.user_block ⇒ Object
readonly
Returns the value of attribute user_block.
Instance Attribute Summary collapse
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(*values) ⇒ Prompt
constructor
A new instance of Prompt.
- #to_h ⇒ Object
Constructor Details
Class Attribute Details
.inputs ⇒ Object (readonly)
Returns the value of attribute inputs.
17 18 19 |
# File 'lib/ollama/prompt.rb', line 17 def inputs @inputs end |
.system_content ⇒ Object (readonly)
Returns the value of attribute system_content.
17 18 19 |
# File 'lib/ollama/prompt.rb', line 17 def system_content @system_content end |
.user_block ⇒ Object (readonly)
Returns the value of attribute user_block.
17 18 19 |
# File 'lib/ollama/prompt.rb', line 17 def user_block @user_block end |
Instance Attribute Details
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
47 48 49 |
# File 'lib/ollama/prompt.rb', line 47 def @messages end |
Class Method Details
.input(*names) ⇒ Object
19 20 21 |
# File 'lib/ollama/prompt.rb', line 19 def input(*names) @inputs = names.freeze end |
.system(text) ⇒ Object
23 24 25 |
# File 'lib/ollama/prompt.rb', line 23 def system(text) @system_content = text end |
.user(&block) ⇒ Object
27 28 29 |
# File 'lib/ollama/prompt.rb', line 27 def user(&block) @user_block = block end |
Instance Method Details
#==(other) ⇒ Object
53 54 55 |
# File 'lib/ollama/prompt.rb', line 53 def ==(other) other.is_a?(Prompt) && to_h == other.to_h end |
#to_h ⇒ Object
49 50 51 |
# File 'lib/ollama/prompt.rb', line 49 def to_h .to_h end |