Class: LLM::Builder
- Inherits:
-
Object
- Object
- LLM::Builder
- Defined in:
- lib/llm/builder.rb
Overview
Note:
The LLM::Builder class can build a collection of messages that can be sent in a single request.
This API is not meant to be used directly.
Instance Method Summary collapse
- #call
- #chat(content, role: @provider.user_role)
- #developer(content)
-
#initialize(provider, &evaluator) ⇒ Builder
constructor
A new instance of Builder.
- #system(content)
- #to_a ⇒ Array
- #user(content)
Constructor Details
#initialize(provider, &evaluator) ⇒ Builder
Returns a new instance of Builder.
22 23 24 25 26 |
# File 'lib/llm/builder.rb', line 22 def initialize(provider, &evaluator) @provider = provider @buffer = [] @evaluator = evaluator end |
Instance Method Details
#call
This method returns an undefined value.
30 31 32 |
# File 'lib/llm/builder.rb', line 30 def call @evaluator.call(self) end |
#chat(content, role: @provider.user_role)
This method returns an undefined value.
40 41 42 43 44 45 46 47 48 |
# File 'lib/llm/builder.rb', line 40 def chat(content, role: @provider.user_role) role = case role.to_sym when :system then @provider.system_role when :user then @provider.user_role when :developer then @provider.developer_role else role end @buffer << LLM::Message.new(role, content) end |
#developer(content)
This method returns an undefined value.
70 71 72 |
# File 'lib/llm/builder.rb', line 70 def developer(content) chat(content, role: @provider.developer_role) end |
#system(content)
This method returns an undefined value.
62 63 64 |
# File 'lib/llm/builder.rb', line 62 def system(content) chat(content, role: @provider.system_role) end |
#to_a ⇒ Array
76 77 78 |
# File 'lib/llm/builder.rb', line 76 def to_a @buffer.dup end |
#user(content)
This method returns an undefined value.
54 55 56 |
# File 'lib/llm/builder.rb', line 54 def user(content) chat(content, role: @provider.user_role) end |