feat: ensure captain limits

This commit is contained in:
Shivam Mishra
2025-01-17 16:29:15 +05:30
parent bc7294e88e
commit 807383ff7d
3 changed files with 3 additions and 1 deletions
+1
View File
@@ -231,6 +231,7 @@ en:
description: 'Create issues in Linear directly from your conversation window. Alternatively, link existing Linear issues for a more streamlined and efficient issue tracking process.'
captain:
copilot_error: 'Please connect an assistant to this inbox to use copilot'
copilot_limit: 'You are out of copilot credits. You can buy more credits from the billing section.'
public_portal:
search:
search_placeholder: Search for article by title or body...
@@ -7,6 +7,7 @@ module Enterprise::Api::V1::Accounts::ConversationsController
def copilot
assistant = @conversation.inbox.captain_assistant
return render json: { message: I18n.t('captain.copilot_error') } unless assistant
return render json: { message: I18n.t('captain.copilot_limit') } unless @conversation.inbox.captain_active?
response = Captain::Copilot::ChatService.new(
assistant,
@@ -10,6 +10,6 @@ module Enterprise::MessageTemplates::HookExecutionService
end
def should_process_captain_response?
conversation.pending? && message.incoming? && inbox.captain_assistant.present?
conversation.pending? && message.incoming? && inbox.captain_active?
end
end