Class: ChatMessage
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ChatMessage
- Defined in:
- app/models/chat_message.rb
Instance Method Summary collapse
-
#broadcast_message(event_type) ⇒ Object
Returns the content of the message.
- #role ⇒ Object
Methods inherited from ApplicationRecord
define_decrypted_attribute, define_decrypted_attributes, #errors_in_bullet_points, primary_connection, special_connection
Instance Method Details
#broadcast_message(event_type) ⇒ Object
Returns the content of the message
20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/chat_message.rb', line 20 def (event_type) ActionCable.server.broadcast( "chat_channel_#{chat.id}", { message: event_type, # data: self.as_json(include: :chat) data: self.as_json } ) end |
#role ⇒ Object
13 14 15 |
# File 'app/models/chat_message.rb', line 13 def role sender == 'user' ? 'user' : 'assistant' end |