Class: LLM::MessageQueue
- Inherits:
-
Object
- Object
- LLM::MessageQueue
- Includes:
- Enumerable
- Defined in:
- lib/llm/message_queue.rb
Overview
LLM::MessageQueue provides an Enumerable object that yields each message in a conversation on-demand, and only sends a request to the LLM when a response is needed.
Instance Method Summary collapse
- #<<(item) ⇒ void (also: #push)
- #each {|LLM::Message| ... } ⇒ void
- #initialize(provider) ⇒ LLM::MessageQueue constructor
Constructor Details
#initialize(provider) ⇒ LLM::MessageQueue
14 15 16 17 18 |
# File 'lib/llm/message_queue.rb', line 14 def initialize(provider) @provider = provider @pending = [] @completed = [] end |
Instance Method Details
#<<(item) ⇒ void Also known as: push
This method returns an undefined value.
34 35 36 37 |
# File 'lib/llm/message_queue.rb', line 34 def <<(item) @pending << item self end |
#each {|LLM::Message| ... } ⇒ void
This method returns an undefined value.
25 26 27 28 |
# File 'lib/llm/message_queue.rb', line 25 def each complete! unless @pending.empty? @completed.each { yield(_1) } end |