Class: RailsOrchestrator::Conversation
- Inherits:
-
Object
- Object
- RailsOrchestrator::Conversation
- Includes:
- Enumerable
- Defined in:
- lib/rails_orchestrator/conversation.rb
Instance Method Summary collapse
- #assistant(content) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize ⇒ Conversation
constructor
A new instance of Conversation.
- #size ⇒ Object
- #system(content) ⇒ Object
- #to_a ⇒ Object
- #user(content) ⇒ Object
Constructor Details
#initialize ⇒ Conversation
Returns a new instance of Conversation.
7 8 9 |
# File 'lib/rails_orchestrator/conversation.rb', line 7 def initialize @messages = [] end |
Instance Method Details
#assistant(content) ⇒ Object
21 22 23 24 |
# File 'lib/rails_orchestrator/conversation.rb', line 21 def assistant(content) @messages << Message.new(role: "assistant", content: content) self end |
#each(&block) ⇒ Object
26 27 28 |
# File 'lib/rails_orchestrator/conversation.rb', line 26 def each(&block) @messages.each(&block) end |
#size ⇒ Object
34 35 36 |
# File 'lib/rails_orchestrator/conversation.rb', line 34 def size @messages.size end |
#system(content) ⇒ Object
11 12 13 14 |
# File 'lib/rails_orchestrator/conversation.rb', line 11 def system(content) @messages << Message.new(role: "system", content: content) self end |
#to_a ⇒ Object
30 31 32 |
# File 'lib/rails_orchestrator/conversation.rb', line 30 def to_a @messages.map(&:to_h) end |