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,34 @@
class Api::V1::Accounts::ResponseSourcesController < Api::V1::Accounts::BaseController
before_action :current_account
before_action :check_authorization
before_action :find_response_source, only: [:add_document, :remove_document]
def parse
links = PageCrawlerService.new(params[:link]).page_links
render json: { links: links }
end
def create
@response_source = Current.account.response_sources.new(response_source_params)
@response_source.save!
end
def add_document
@response_source.response_documents.create!(document_link: params[:document_link])
end
def remove_document
@response_source.response_documents.find(params[:document_id]).destroy!
end
private
def find_response_source
@response_source = Current.account.response_sources.find(params[:id])
end
def response_source_params
params.require(:response_source).permit(:name, :source_link, :inbox_id,
response_documents_attributes: [:document_link])
end
end

View File

@@ -1,4 +1,8 @@
module Enterprise::Api::V1::Accounts::InboxesController
def response_sources
@response_sources = @inbox.response_sources
end
def inbox_attributes
super + ee_inbox_attributes
end