Module: Brute::Messages

Defined in:
lib/brute/messages.rb

Overview

The in-memory conversation log is just a plain Array of Brute::Message. This module adds a little sugar for appending role-tagged messages; mix it into an array via Brute.log. Persistence is NOT here — loading/saving the log to disk is the Brute::Middleware::SessionLog middleware's job.

Instance Method Summary collapse

Instance Method Details

#assistant(content) ⇒ Object



51
# File 'lib/brute/messages.rb', line 51

def assistant(content); self << Message.new(role: :assistant, content: content); end

#system(content) ⇒ Object



52
# File 'lib/brute/messages.rb', line 52

def system(content);    self << Message.new(role: :system,    content: content); end

#tool(content, tool_call_id:) ⇒ Object



54
55
56
# File 'lib/brute/messages.rb', line 54

def tool(content, tool_call_id:)
  self << Message.new(role: :tool, content: content, tool_call_id: tool_call_id)
end

#user(content) ⇒ Object



50
# File 'lib/brute/messages.rb', line 50

def user(content);      self << Message.new(role: :user,      content: content); end