Class: Askcii::Commands::LastResponseCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Askcii::Commands::LastResponseCommand
- Defined in:
- lib/askcii/commands/last_response_command.rb
Overview
Retrieves and displays the last assistant response from 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 |
# File 'lib/askcii/commands/last_response_command.rb', line 7 def execute verbose "Retrieving last response from session: #{session_context}" chat = Chat.find(context: session_context) unless chat error! "No chat session found for context: #{session_context}" end = chat. .where(role: 'assistant') .order(Sequel.desc(:created_at)) .first unless error! "No assistant messages found in this session" end puts .content exit 0 end |