From 7380f0e7ce23d5ffb6387cec2443033e0784989f Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Fri, 17 Nov 2023 19:54:15 -0800 Subject: [PATCH] chore: Making OpenAI label suggestions optional (#8374) Co-authored-by: Pranav Raj S --- .../dashboard/assets/scss/_formulate.scss | 20 ++++++++++++++ .../widgets/conversation/MessagesView.vue | 2 +- app/javascript/dashboard/mixins/aiMixin.js | 20 +++++++++----- .../settings/integrationapps/NewHook.vue | 2 +- config/integration/apps.yml | 9 ++++++- .../integrations/openai_processor_service.rb | 27 ++++++++++++++----- 6 files changed, 65 insertions(+), 15 deletions(-) diff --git a/app/javascript/dashboard/assets/scss/_formulate.scss b/app/javascript/dashboard/assets/scss/_formulate.scss index 57c43a3d6..d683ce3c7 100644 --- a/app/javascript/dashboard/assets/scss/_formulate.scss +++ b/app/javascript/dashboard/assets/scss/_formulate.scss @@ -16,3 +16,23 @@ width: 100%; } } + +.integration-hooks { + .formulate-input[data-type='checkbox'] { + .formulate-input-wrapper { + @apply flex; + + .formulate-input-element { + @apply pr-2; + + input { + @apply mb-0; + } + } + } + + .formulate-input-element-decorator { + @apply hidden; + } + } +} diff --git a/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue b/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue index c6d492061..10b1dce32 100644 --- a/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue +++ b/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue @@ -340,7 +340,7 @@ export default { // method available in mixin, need to ensure that integrations are present await this.fetchIntegrationsIfRequired(); - if (!this.isAIIntegrationEnabled) { + if (!this.isLabelSuggestionFeatureEnabled) { return; } diff --git a/app/javascript/dashboard/mixins/aiMixin.js b/app/javascript/dashboard/mixins/aiMixin.js index 3a9fc4a75..f3558a6c7 100644 --- a/app/javascript/dashboard/mixins/aiMixin.js +++ b/app/javascript/dashboard/mixins/aiMixin.js @@ -15,18 +15,26 @@ export default { currentChat: 'getSelectedChat', replyMode: 'draftMessages/getReplyEditorMode', }), - isAIIntegrationEnabled() { - return !!this.appIntegrations.find( + aiIntegration() { + return this.appIntegrations.find( integration => integration.id === 'openai' && !!integration.hooks.length - ); + ).hooks[0]; + }, + isAIIntegrationEnabled() { + return !!this.aiIntegration; + }, + isLabelSuggestionFeatureEnabled() { + if (this.aiIntegration) { + const { settings = {} } = this.aiIntegration || {}; + return settings.label_suggestion; + } + return false; }, isFetchingAppIntegrations() { return this.uiFlags.isFetching; }, hookId() { - return this.appIntegrations.find( - integration => integration.id === 'openai' && !!integration.hooks.length - ).hooks[0].id; + return this.aiIntegration.id; }, draftMessage() { return this.$store.getters['draftMessages/get'](this.draftKey); diff --git a/app/javascript/dashboard/routes/dashboard/settings/integrationapps/NewHook.vue b/app/javascript/dashboard/routes/dashboard/settings/integrationapps/NewHook.vue index 93eed8795..454f03dac 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/integrationapps/NewHook.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/integrationapps/NewHook.vue @@ -1,6 +1,6 @@