feat: update message content and include 'Conversation Attributes'
This commit is contained in:
@@ -12,7 +12,9 @@ RSpec.describe LlmFormatter::ConversationLlmFormatter do
|
||||
"Conversation ID: ##{conversation.display_id}",
|
||||
"Channel: #{conversation.inbox.channel.name}",
|
||||
'Message History:',
|
||||
'No messages in this conversation'
|
||||
'No messages in this conversation',
|
||||
'Conversation Attributes:',
|
||||
''
|
||||
].join("\n")
|
||||
|
||||
expect(formatter.format).to eq(expected_output)
|
||||
@@ -41,6 +43,8 @@ RSpec.describe LlmFormatter::ConversationLlmFormatter do
|
||||
'Message History:',
|
||||
'User: Hello, I need help',
|
||||
'Support agent: How can I assist you today?',
|
||||
'',
|
||||
'Conversation Attributes:',
|
||||
''
|
||||
].join("\n")
|
||||
|
||||
@@ -55,11 +59,38 @@ RSpec.describe LlmFormatter::ConversationLlmFormatter do
|
||||
"Channel: #{conversation.inbox.channel.name}",
|
||||
'Message History:',
|
||||
'No messages in this conversation',
|
||||
"Contact Details: #{conversation.contact.to_llm_text}"
|
||||
"Contact Details: #{conversation.contact.to_llm_text}",
|
||||
'Conversation Attributes:',
|
||||
''
|
||||
].join("\n")
|
||||
|
||||
expect(formatter.format(include_contact_details: true)).to eq(expected_output)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when conversation has custom attributes' do
|
||||
it 'includes formatted custom attributes in the output' do
|
||||
create(
|
||||
:custom_attribute_definition,
|
||||
account: account,
|
||||
attribute_display_name: 'Order ID',
|
||||
attribute_key: 'order_id',
|
||||
attribute_model: :conversation_attribute
|
||||
)
|
||||
|
||||
conversation.update(custom_attributes: { 'order_id' => '12345' })
|
||||
|
||||
expected_output = [
|
||||
"Conversation ID: ##{conversation.display_id}",
|
||||
"Channel: #{conversation.inbox.channel.name}",
|
||||
'Message History:',
|
||||
'No messages in this conversation',
|
||||
'Conversation Attributes:',
|
||||
'Order ID: 12345'
|
||||
].join("\n")
|
||||
|
||||
expect(formatter.format).to eq(expected_output)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user