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:
@@ -151,5 +151,5 @@ class Account < ApplicationRecord
|
||||
end
|
||||
|
||||
Account.prepend_mod_with('Account')
|
||||
Account.include_mod_with('EnterpriseAccountConcern')
|
||||
Account.include_mod_with('Concerns::Account')
|
||||
Account.include_mod_with('Audit::Account')
|
||||
|
||||
@@ -172,3 +172,4 @@ end
|
||||
|
||||
Inbox.prepend_mod_with('Inbox')
|
||||
Inbox.include_mod_with('Audit::Inbox')
|
||||
Inbox.include_mod_with('Concerns::Inbox')
|
||||
|
||||
@@ -38,6 +38,10 @@ class InboxPolicy < ApplicationPolicy
|
||||
@account_user.administrator?
|
||||
end
|
||||
|
||||
def response_sources?
|
||||
@account_user.administrator?
|
||||
end
|
||||
|
||||
def create?
|
||||
@account_user.administrator?
|
||||
end
|
||||
|
||||
17
app/policies/response_source_policy.rb
Normal file
17
app/policies/response_source_policy.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
class ResponseSourcePolicy < ApplicationPolicy
|
||||
def parse?
|
||||
@account_user.administrator?
|
||||
end
|
||||
|
||||
def create?
|
||||
@account_user.administrator?
|
||||
end
|
||||
|
||||
def add_document?
|
||||
@account_user.administrator?
|
||||
end
|
||||
|
||||
def remove_document?
|
||||
@account_user.administrator?
|
||||
end
|
||||
end
|
||||
@@ -70,3 +70,4 @@ class MessageTemplates::HookExecutionService
|
||||
true
|
||||
end
|
||||
end
|
||||
MessageTemplates::HookExecutionService.prepend_mod_with('MessageTemplates::HookExecutionService')
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
json.array! @response_sources do |response_source|
|
||||
json.partial! 'api/v1/models/response_source', formats: [:json], resource: response_source
|
||||
end
|
||||
@@ -0,0 +1 @@
|
||||
json.partial! 'api/v1/models/response_source', formats: [:json], resource: @response_source
|
||||
@@ -0,0 +1 @@
|
||||
json.partial! 'api/v1/models/response_source', formats: [:json], resource: @response_source
|
||||
@@ -0,0 +1 @@
|
||||
json.partial! 'api/v1/models/response_source', formats: [:json], resource: @response_source
|
||||
16
app/views/api/v1/models/_response_source.json.jbuilder
Normal file
16
app/views/api/v1/models/_response_source.json.jbuilder
Normal file
@@ -0,0 +1,16 @@
|
||||
json.id resource.id
|
||||
json.name resource.name
|
||||
json.source_link resource.source_link
|
||||
json.source_type resource.source_type
|
||||
json.inbox_id resource.inbox_id
|
||||
json.account_id resource.account_id
|
||||
json.created_at resource.created_at.to_i
|
||||
json.updated_at resource.updated_at.to_i
|
||||
json.response_documents do
|
||||
json.array! resource.response_documents do |response_document|
|
||||
json.id response_document.id
|
||||
json.document_link response_document.document_link
|
||||
json.created_at response_document.created_at.to_i
|
||||
json.updated_at response_document.updated_at.to_i
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user