Class: Assistant::ChatResponseComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/assistant/chat_response_component.rb

Overview

ViewComponent for rendering AI chat responses

Features:

  • Markdown rendering with proper HTML formatting
  • SQL queries in collapsible Bootstrap accordions
  • Tables with export buttons (CSV/Excel)
  • Formatted numbers, dates, and currency
  • Entity links to CRM (customers, orders, products)
  • Copy to clipboard button

Usage:
<%= render Assistant::ChatResponseComponent.new(response_text: message['content']) %>

Instance Method Summary collapse

Constructor Details

#initialize(response_text:) ⇒ ChatResponseComponent

Returns a new instance of ChatResponseComponent.



18
19
20
21
# File 'app/components/assistant/chat_response_component.rb', line 18

def initialize(response_text:)
  @response_text = response_text.to_s
  super()
end

Instance Method Details

#callObject



23
24
25
26
27
28
29
30
# File 'app/components/assistant/chat_response_component.rb', line 23

def call
   :div, class: 'chat-response' do
    safe_join([
      render_action_buttons,
      render_formatted_content
    ])
  end
end