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.

Parameters:

  • response_text (String)

    raw AI response content, coerced with +to_s+



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

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

Instance Method Details

#callActiveSupport::SafeBuffer

Renders the chat response wrapper with action buttons and formatted content

Returns:

  • (ActiveSupport::SafeBuffer)

    the +chat-response+ container markup



26
27
28
29
30
31
32
33
# File 'app/components/assistant/chat_response_component.rb', line 26

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