Skip to content

Commit

Permalink
chore: Fix trigger message for response Bot (#8322)
Browse files Browse the repository at this point in the history
- Fix the bug where wrong messages was used to search response sources
  • Loading branch information
sojan-official committed Nov 9, 2023
1 parent af7631d commit 7b09b02
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Expand Up @@ -3,7 +3,7 @@ class Enterprise::MessageTemplates::ResponseBotService

def perform
ActiveRecord::Base.transaction do
@response = get_response(conversation.messages.last.content)
@response = get_response(conversation.messages.incoming.last.content)
process_response
end
rescue StandardError => e
Expand Down
Expand Up @@ -14,10 +14,11 @@
stub_request(:post, 'https://api.openai.com/v1/embeddings').to_return(status: 200, body: {}.to_json,
headers: { Content_Type: 'application/json' })
create(:message, message_type: :incoming, conversation: conversation, content: 'Hi')
create(:message, message_type: :outgoing, conversation: conversation, content: 'Hello')
4.times { create(:response, response_source: response_source) }
allow(ChatGpt).to receive(:new).and_return(chat_gpt_double)
allow(chat_gpt_double).to receive(:generate_response).and_return({ 'response' => 'some_response', 'context_ids' => Response.all.map(&:id) })
allow(conversation.inbox).to receive(:get_responses).and_return([response_object])
allow(conversation.inbox).to receive(:get_responses).with('Hi').and_return([response_object])
end

describe '#perform' do
Expand Down

0 comments on commit 7b09b02

Please sign in to comment.