diff --git a/app/channels/copilot_channel.rb b/app/channels/copilot_channel.rb new file mode 100644 index 000000000..2fde1c32f --- /dev/null +++ b/app/channels/copilot_channel.rb @@ -0,0 +1,35 @@ +class CopilotChannel < ApplicationCable::Channel + def subscribed + current_user + current_account + ensure_stream + end + + def message(data) + return if @current_account.blank? + + Captain::ProcessCopilotMessageJob.perform_later( + assistant_id: data['assistant_id'], + message: data['message'], + options: { + user_id: @current_user.id, + conversation_id: data['conversation_id'], + previous_history: data['previous_history'] + } + ) + end + + def ensure_stream + stream_from "copilot_#{@current_account.id}_#{@current_user.id}" + end + + def current_user + @current_user ||= User.find(params[:user_id]) + end + + def current_account + return if current_user.blank? + + @current_account ||= @current_user.accounts.find(params[:account_id]) + end +end diff --git a/app/javascript/dashboard/api/inbox/conversation.js b/app/javascript/dashboard/api/inbox/conversation.js index 39546096f..1a87e6d96 100644 --- a/app/javascript/dashboard/api/inbox/conversation.js +++ b/app/javascript/dashboard/api/inbox/conversation.js @@ -134,10 +134,6 @@ class ConversationApi extends ApiClient { return axios.get(`${this.url}/${conversationId}/attachments`); } - requestCopilot(conversationId, body) { - return axios.post(`${this.url}/${conversationId}/copilot`, body); - } - getInboxAssistant(conversationId) { return axios.get(`${this.url}/${conversationId}/inbox_assistant`); } diff --git a/app/javascript/dashboard/components-next/copilot/Copilot.vue b/app/javascript/dashboard/components-next/copilot/Copilot.vue index cc445257a..903450bdd 100644 --- a/app/javascript/dashboard/components-next/copilot/Copilot.vue +++ b/app/javascript/dashboard/components-next/copilot/Copilot.vue @@ -8,6 +8,7 @@ import CopilotInput from './CopilotInput.vue'; import CopilotLoader from './CopilotLoader.vue'; import CopilotAgentMessage from './CopilotAgentMessage.vue'; import CopilotAssistantMessage from './CopilotAssistantMessage.vue'; +import CopilotThinkingBlock from 'dashboard/components/copilot/CopilotThinkingBlock.vue'; import ToggleCopilotAssistant from './ToggleCopilotAssistant.vue'; import Icon from '../icon/Icon.vue'; import Button from '../button/Button.vue'; @@ -43,8 +44,6 @@ const emit = defineEmits(['sendMessage', 'reset', 'setAssistant', 'close']); const { t } = useI18n(); -const COPILOT_USER_ROLES = ['assistant', 'system']; - const sendMessage = message => { emit('sendMessage', message); useTrack(COPILOT_EVENTS.SEND_MESSAGE); @@ -113,11 +112,11 @@ watch( -
-
+
+
diff --git a/app/javascript/dashboard/components/copilot/CopilotContainer.vue b/app/javascript/dashboard/components/copilot/CopilotContainer.vue index 1fed0e861..fd10489dc 100644 --- a/app/javascript/dashboard/components/copilot/CopilotContainer.vue +++ b/app/javascript/dashboard/components/copilot/CopilotContainer.vue @@ -1,8 +1,8 @@