Class: LLM::LazyConversation
- Inherits:
-
Object
- Object
- LLM::LazyConversation
- Defined in:
- lib/llm/lazy_conversation.rb
Overview
LLM::LazyConversation provides a conversation object that allows input prompts to be queued and only sent to the LLM when a response is needed.
Instance Attribute Summary collapse
- #messages ⇒ LLM::MessageQueue readonly
Instance Method Summary collapse
- #chat(prompt, role = :user, **params) ⇒ LLM::Conversation
-
#initialize(provider) ⇒ LazyConversation
constructor
A new instance of LazyConversation.
Constructor Details
#initialize(provider) ⇒ LazyConversation
Returns a new instance of LazyConversation.
27 28 29 30 |
# File 'lib/llm/lazy_conversation.rb', line 27 def initialize(provider) @provider = provider @messages = LLM::MessageQueue.new(provider) end |
Instance Attribute Details
#messages ⇒ LLM::MessageQueue (readonly)
22 23 24 |
# File 'lib/llm/lazy_conversation.rb', line 22 def @messages end |
Instance Method Details
#chat(prompt, role = :user, **params) ⇒ LLM::Conversation
35 36 37 |
# File 'lib/llm/lazy_conversation.rb', line 35 def chat(prompt, role = :user, **params) tap { @messages << [prompt, role, params] } end |