Initial commit: Add logistics and order_detail message types
Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
- Add Logistics component with progress tracking - Add OrderDetail component for order information - Support data-driven steps and actions - Add blue color scale to widget SCSS - Fix node overflow and progress bar rendering issues - Add English translations for dashboard components Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
22
app/services/llm_formatter/article_llm_formatter.rb
Normal file
22
app/services/llm_formatter/article_llm_formatter.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
class LlmFormatter::ArticleLlmFormatter
|
||||
attr_reader :article
|
||||
|
||||
def initialize(article)
|
||||
@article = article
|
||||
end
|
||||
|
||||
def format(*)
|
||||
<<~TEXT
|
||||
Title: #{article.title}
|
||||
ID: #{article.id}
|
||||
Status: #{article.status}
|
||||
Category: #{article.category&.name || 'Uncategorized'}
|
||||
Author: #{article.author&.name || 'Unknown'}
|
||||
Views: #{article.views}
|
||||
Created At: #{article.created_at}
|
||||
Updated At: #{article.updated_at}
|
||||
Content:
|
||||
#{article.content}
|
||||
TEXT
|
||||
end
|
||||
end
|
||||
35
app/services/llm_formatter/contact_llm_formatter.rb
Normal file
35
app/services/llm_formatter/contact_llm_formatter.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
class LlmFormatter::ContactLlmFormatter < LlmFormatter::DefaultLlmFormatter
|
||||
def format(*)
|
||||
sections = []
|
||||
sections << "Contact ID: ##{@record.id}"
|
||||
sections << 'Contact Attributes:'
|
||||
sections << build_attributes
|
||||
sections << 'Contact Notes:'
|
||||
sections << if @record.notes.any?
|
||||
build_notes
|
||||
else
|
||||
'No notes for this contact'
|
||||
end
|
||||
|
||||
sections.join("\n")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def build_notes
|
||||
@record.notes.all.map { |note| " - #{note.content}" }.join("\n")
|
||||
end
|
||||
|
||||
def build_attributes
|
||||
attributes = []
|
||||
attributes << "Name: #{@record.name}"
|
||||
attributes << "Email: #{@record.email}"
|
||||
attributes << "Phone: #{@record.phone_number}"
|
||||
attributes << "Location: #{@record.location}"
|
||||
attributes << "Country Code: #{@record.country_code}"
|
||||
@record.account.custom_attribute_definitions.with_attribute_model('contact_attribute').each do |attribute|
|
||||
attributes << "#{attribute.attribute_display_name}: #{@record.custom_attributes[attribute.attribute_key]}"
|
||||
end
|
||||
attributes.join("\n")
|
||||
end
|
||||
end
|
||||
60
app/services/llm_formatter/conversation_llm_formatter.rb
Normal file
60
app/services/llm_formatter/conversation_llm_formatter.rb
Normal file
@@ -0,0 +1,60 @@
|
||||
class LlmFormatter::ConversationLlmFormatter < LlmFormatter::DefaultLlmFormatter
|
||||
def format(config = {})
|
||||
sections = []
|
||||
sections << "Conversation ID: ##{@record.display_id}"
|
||||
sections << "Channel: #{@record.inbox.channel.name}"
|
||||
sections << 'Message History:'
|
||||
sections << if @record.messages.any?
|
||||
build_messages(config)
|
||||
else
|
||||
'No messages in this conversation'
|
||||
end
|
||||
|
||||
sections << "Contact Details: #{@record.contact.to_llm_text}" if config[:include_contact_details]
|
||||
|
||||
attributes = build_attributes
|
||||
if attributes.present?
|
||||
sections << 'Conversation Attributes:'
|
||||
sections << attributes
|
||||
end
|
||||
|
||||
sections.join("\n")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def build_messages(config = {})
|
||||
return "No messages in this conversation\n" if @record.messages.empty?
|
||||
|
||||
message_text = ''
|
||||
messages = @record.messages.where.not(message_type: :activity).order(created_at: :asc)
|
||||
|
||||
messages.each do |message|
|
||||
# Skip private messages unless explicitly included in config
|
||||
next if message.private? && !config[:include_private_messages]
|
||||
|
||||
message_text << format_message(message)
|
||||
end
|
||||
message_text
|
||||
end
|
||||
|
||||
def format_message(message)
|
||||
sender = case message.sender_type
|
||||
when 'User'
|
||||
'Support Agent'
|
||||
when 'Contact'
|
||||
'User'
|
||||
else
|
||||
'Bot'
|
||||
end
|
||||
sender = "[Private Note] #{sender}" if message.private?
|
||||
"#{sender}: #{message.content_for_llm}\n"
|
||||
end
|
||||
|
||||
def build_attributes
|
||||
attributes = @record.account.custom_attribute_definitions.with_attribute_model('conversation_attribute').map do |attribute|
|
||||
"#{attribute.attribute_display_name}: #{@record.custom_attributes[attribute.attribute_key]}"
|
||||
end
|
||||
attributes.join("\n")
|
||||
end
|
||||
end
|
||||
9
app/services/llm_formatter/default_llm_formatter.rb
Normal file
9
app/services/llm_formatter/default_llm_formatter.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class LlmFormatter::DefaultLlmFormatter
|
||||
def initialize(record)
|
||||
@record = record
|
||||
end
|
||||
|
||||
def format(*)
|
||||
# override this
|
||||
end
|
||||
end
|
||||
20
app/services/llm_formatter/llm_text_formatter_service.rb
Normal file
20
app/services/llm_formatter/llm_text_formatter_service.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
class LlmFormatter::LlmTextFormatterService
|
||||
def initialize(record)
|
||||
@record = record
|
||||
end
|
||||
|
||||
def format(config = {})
|
||||
formatter_class = find_formatter
|
||||
formatter_class.new(@record).format(config)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_formatter
|
||||
formatter_name = "LlmFormatter::#{@record.class.name}LlmFormatter"
|
||||
formatter_class = formatter_name.safe_constantize
|
||||
raise FormatterNotFoundError, "No formatter found for #{@record.class.name}" unless formatter_class
|
||||
|
||||
formatter_class
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user