From 0b4028b95dcb4c9718b62914a9019774df19e38e Mon Sep 17 00:00:00 2001 From: Pranav Date: Thu, 16 Jan 2025 01:57:30 -0800 Subject: [PATCH] feat: Add support for the references in FAQs (#10699) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, it’s unclear whether an FAQ item is generated from a document, derived from a conversation, or added manually. This PR resolves the issue by providing visibility into the source of each FAQ. Users can now see whether an FAQ was generated or manually added and, if applicable, by whom. - Move the document_id to a polymorphic relation (documentable). - Updated the APIs to accommodate the change. - Update the service to add corresponding references. - Updated the specs. Screenshot 2025-01-15 at 11 27 56 PM --------- Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> --- .../components-next/captain/PageLayout.vue | 4 +- .../captain/assistant/ResponseCard.vue | 91 +++++++++++++++---- .../i18n/locale/en/integrations.json | 5 +- .../dashboard/captain/responses/Index.vue | 15 ++- ...ert_document_to_polymorphic_association.rb | 33 +++++++ db/schema.rb | 7 +- .../captain/assistant_responses_controller.rb | 13 ++- .../captain/documents/response_builder_job.rb | 2 +- .../app/models/captain/assistant_response.rb | 25 ++--- enterprise/app/models/captain/document.rb | 2 +- .../enterprise/concerns/conversation.rb | 1 + .../app/models/enterprise/concerns/user.rb | 2 + .../captain/llm/conversation_faq_service.rb | 12 ++- .../captain/_assistant_response.json.jbuilder | 24 ++++- .../assistant_responses_controller_spec.rb | 12 +-- .../documents/response_builder_job_spec.rb | 4 +- .../llm/conversation_faq_service_spec.rb | 6 +- 17 files changed, 197 insertions(+), 61 deletions(-) create mode 100644 db/migrate/20250116061033_convert_document_to_polymorphic_association.rb diff --git a/app/javascript/dashboard/components-next/captain/PageLayout.vue b/app/javascript/dashboard/components-next/captain/PageLayout.vue index 36229d42833b0..b0d10b889dcc2 100644 --- a/app/javascript/dashboard/components-next/captain/PageLayout.vue +++ b/app/javascript/dashboard/components-next/captain/PageLayout.vue @@ -42,7 +42,7 @@ const handlePageChange = event => {