Class: LLM::Builder
- Inherits:
-
Object
- Object
- LLM::Builder
- Defined in:
- lib/llm/builder.rb
Overview
The LLM::Builder class can build a collection of messages that can be sent in a single request.
Instance Method Summary collapse
- #call ⇒ void
- #chat(content, role: :user) ⇒ void
-
#initialize(&evaluator) ⇒ Builder
constructor
A new instance of Builder.
- #system(content) ⇒ void
- #to_a ⇒ Array
- #user(content) ⇒ void
Constructor Details
#initialize(&evaluator) ⇒ Builder
Returns a new instance of Builder.
19 20 21 22 |
# File 'lib/llm/builder.rb', line 19 def initialize(&evaluator) @buffer = [] @evaluator = evaluator end |
Instance Method Details
#call ⇒ void
This method returns an undefined value.
26 27 28 |
# File 'lib/llm/builder.rb', line 26 def call @evaluator.call(self) end |
#chat(content, role: :user) ⇒ void
This method returns an undefined value.
36 37 38 |
# File 'lib/llm/builder.rb', line 36 def chat(content, role: :user) @buffer << LLM::Message.new(role, content) end |
#system(content) ⇒ void
This method returns an undefined value.
52 53 54 |
# File 'lib/llm/builder.rb', line 52 def system(content) chat(content, role: :system) end |
#to_a ⇒ Array
58 59 60 |
# File 'lib/llm/builder.rb', line 58 def to_a @buffer.dup end |
#user(content) ⇒ void
This method returns an undefined value.
44 45 46 |
# File 'lib/llm/builder.rb', line 44 def user(content) chat(content, role: :user) end |