mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-29 02:02:27 +00:00
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.
35 lines
1.0 KiB
Ruby
35 lines
1.0 KiB
Ruby
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
|