Class: Layered::Assistant::Message
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- ApplicationRecord
- Layered::Assistant::Message
- Includes:
- ActionView::RecordIdentifier
- Defined in:
- app/models/layered/assistant/message.rb
Instance Method Summary collapse
-
#broadcast_created ⇒ Object
Broadcasting.
- #broadcast_response_complete ⇒ Object
- #broadcast_streaming_content ⇒ Object
- #broadcast_updated ⇒ Object
Instance Method Details
#broadcast_created ⇒ Object
Broadcasting
28 29 30 31 32 33 |
# File 'app/models/layered/assistant/message.rb', line 28 def broadcast_created broadcast_append_to conversation, targets: ".#{dom_id(conversation)}_messages", partial: "layered/assistant/messages/message", locals: { message: self } end |
#broadcast_response_complete ⇒ Object
42 43 44 45 46 |
# File 'app/models/layered/assistant/message.rb', line 42 def broadcast_response_complete broadcast_action_to conversation, action: :enable_composer, targets: ".#{dom_id(conversation)}_composer" end |
#broadcast_streaming_content ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/models/layered/assistant/message.rb', line 48 def broadcast_streaming_content rendered = helpers.render_streaming_markdown(content) html = rendered[:html] if rendered[:has_unclosed_fence] html += helpers.tag.div( helpers.tag.span(class: "l-ui-typing-indicator__dot") + helpers.tag.span(class: "l-ui-typing-indicator__dot") + helpers.tag.span(class: "l-ui-typing-indicator__dot"), class: "l-ui-typing-indicator", role: "status", "aria-label": "Assistant is typing" ) end broadcast_action_to conversation, action: :render_content, targets: ".#{dom_id(self)}_body", content: html end |
#broadcast_updated ⇒ Object
35 36 37 38 39 40 |
# File 'app/models/layered/assistant/message.rb', line 35 def broadcast_updated broadcast_replace_to conversation, targets: ".#{dom_id(self)}", partial: "layered/assistant/messages/message", locals: { message: self } end |