Class: Askcii::Commands::HistoryCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Askcii::Commands::HistoryCommand
- Defined in:
- lib/askcii/commands/history_command.rb
Overview
Displays conversation history for the current session
Instance Attribute Summary
Attributes inherited from BaseCommand
Instance Method Summary collapse
Methods inherited from BaseCommand
Constructor Details
This class inherits a constructor from Askcii::Commands::BaseCommand
Instance Method Details
#execute ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/askcii/commands/history_command.rb', line 7 def execute verbose "Retrieving history for session: #{session_context}" chat = Chat.find(context: session_context) unless chat puts "No history found for this session." exit 0 end = chat..order(:created_at).all if .empty? puts "No messages in this session." exit 0 end puts "Session: #{chat.context}" puts "Model: #{chat.model_id}" puts "Messages: #{messages.count}" puts puts "=" * 80 puts .each do |msg| role_label = msg.role.to_s.capitalize = msg.created_at.strftime('%Y-%m-%d %H:%M:%S') puts "#{role_label} (#{timestamp}):" puts msg.content puts puts "-" * 80 puts end exit 0 end |