Class: Zephira::Commands::History

Inherits:
Object
  • Object
show all
Defined in:
lib/zephira/commands/history.rb

Class Method Summary collapse

Class Method Details

.descriptionObject



11
12
13
# File 'lib/zephira/commands/history.rb', line 11

def description
  "Display the conversation history"
end

.nameObject



7
8
9
# File 'lib/zephira/commands/history.rb', line 7

def name
  "history"
end

.run(agent:, args:) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/zephira/commands/history.rb', line 15

def run(agent:, args:)
  agent.history.messages.each do |message|
    content = message[:content].to_s
    content = "#{content.gsub("\n", "\\n").slice(0, 100)}..." if content.length > 100
    puts "[#{message[:timestamp]}] #{message[:role]}: #{content}"
  end
end