feat: Response Bot using GPT and Webpage Sources (#7518)

This commit introduces the ability to associate response sources to an inbox, allowing external webpages to be parsed by Chatwoot. The parsed data is converted into embeddings for use with GPT models when managing customer queries.

The implementation relies on the `pgvector` extension for PostgreSQL. Database migrations related to this feature are handled separately by `Features::ResponseBotService`. A future update will integrate these migrations into the default rails migrations, once compatibility with Postgres extensions across all self-hosted installation options is confirmed.

Additionally, a new GitHub action has been added to the CI pipeline to ensure the execution of specs related to this feature.
This commit is contained in:
Sojan Jose
2023-07-21 18:11:51 +03:00
committed by GitHub
parent 30f3928904
commit 480f34803b
41 changed files with 976 additions and 10 deletions

View File

@@ -0,0 +1,46 @@
# == Schema Information
#
# Table name: response_documents
#
# id :bigint not null, primary key
# content :text
# document_link :string
# document_type :string
# created_at :datetime not null
# updated_at :datetime not null
# account_id :bigint not null
# document_id :bigint
# response_source_id :bigint not null
#
# Indexes
#
# index_response_documents_on_document (document_type,document_id)
# index_response_documents_on_response_source_id (response_source_id)
#
class ResponseDocument < ApplicationRecord
has_many :responses, dependent: :destroy
belongs_to :account
belongs_to :response_source
before_validation :set_account
after_create :ensure_content
after_update :handle_content_change
private
def set_account
self.account = response_source.account
end
def ensure_content
return unless content.nil?
ResponseDocumentContentJob.perform_later(self)
end
def handle_content_change
return unless saved_change_to_content? && content.present?
ResponseBuilderJob.perform_later(self)
end
end